コード例 #1
0
ファイル: ShortcutsManager.php プロジェクト: bazo/Tatami
 public function __construct(Nette\Loaders\RobotLoader $robotLoader)
 {
     $classes = $robotLoader->getIndexedClasses();
     foreach ($classes as $class => $file) {
         if (class_exists($class)) {
             $reflection = new \Nette\Reflection\ClassType($class);
             if ($reflection->implementsInterface('Tatami\\Modules\\IModule')) {
                 if (!($reflection->isAbstract() or $reflection->isInterface())) {
                     $this->modules[] = $this->parseModuleName($reflection->getShortName());
                 }
             }
             if ($reflection->isSubclassOf('Tatami\\Presenters\\BackendPresenter')) {
                 $moduleName = $this->parseModuleName($reflection->getNamespaceName());
                 $presenterName = $this->parsePresenterName($reflection->getShortName());
                 $this->presenters[$moduleName][] = $presenterName;
                 $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
                 foreach ($methods as $method) {
                     if (Strings::match($method->name, '/action/') or Strings::match($method->name, '/render/')) {
                         $this->actions[$presenterName][] = $this->parseActionName($method->name);
                     }
                 }
             }
             unset($reflection);
         }
     }
 }
コード例 #2
0
ファイル: TestCase.php プロジェクト: konecnyjakub/mytester
 /**
  * Get list of jobs with parameters for current test suit
  * 
  * @return Job[]
  */
 protected function getJobs()
 {
     $jobs = [];
     $r = new \Nette\Reflection\ClassType(get_class($this));
     $methods = array_values(preg_grep(static::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
         return $rm->getName();
     }, $r->getMethods())));
     foreach ($methods as $method) {
         $rm = $r->getMethod($method);
         $data = NULL;
         $job = ["name" => $this->getJobName($rm), "callback" => [$this, $method], "params" => [], "skip" => $this->checkSkip($rm), "shouldFail" => $rm->hasAnnotation("fail")];
         if ($rm->getNumberOfParameters() and $rm->hasAnnotation("data")) {
             $data = (array) $rm->getAnnotation("data");
         }
         if (is_array($data)) {
             foreach ($data as $value) {
                 $job["params"][0] = $value;
                 $jobs[] = new Job($job["name"], $job["callback"], $job["params"], $job["skip"], $job["shouldFail"]);
                 $job["params"] = [];
             }
         } else {
             $jobs[] = new Job($job["name"], $job["callback"], $job["params"], $job["skip"], $job["shouldFail"]);
         }
     }
     return $jobs;
 }
コード例 #3
0
ファイル: CronPresenter.php プロジェクト: f3l1x/nette-plugins
 /**
  * Creates method list
  * (may take a time..)
  *
  * @return array
  */
 public function createMethodList()
 {
     /** @var $robotLoader RobotLoader */
     $robotLoader = $this->context->getService('robotLoader');
     foreach ($robotLoader->getIndexedClasses() as $class => $file) {
         if (Strings::match($file, "~\\Nette~")) {
             continue;
         }
         $creflection = new Nette\Reflection\ClassType($class);
         foreach ($creflection->getMethods() as $method) {
             $mreflection = new Method($class, $method->getName());
             if ($mreflection->hasAnnotation('cron')) {
                 $m = new stdClass();
                 $m->name = $mreflection->getName();
                 $m->class = $mreflection->getDeclaringClass()->getName();
                 $m->annotations = $mreflection->getAnnotations();
                 $this->methods[] = $m;
             }
         }
     }
     return $this->methods;
 }