コード例 #1
0
ファイル: Weaver.php プロジェクト: reoring/sabel
 private function _build($adviceClass)
 {
     $this->advice = $advice = new $adviceClass();
     if (isset(self::$reflectionCache[$adviceClass])) {
         $reflection = self::$reflectionCache[$adviceClass];
     } else {
         $reflection = new Sabel_Reflection_Class($advice);
         self::$reflectionCache[$adviceClass] = $reflection;
     }
     $annotatedAdvisor = $reflection->getAnnotation("advisor");
     if ($annotatedAdvisor !== null) {
         $this->advisorClass = $annotatedAdvisor[0][0];
     }
     $annotatedInterceptor = $reflection->getAnnotation("interceptor");
     if ($annotatedInterceptor !== null) {
         $this->interceptorClass = $annotatedInterceptor[0][0];
     }
     $annotatedClass = $reflection->getAnnotation("classMatch");
     if ($annotatedClass !== null) {
         $this->annotatedClass = $annotatedClass[0][0];
     }
     foreach ($reflection->getMethods() as $method) {
         $this->addToAdvisor($method, $advice);
     }
 }
コード例 #2
0
 public function build($weaverClass, $targetClass, $adviceClasses)
 {
     $this->weaver = new $weaverClass($targetClass);
     if (!is_array($adviceClasses)) {
         $adviceClasses = array($adviceClasses);
     }
     $adviceClasses = array_reverse($adviceClasses);
     foreach ($adviceClasses as $adviceClass) {
         $advice = new $adviceClass();
         $this->advice = $advice;
         $reflection = new Sabel_Reflection_Class($advice);
         $annotatedAdvisor = $reflection->getAnnotation("advisor");
         if ($annotatedAdvisor !== null) {
             $this->advisorClass = $annotatedAdvisor[0][0];
         }
         $annotatedInterceptor = $reflection->getAnnotation("interceptor");
         if ($annotatedInterceptor !== null) {
             $this->interceptorClass = $annotatedInterceptor[0][0];
         }
         $annotatedClass = $reflection->getAnnotation("classMatch");
         if ($annotatedClass !== null) {
             $this->annotatedClass = $annotatedClass[0][0];
         }
         foreach ($reflection->getMethods() as $method) {
             $this->addToAdvisor($method);
         }
     }
     return $this->weaver;
 }
コード例 #3
0
ファイル: TestSuite.php プロジェクト: hamaco/phwittr-on-xoops
 protected function doFixture($method)
 {
     $name = $this->name === "" ? get_class($this) : $this->name;
     $fixtureDir = RUN_BASE . DS . "tests" . DS . "fixture";
     $reflection = new Sabel_Reflection_Class($name);
     $annotation = $reflection->getAnnotation("fixture");
     if (isset($annotation[0])) {
         if ($method === "downFixture") {
             $annotation[0] = array_reverse($annotation[0]);
         }
         try {
             foreach ($annotation[0] as $fixtureName) {
                 Sabel::fileUsing($fixtureDir . DS . $this->getFixturePath($fixtureName), true);
                 $className = "Fixture_" . $fixtureName;
                 $fixture = new $className();
                 $fixture->{$method}();
             }
         } catch (Exception $e) {
             if ($reflection->hasMethod($method . "Exception")) {
                 $reflection->getMethod($method . "Exception")->invoke(null, $e);
             } else {
                 throw $e;
             }
         }
     }
 }