Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function isAllowed(NodeInterface $from, NodeInterface $to)
 {
     foreach ($this->getTargets() as $namespace) {
         if ($this->namespaceContains($namespace, $to->getFQName())) {
             return EvaluationResult::allowed($this);
         }
     }
     return EvaluationResult::undefined();
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function isAllowed(NodeInterface $from, NodeInterface $to)
 {
     foreach ($this->getTargets() as $namespace) {
         if ($this->namespaceContains($namespace, $to->getFQName())) {
             return EvaluationResult::denied($this, sprintf("%s has an attached DenyPolicy of namespace %s, preventing use of %s", $from->getFQName(), $namespace, $to->getFQName()));
         }
     }
     return EvaluationResult::undefined();
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function affects(NodeInterface $from, NodeInterface $to)
 {
     foreach ($this->getTargets() as $namespace) {
         if ($this->namespaceContains($namespace, $to->getFQName())) {
             return true;
         }
     }
     return false;
 }
Пример #4
0
 private function parentNamespace(NodeInterface $node)
 {
     $fqcn = $node->getFQName();
     $lastNsSep = strpos($fqcn, '\\');
     if (false === $lastNsSep) {
         // no namespace
         return "";
     } else {
         return substr($fqcn, 0, $lastNsSep);
     }
 }
Пример #5
0
 private function regexMatchesNode($regex, NodeInterface $node)
 {
     return (bool) preg_match("/{$regex}/i", $node->getFQName());
 }
Пример #6
0
 /**
  * Adds a child to the current node.
  *
  * @param NodeInterface $child
  */
 public function addChild(NodeInterface $child)
 {
     $this->children[$child->getName()] = $child;
 }