예제 #1
0
 public static function findPointCut($mode, $class, $method, $args = null)
 {
     if ($mode == "around" and !isset(Aspect::$pointCuts[$mode][$method])) {
         throw new AOPNoAdviceException();
     }
     if ($mode == "after" and !isset(self::$pointCuts[$mode][$method])) {
         return $args;
     }
     if (isset($_SESSION[self::$sessionVariable]) and count($_SESSION[self::$sessionVariable]) > 0) {
         foreach ($_SESSION[self::$sessionVariable] as $PA) {
             self::registerPointCut($PA[0], $PA[1], $PA[2]);
         }
     }
     if (isset(Aspect::$pointCuts[$mode][$method]) and count(Aspect::$pointCuts[$mode][$method]) > 0) {
         $values = array();
         foreach (Aspect::$pointCuts[$mode][$method] as $k => $advice) {
             $values[] = Aspect::invokeParser($advice, $class, $args);
             if (isset(Aspect::$onetimePointCuts[$mode . "_" . $method])) {
                 unset(Aspect::$onetimePointCuts[$mode . "_" . $method]);
                 unset(Aspect::$pointCuts[$mode][$method][$k]);
             }
         }
         if (count($values) > 1 and $mode != "after") {
             return $values;
         }
         return $values[0];
     }
     return null;
 }