Ejemplo n.º 1
0
 /**
  * Index and register i18n string located in default properties which belongs to TranslatorTrait
  * classes.
  *
  * @param ClassLocatorInterface $locator
  */
 public function indexClasses(ClassLocatorInterface $locator)
 {
     foreach ($locator->getClasses(TranslatorTrait::class) as $class => $options) {
         $reflection = new \ReflectionClass($class);
         $strings = $this->fetchStrings($reflection, $reflection->getConstant('INHERIT_TRANSLATIONS'));
         if (!empty($strings)) {
             $this->logger()->info("Found translation string(s) in class '{class}'.", ['class' => $reflection->getName()]);
         }
         foreach ($strings as $string) {
             $this->register($this->translator->resolveDomain($reflection->getName()), $string);
         }
     }
     $this->catalogue->saveDomains();
 }
Ejemplo n.º 2
0
 /**
  * @param Indexer                    $indexer
  * @param InvocationLocatorInterface $invocationLocator
  * @param ClassLocatorInterface      $classLocator
  */
 public function perform(Indexer $indexer, InvocationLocatorInterface $invocationLocator, ClassLocatorInterface $classLocator)
 {
     if ($invocationLocator instanceof LoggerAwareInterface) {
         //Way too much verbosity
         $invocationLocator->setLogger(new NullLogger());
     }
     if ($classLocator instanceof LoggerAwareInterface) {
         //Way too much verbosity
         $classLocator->setLogger(new NullLogger());
     }
     $this->writeln("<info>Scanning translate function usages...</info>");
     $indexer->indexInvocations($invocationLocator);
     $this->writeln("<info>Scanning Translatable classes...</info>");
     $indexer->indexClasses($classLocator);
 }
Ejemplo n.º 3
0
 /**
  * Locate every available Symfony command using Tokenizer.
  *
  * @return array
  */
 public function locateCommands()
 {
     $this->commands = [];
     foreach ($this->locator->getClasses(SymfonyCommand::class) as $class) {
         if ($class['abstract']) {
             continue;
         }
         $this->commands[] = $class['name'];
     }
     $this->memory->saveData('commands', $this->commands);
     return $this->commands;
 }
Ejemplo n.º 4
0
 /**
  * Locate ORM entities sources.
  *
  * @param ClassLocatorInterface $locator
  * @return $this
  */
 protected function locateSources(ClassLocatorInterface $locator)
 {
     foreach ($locator->getClasses(DocumentSource::class) as $class => $definition) {
         $reflection = new \ReflectionClass($class);
         if ($reflection->isAbstract() || empty($document = $reflection->getConstant('DOCUMENT'))) {
             continue;
         }
         if ($this->hasDocument($document)) {
             //Associating source with record
             $this->document($document)->setSource($class);
         }
     }
     return $this;
 }