Skimia\Foundation
  • Namespace
  • Class
  • Tree
  • Todo
  • Download

Namespaces

  • None
  • PHP
  • Skimia
    • Foundation
      • Annotations
      • Exceptions
        • Fail
      • Providers
        • Traits
      • Support
        • Traits
      • Testing
        • Traits

Classes

  • Skimia\Foundation\Annotations\BaseServiceProvider
  • Skimia\Foundation\Annotations\Scanner
  • Skimia\Foundation\FoundationServiceProvider
  • Skimia\Foundation\Testing\CommandOutput

Interfaces

  • Skimia\Foundation\Testing\TestablePromptCommandInterface

Traits

  • Skimia\Foundation\Providers\Traits\CommandLoaderTrait
  • Skimia\Foundation\Support\Traits\NamespaceClassFinderTrait
  • Skimia\Foundation\Testing\Traits\CommandTrait
  • Skimia\Foundation\Testing\Traits\TestableCommandTrait

Exceptions

  • Exception
  • LogicException
  • Skimia\Foundation\Exceptions\Fail\InvalidSuperclassUsedForTraitException
  • Skimia\Foundation\Exceptions\Fail\IsNotASubclassOfException

Functions

  • ensure_trait_used_in_subclass_of_or_fail
  • is_subclass_of_or_fail
  1 <?php
  2 
  3 namespace Skimia\Foundation\Annotations;
  4 
  5 use Illuminate\Support\ServiceProvider;
  6 use Skimia\Foundation\Support\Traits\NamespaceClassFinderTrait;
  7 use Illuminate\Contracts\Foundation\Application;
  8 
  9 abstract class BaseServiceProvider extends ServiceProvider
 10 {
 11     use NamespaceClassFinderTrait;
 12 
 13     /**
 14      * The classes to scan for annotations.
 15      *
 16      * @var array
 17      */
 18     protected $classesToScan = [];
 19 
 20     /**
 21      * Determines if we will auto-scan in the local environment.
 22      *
 23      * @var bool
 24      */
 25     protected $scanWhenLocal = true;
 26 
 27     /**
 28      * Determines whether or not to automatically scan all namespaced
 29      * classes for annotations.
 30      *
 31      * @var bool
 32      */
 33     protected $scanEverything = true;
 34 
 35     /**
 36      * @param \Illuminate\Contracts\Foundation\Application $app
 37      */
 38     public function __construct(Application $app)
 39     {
 40         //$this->finder = new AnnotationFinder($app);
 41         parent::__construct($app);
 42     }
 43 
 44     /**
 45      * Register the service provider.
 46      *
 47      * @return void
 48      */
 49     public function register()
 50     {
 51         $this->registerAnnotationScanner();
 52 
 53         if (method_exists($this, 'registerCommands')) {
 54             $this->registerCommands();
 55         }
 56     }
 57 
 58     /**
 59      * Register the application's annotated event listeners.
 60      *
 61      * @return void
 62      */
 63     public function boot()
 64     {
 65         $this->addAnnotations($this->getAnnotationScanner());
 66 
 67         $this->loadAnnotated();
 68     }
 69 
 70     /**
 71      * Register the scanner.
 72      *
 73      * @return void
 74      */
 75     abstract protected function registerAnnotationScanner();
 76 
 77     /**
 78      * @return Scanner
 79      */
 80     abstract protected function getAnnotationScanner();
 81 
 82     /**
 83      * Add annotation classes to the api routing scanner.
 84      *
 85      * @param Scanner $scanner
 86      */
 87     public function addAnnotations(Scanner $scanner)
 88     {
 89     }
 90 
 91     /**
 92      * Scan the events for the application.
 93      *
 94      * @return void
 95      */
 96     protected function scanAnnotations()
 97     {
 98         $scans = $this->classesToScan();
 99 
100         if (empty($scans)) {
101             return;
102         }
103 
104         $scanner = $this->getAnnotationScanner();
105 
106         $scanner->setClassesToScan($scans);
107 
108         $scanner->scan();
109     }
110 
111     /**
112      * Load the annotated events.
113      *
114      * @return void
115      */
116     public function loadAnnotated()
117     {
118         if ($this->app->environment('local') && $this->scanWhenLocal) {
119             $this->scanAnnotations();
120         }
121 
122         $scans = $this->classesToScan();
123 
124         if (! empty($scans) && $this->getAnnotationScanner()->annotationsAreScanned()) {
125             $this->getAnnotationScanner()->loadScannedAnnotations();
126         }
127     }
128 
129     /**
130      * Get the classes to be scanned by the provider.
131      *
132      * @return array
133      */
134     public function classesToScan()
135     {
136         if ($this->scanEverything) {
137             return $this->getAllClasses();
138         }
139 
140         return $this->classesToScan;
141     }
142 }
143 
Skimia\Foundation API documentation generated by ApiGen