コード例 #1
0
ファイル: Aspect.php プロジェクト: JeCat/framework
 public static function createFromToken(ClassDefine $aClassToken, $sAspectFilepath = null)
 {
     $sAspectName = $aClassToken->fullName();
     $aTokenPool = $aClassToken->parent();
     $aAspect = new self($sAspectName);
     // 先定义 pointcut
     foreach ($aTokenPool->functionIterator($sAspectName) as $aMethodToken) {
         if (!($aDocCommentToken = $aMethodToken->docToken()) or !($aDocComment = $aDocCommentToken->docComment())) {
             continue;
         }
         // pointcut
         if ($aDocComment->hasItem('pointcut')) {
             $aPointcut = Pointcut::createFromToken($aMethodToken);
             $aAspect->pointcuts()->add($aPointcut);
         }
     }
     // 然后定义 advice
     foreach ($aTokenPool->functionIterator($sAspectName) as $aMethodToken) {
         if (!($aDocCommentToken = $aMethodToken->docToken()) or !($aDocComment = $aDocCommentToken->docComment())) {
             continue;
         }
         if ($aDocComment->hasItem('advice')) {
             $aAdvice = Advice::createFromToken($aMethodToken, $aAspect);
             $aAspect->addAdvice($aAdvice);
         }
     }
     $aAspect->sAspectName = $sAspectName;
     if ($sAspectFilepath) {
         $aAspect->setAspectFilepath(FSO::tidyPath($sAspectFilepath));
     }
     return $aAspect;
 }
コード例 #2
0
ファイル: AOP.php プロジェクト: JeCat/framework
 /**
  * @return AOP 
  */
 public function registerBean(array $arrConfig, $sAspectDefineFile = null)
 {
     if (empty($arrConfig['class'])) {
         $arrConfig['class'] = 'aspect';
     }
     $aAspect = BeanFactory::singleton()->createBean($arrConfig);
     if ($sAspectDefineFile) {
         $aAspect->setAspectFilepath(FSO::tidyPath($sAspectDefineFile));
     }
     $this->aspects()->add($aAspect);
     $this->aPointcutIterator = null;
     $this->aJointPointIterator = null;
     return $this;
 }
コード例 #3
0
ファイル: FsSetting.php プロジェクト: JeCat/framework
 public function serialize()
 {
     return FSO::tidyPath($this->aRootFolder->path());
 }