getIndexedClasses() public method

public getIndexedClasses ( ) : array
return array of class => filename
Exemplo n.º 1
0
 /**
  * Create route list
  * @param string|null $module
  * @return ResourceRouteList
  */
 public final function create($module = NULL)
 {
     $routeList = new ResourceRouteList($module ? $module : $this->module);
     foreach ($this->loader->getIndexedClasses() as $class => $file) {
         try {
             self::getClassReflection($class);
         } catch (InvalidStateException $e) {
             continue;
         }
         $methods = $this->getClassMethods($class);
         $routeData = $this->parseClassRoutes($methods);
         $this->addRoutes($routeList, $routeData, $class);
     }
     return $routeList;
 }
 /** @return string[] */
 private function findPresenters()
 {
     $config = $this->getConfig();
     $classes = array();
     if ($config['scanDirs']) {
         $robot = new Nette\Loaders\RobotLoader();
         $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage());
         $robot->addDirectory($config['scanDirs']);
         $robot->acceptFiles = '*' . $config['scanFilter'] . '*.php';
         $robot->rebuild();
         $classes = array_keys($robot->getIndexedClasses());
     }
     if ($config['scanComposer']) {
         $rc = new \ReflectionClass('Composer\\Autoload\\ClassLoader');
         $classFile = dirname($rc->getFileName()) . '/autoload_classmap.php';
         if (is_file($classFile)) {
             $this->getContainerBuilder()->addDependency($classFile);
             $classes = array_merge($classes, array_keys(call_user_func(function ($path) {
                 return require $path;
             }, $classFile)));
         }
     }
     $presenters = array();
     foreach (array_unique($classes) as $class) {
         if (strpos($class, $config['scanFilter']) !== FALSE && class_exists($class) && ($rc = new \ReflectionClass($class)) && $rc->implementsInterface('Nette\\Application\\IPresenter') && !$rc->isAbstract()) {
             $presenters[] = $rc->getName();
         }
     }
     return $presenters;
 }
Exemplo n.º 3
0
 private function findRepositories($config)
 {
     $classes = [];
     if ($config['scanDirs']) {
         $robot = new RobotLoader();
         $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage());
         $robot->addDirectory($config['scanDirs']);
         $robot->acceptFiles = '*.php';
         $robot->rebuild();
         $classes = array_keys($robot->getIndexedClasses());
     }
     $repositories = [];
     foreach (array_unique($classes) as $class) {
         if (class_exists($class) && ($rc = new \ReflectionClass($class)) && $rc->isSubclassOf('Joseki\\LeanMapper\\Repository') && !$rc->isAbstract()) {
             $repositoryClass = $rc->getName();
             $entityClass = Strings::endsWith($repositoryClass, 'Repository') ? substr($repositoryClass, 0, strlen($repositoryClass) - 10) : $repositoryClass;
             $table = Utils::camelToUnderscore(Utils::trimNamespace($entityClass));
             if (array_key_exists($table, $repositories)) {
                 throw new \Exception(sprintf('Multiple repositories for table %s found.', $table));
             }
             $repositories[$table] = $repositoryClass;
         }
     }
     return $repositories;
 }
 /** @return string[] */
 private function findPresenters()
 {
     $config = $this->getConfig();
     $classes = [];
     if ($config['scanDirs']) {
         if (!class_exists(Nette\Loaders\RobotLoader::class)) {
             throw new Nette\NotSupportedException("RobotLoader is required to find presenters, install package `nette/robot-loader` or disable option {$this->prefix('scanDirs')}: false");
         }
         $robot = new Nette\Loaders\RobotLoader();
         $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage());
         $robot->addDirectory($config['scanDirs']);
         $robot->acceptFiles = '*' . $config['scanFilter'] . '*.php';
         $robot->rebuild();
         $classes = array_keys($robot->getIndexedClasses());
         $this->getContainerBuilder()->addDependency($this->tempFile);
     }
     if ($config['scanComposer']) {
         $rc = new \ReflectionClass('Composer\\Autoload\\ClassLoader');
         $classFile = dirname($rc->getFileName()) . '/autoload_classmap.php';
         if (is_file($classFile)) {
             $this->getContainerBuilder()->addDependency($classFile);
             $classes = array_merge($classes, array_keys(call_user_func(function ($path) {
                 return require $path;
             }, $classFile)));
         }
     }
     $presenters = [];
     foreach (array_unique($classes) as $class) {
         if (strpos($class, $config['scanFilter']) !== FALSE && class_exists($class) && ($rc = new \ReflectionClass($class)) && $rc->implementsInterface(Nette\Application\IPresenter::class) && !$rc->isAbstract()) {
             $presenters[] = $rc->getName();
         }
     }
     return $presenters;
 }
Exemplo n.º 5
0
 public function getIndexedClasses()
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     return parent::getIndexedClasses();
 }
Exemplo n.º 6
0
 protected function getFiles($directory)
 {
     $robot = new RobotLoader();
     $robot->addDirectory($directory);
     $robot->setCacheStorage(new MemoryStorage());
     $robot->rebuild();
     $indexed = array_keys($robot->getIndexedClasses());
     return $indexed;
 }
 private function loadDefinitions(ContainerBuilder $builder)
 {
     $classes = $this->robotLoader->getIndexedClasses();
     $markerInterface = new ClassType(IServiceMarker::class);
     foreach ($classes as $key => $val) {
         if (Strings::endsWith($key, 'Service')) {
             $reflection = new ClassType($key);
             $serviceName = '_auto.' . str_replace("\\", "_", $key);
             if (!$reflection->isAbstract() && $reflection->isSubclassOf($markerInterface)) {
                 $builder->addDefinition($serviceName)->setClass($key);
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Find all sitemap classes
  *
  * @return string[] Class names
  */
 public function findClasses()
 {
     // find all classes
     $robot = new RobotLoader();
     foreach ($this->dirs as $dir) {
         if (!is_dir($dir)) {
             continue;
         }
         $robot->addDirectory($dir);
     }
     $robot->setCacheStorage(new \Nette\Caching\Storages\DevNullStorage());
     $robot->rebuild();
     $classes = array_keys($robot->getIndexedClasses());
     return $classes;
 }
Exemplo n.º 9
0
 private function findRepositories($config)
 {
     $classes = [];
     if ($config['scanDirs']) {
         $robot = new RobotLoader();
         $robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage());
         $robot->addDirectory($config['scanDirs']);
         $robot->acceptFiles = '*.php';
         $robot->rebuild();
         $classes = array_keys($robot->getIndexedClasses());
     }
     $repositories = [];
     foreach (array_unique($classes) as $class) {
         if (class_exists($class) && ($rc = new \ReflectionClass($class)) && $rc->isSubclassOf('LeanMapper\\Repository') && !$rc->isAbstract()) {
             $repositories[] = $rc->getName();
         }
     }
     return $repositories;
 }
 public function loadConfiguration()
 {
     $config = $this->_getConfig();
     $builder = $this->getContainerBuilder();
     foreach ($config['dirs'] as $namespace => $dir) {
         if (is_dir($dir)) {
             foreach (Finder::findFiles('*.php')->in($dir) as $key => $file) {
                 $class = $file->getBasename('.php');
                 $refletion = new \ReflectionClass("{$namespace}\\{$class}");
                 if (in_array($refletion->getName(), $config['skip'])) {
                     continue;
                 }
                 if ($refletion->isInstantiable()) {
                     $builder->addDefinition($class)->setClass($refletion->getName());
                 }
             }
         }
     }
     if (!empty($config['interfaces'])) {
         $interfaces = array_keys($config['interfaces']);
         $loader = new Nette\Loaders\RobotLoader();
         $loader->setCacheStorage($config['cache']);
         foreach ($config['interfaces'] as $dir) {
             if (is_dir($dir)) {
                 $loader->addDirectory($dir);
             }
         }
         $loader->register();
         foreach ($loader->getIndexedClasses() as $class => $file) {
             if (empty(array_intersect(class_implements($class), $interfaces))) {
                 continue;
             }
             $refletion = new \ReflectionClass($class);
             if ($refletion->isInstantiable()) {
                 $builder->addDefinition($class)->setClass($class);
             }
         }
     }
 }
Exemplo n.º 11
0
 /**
  * @return array of class => filename
  */
 public function getClasses()
 {
     $loader = new Nette\Loaders\RobotLoader();
     $loader->setCacheStorage(new Nette\Caching\Storages\FileStorage($this->defaults['tempDir']));
     $loader->addDirectory($this->defaults["appDir"]);
     $loader->register();
     return $loader->getIndexedClasses();
 }
Exemplo n.º 12
0
 public function handleInstall()
 {
     if ($this->connectionCheckerFactory->invoke() && count($this->getEntityManager()->getConnection()->getSchemaManager()->listTables()) == 0) {
         if ($this->backup) {
             $this->deploymentManager->loadBackup($this->backup);
         } else {
             /** @var $em \Doctrine\ORM\EntityManager */
             $em = $this->getEntityManager();
             $tool = new SchemaTool($em);
             $robotLoader = new RobotLoader();
             $robotLoader->setCacheStorage(new MemoryStorage());
             $robotLoader->addDirectory($this->context->parameters['modules']['cms']['path'] . '/CmsModule');
             $robotLoader->register();
             $classes = array();
             foreach ($robotLoader->getIndexedClasses() as $item => $a) {
                 $ref = ClassType::from($item);
                 if ($ref->hasAnnotation('ORM\\Entity')) {
                     $classes[] = $em->getClassMetadata('\\' . $item);
                 }
             }
             $tool->createSchema($classes);
             /** @var $installer CmsInstaller */
             $installer = $this->context->createInstance('CmsModule\\Module\\Installers\\CmsInstaller');
             $installer->install($this->context->venne->moduleManager->modules['cms']);
         }
     }
     $this->redirect('Installation:', array('backup' => NULL));
 }