Exemple #1
0
 /**
  * warm application
  * @param Application $application
  * @return mixed
  */
 public function warm(Application $application)
 {
     $cache = $application->getCache();
     foreach ($this->getAvailableNamespaces() as $namespace) {
         $this->getClasses($namespace);
     }
     $cache->set(get_class($this), $this->cache);
 }
Exemple #2
0
 /**
  * warm application
  * @param Application $application
  * @return mixed
  */
 public function warm(Application $application)
 {
     // define available classes
     $coreSource = dirname(__DIR__);
     $buildSource = $application->getProject()->getPath('build php');
     $source = $application->getProject()->getPath('src php');
     $path = array($coreSource, $source);
     if (is_dir($buildSource)) {
         $path[] = $buildSource;
     }
     $finder = new Finder();
     $finder->in($path)->files();
     $inspector = $application->getManager()->getInspector();
     // warm inspector
     foreach ($finder as $file) {
         $path = $file->getPath();
         if (strpos($path, $coreSource) === 0) {
             $namespace = 'Cti\\Core' . substr($path, strlen($coreSource));
         } elseif (strpos($path, $buildSource) === 0) {
             $namespace = substr($path, strlen($buildSource) + 1);
         } elseif (strpos($path, $source) === 0) {
             $namespace = substr($path, strlen($source) + 1);
         }
         $class = str_replace(DIRECTORY_SEPARATOR, '\\', $namespace) . '\\' . $file->getBasename('.php');
         if (!class_exists($class)) {
             continue;
         }
         $inspector->getPublicMethods($class);
         $inspector->getClassInjection($class);
         $inspector->getClassProperties($class);
         foreach (Reflection::getReflectionClass($class)->getMethods() as $method) {
             if ($method->getDeclaringClass()->getName() == $class) {
                 $inspector->getMethodArguments($class, $method->getName());
                 $inspector->getMethodRequiredCount($class, $method->getName());
             }
         }
     }
     $application->getCache()->set(__CLASS__, $this->get('Cti\\Di\\Cache')->getData());
 }