예제 #1
0
 /**
  * Checks if group from path is declared in manifest.
  * Manifest is valid if path ends with: configuration/website/[group],
  * where group is declared in manifest.
  * 
  * @param \DOMDocument $xml
  * @param Path $path
  * @return bool
  */
 public function isValidForPath(\DOMDocument $xml, Path $path)
 {
     $allowedGroups = [];
     $groupsNode = $xml->getElementsByTagName('allowed_groups');
     if (!$groupsNode->length) {
         return false;
     }
     // get all allowed group for manifest
     foreach ($groupsNode->item(0)->childNodes as $group) {
         if ($group->nodeName === 'group') {
             $allowedGroups[] = (string) $group->textContent;
         }
     }
     $search = $path->getDirectory() . '/' . $path->getGroup();
     $pattern = "#{$search}[/]?\$#";
     // skip if group is invalid (allowed groups from manifest)
     // or if config do not ends with configuration/[website]/[group]
     if (!in_array($path->getGroup(), $allowedGroups) || 1 !== preg_match($pattern, $path->getParamPath(), $matches)) {
         return false;
     }
     return true;
 }
예제 #2
0
 /**
  * @covers ::getParamPath
  */
 public function test_getParamPath_should_return_value_passed_to_constructor()
 {
     $paramPath = 'configuration/param/path/';
     $path = new Path($paramPath, 'whatever', 'rootdir');
     $this->assertEquals($paramPath, $path->getParamPath());
 }