Ejemplo n.º 1
0
 /**
  * Register a path template
  *
  * If the template path has format com:foo/path/to/file this method will replace com:foo with the
  * base path of the component. If the component has additional paths a template path for each will
  * be added in FIFO order.
  *
  * @param  string $template   The path template
  * @param  bool $prepend      If true, the template will be prepended instead of appended.
  * @return FilesystemLocatorAbstract
  */
 public function registerPathTemplate($template, $prepend = false)
 {
     if (parse_url($template, PHP_URL_SCHEME) === 'com') {
         $bootstrapper = $this->getObject('object.bootstrapper');
         $info = $this->parseUrl($template);
         $package = $info['package'];
         $domain = $info['domain'];
         //Remove component identifier from the template
         $identifier = $bootstrapper->getComponentIdentifier($package, $domain);
         $template = ltrim(str_replace($identifier, '', $template), '/');
         $paths = $bootstrapper->getComponentPaths($package, $domain);
         foreach ($paths as $path) {
             $path = $path . '/' . $template;
             parent::registerPathTemplate($path, $prepend);
         }
     } else {
         parent::registerPathTemplate($template, $prepend);
     }
     return $this;
 }