Exemplo n.º 1
0
Arquivo: Xml.php Projeto: im286er/Ding
 /**
  * Returns an aspect definition.
  *
  * @param SimpleXML $simpleXmlAspect Aspect node.
  *
  * @throws BeanFactoryException
  * @return AspectDefinition
  */
 private function _loadAspect($simpleXmlAspect)
 {
     $aspects = array();
     $atts = $simpleXmlAspect->attributes();
     if (isset($atts->id)) {
         $name = (string) $atts->id;
     } else {
         $name = BeanDefinition::generateName('AspectXML');
     }
     if (isset($atts->expression)) {
         $expression = (string) $atts->expression;
     } else {
         $expression = '';
     }
     $aspectBean = (string) $atts->ref;
     $type = (string) $atts->type;
     if ($type == 'method') {
         $type = AspectDefinition::ASPECT_METHOD;
     } else {
         if ($type == 'exception') {
             $type = AspectDefinition::ASPECT_EXCEPTION;
         } else {
             throw new BeanFactoryException('Invalid aspect type');
         }
     }
     $pointcuts = array();
     foreach ($simpleXmlAspect->pointcut as $pointcut) {
         $pointcutAtts = $pointcut->attributes();
         if (isset($pointcutAtts->id)) {
             $pointcutName = (string) $pointcutAtts->id;
         } else {
             $pointcutName = BeanDefinition::generateName('PointcutXML');
         }
         if (isset($pointcutAtts->expression)) {
             $pointcut = clone $this->_templatePointcutDef;
             $pointcut->setName($pointcutName);
             $pointcut->setExpression((string) $pointcutAtts->expression);
             $pointcut->setMethod((string) $pointcutAtts->method);
             $this->_aspectManager->setPointcut($pointcut);
             $pointcuts[] = $pointcutName;
         } else {
             if (isset($pointcutAtts->{'pointcut-ref'})) {
                 $pointcuts[] = (string) $pointcutAtts->{'pointcut-ref'};
             }
         }
     }
     $aspect = new AspectDefinition($name, $pointcuts, $type, $aspectBean, $expression);
     return $aspect;
 }
Exemplo n.º 2
0
 /**
  * Returns an aspect definition.
  *
  * @param mixed[] $aspect Aspect data.
  *
  * @throws BeanFactoryException
  * @return AspectDefinition
  */
 private function _loadAspect($aspect)
 {
     $aspects = array();
     if (isset($aspect['id'])) {
         $name = $aspect['id'];
     } else {
         $name = BeanDefinition::generateName('AspectYAML');
     }
     if (isset($aspect['expression'])) {
         $expression = $aspect['expression'];
     } else {
         $expression = '';
     }
     $aspectBean = $aspect['ref'];
     $type = $aspect['type'];
     if ($type == 'method') {
         $type = AspectDefinition::ASPECT_METHOD;
     } else {
         if ($type == 'exception') {
             $type = AspectDefinition::ASPECT_EXCEPTION;
         } else {
             throw new BeanFactoryException('Invalid aspect type');
         }
     }
     $pointcuts = array();
     foreach ($aspect['pointcuts'] as $pointcut) {
         if (isset($pointcut['id'])) {
             $pointcutName = $pointcut['id'];
         } else {
             $pointcutName = BeanDefinition::generateName('PointcutYAML');
         }
         if (isset($pointcut['expression'])) {
             $pointcutDef = clone $this->_templatePointcutDef;
             $pointcutDef->setName($pointcutName);
             $pointcutDef->setExpression($pointcut['expression']);
             $pointcutDef->setMethod($pointcut['method']);
             $this->_aspectManager->setPointcut($pointcutDef);
             $pointcuts[] = $pointcutName;
         } else {
             if (isset($pointcut['pointcut-ref'])) {
                 $pointcuts[] = $pointcut['pointcut-ref'];
             }
         }
     }
     return new AspectDefinition($name, $pointcuts, $type, $aspectBean, $expression);
 }