/**
  * @param string $namespace_prefix
  * @param string $namespace_url
  * @param string $component_name
  * @param ComponentsProviderInterface $components
  * @param int $code
  * @param Exception $previous
  */
 public function __construct($namespace_prefix, $namespace_url, $component_name, ComponentsProviderInterface $components, $code = 0, Exception $previous = null)
 {
     $known_components = $components->getNamespace($namespace_url)->getComponents();
     $known_components = implode(', ', array_map(function (ComponentDefinition $d) use($namespace_prefix) {
         return "<{$namespace_prefix}:{$d->getName()}>";
     }, $known_components));
     parent::__construct("Component not found in a registered namespace: <{$namespace_prefix}:{$component_name}>.\n" . "Known components in '{$namespace_url}' namespace: " . $known_components, $code, $previous);
 }
 /**
  * @param ComponentsProviderInterface $components
  * @return array [ $path => $contents ]
  */
 public function buildSchemas(ComponentsProviderInterface $components)
 {
     $schemas = [];
     foreach ($components->getNamespaces() as $namespace) {
         $url = parse_url($namespace->getUri());
         $path = $url['host'] . $url['path'];
         if (substr($path, -1) == '/') {
             $path .= 'schema.xsd';
         } else {
             $path .= '.xsd';
         }
         $schemas[$path] = $this->buildNamespaceSchema($namespace);
     }
     return $schemas;
 }
Exemplo n.º 3
0
 /**
  * Checks if tag token is component and returns it's spec
  *
  * @param $token
  * @return array|bool [ $namespace_prefix, $namespace_url, $tag_name ] for valid components and false for non-component tokens
  *
  * @throws ParseException
  */
 protected function getComponentTagSpec($token)
 {
     if ($this->isNamespacedTag($token)) {
         list($prefix, $tag_name) = $this->parseNamespacedTagName($token);
         $stack_namespaces = $this->getStackNamespaceDeclarations();
         $tag_namespaces = $this->getNamespaceDeclarations($token);
         if (isset($tag_namespaces[$prefix]) || isset($stack_namespaces[$prefix])) {
             $namespace_url = isset($tag_namespaces[$prefix]) ? $tag_namespaces[$prefix] : $stack_namespaces[$prefix];
             if ($this->components->hasComponent($namespace_url, $tag_name)) {
                 return [$prefix, $namespace_url, $tag_name];
             } else {
                 throw new UnknownComponentException($prefix, $namespace_url, $tag_name, $this->components);
             }
         } else {
             trigger_error("No namespace declaration found for prefix: {$prefix}.", E_USER_NOTICE);
         }
     }
     return false;
 }