Go\Core\AspectLoader::getUnloadedAspects PHP Method

getUnloadedAspects() public method

Returns list of unloaded aspects in the container
public getUnloadedAspects ( ) : array | Go\Aop\Aspect[]
return array | Go\Aop\Aspect[]
    public function getUnloadedAspects()
    {
        $unloadedAspects = [];
        foreach ($this->container->getByTag('aspect') as $aspect) {
            if (!isset($this->loadedAspects[get_class($aspect)])) {
                $unloadedAspects[] = $aspect;
            }
        }
        return $unloadedAspects;
    }

Usage Example

示例#1
0
 /**
  * This method may transform the supplied source and return a new replacement for it
  *
  * @param StreamMetaData $metadata Metadata for source
  * @return boolean Return false if transformation should be stopped
  */
 public function transform(StreamMetaData $metadata)
 {
     $totalTransformations = 0;
     $fileName = $metadata->uri;
     $astTree = ReflectionEngine::parseFile($fileName, $metadata->source);
     $parsedSource = new ReflectionFile($fileName, $astTree);
     // Check if we have some new aspects that weren't loaded yet
     $unloadedAspects = $this->aspectLoader->getUnloadedAspects();
     if (!empty($unloadedAspects)) {
         $this->loadAndRegisterAspects($unloadedAspects);
     }
     $advisors = $this->container->getByTag('advisor');
     $namespaces = $parsedSource->getFileNamespaces();
     $lineOffset = 0;
     foreach ($namespaces as $namespace) {
         $classes = $namespace->getClasses();
         foreach ($classes as $class) {
             // Skip interfaces and aspects
             if ($class->isInterface() || in_array(Aspect::class, $class->getInterfaceNames())) {
                 continue;
             }
             $wasClassProcessed = $this->processSingleClass($advisors, $metadata, $class, $lineOffset);
             $totalTransformations += (int) $wasClassProcessed;
         }
         $wasFunctionsProcessed = $this->processFunctions($advisors, $metadata, $namespace);
         $totalTransformations += (int) $wasFunctionsProcessed;
     }
     // If we return false this will indicate no more transformation for following transformers
     return $totalTransformations > 0;
 }
All Usage Examples Of Go\Core\AspectLoader::getUnloadedAspects