Example #1
0
 /**
  * {@inheritDoc}
  */
 public function isAllowed()
 {
     if (!parent::isAllowed()) {
         return false;
     }
     $allowed = array_keys($this->allowedNodeClasses, true);
     $mandatory = array_keys($this->mandatoryNodeClasses, true);
     $it = new \RecursiveIteratorIterator(new RecursiveNodeIterator($this), \RecursiveIteratorIterator::SELF_FIRST);
     $achived = array();
     foreach ($it as $node) {
         if ($node === $this) {
             continue;
         }
         $isAllowed = false;
         foreach ($allowed as $classname) {
             if ($node instanceof $classname) {
                 $isAllowed = true;
                 break;
             }
         }
         if (!$isAllowed) {
             throw new NotAllowedException($node, $this);
         }
         foreach ($mandatory as $classname) {
             if ($node instanceof $classname) {
                 $achived[$classname] = $classname;
                 break;
             }
         }
         if (count($achived) == count($mandatory)) {
             return true;
         }
     }
     throw new NotMetException($this, $mandatory, $achived);
 }
Example #2
0
 public function compile()
 {
     $this->root->compile($this);
 }