Exemple #1
0
 /**
  * Find a resource.
  * @param string $resource Resource name.
  * @throws ResourceTypeException If unknown type of resource.
  * @return array Description of resource and dependencies.
  */
 private function find($resource)
 {
     if (isset($this->providers[$resource])) {
         return $this->providers[$resource];
     }
     $type = Utilities::getFileExtension($resource);
     switch ($type) {
         case 'js':
             $type = 'script';
             $location = $this->assets->getAsset('js/' . $resource);
             break;
         case 'css':
             $type = 'style';
             $location = $this->assets->getAsset('css/' . $resource);
             break;
         default:
             throw new ResourceTypeException(tr('Unknown type of resource: "%1"', $type));
     }
     if (!isset($location)) {
         $location = 'resource-is-missing/' . $resource;
     }
     return array('location' => $location, 'type' => $type, 'dependencies' => array(), 'condition' => null);
 }
Exemple #2
0
 /**
  * Find layout template for a template.
  * @param string $template Template name.
  * @return string|null Name of layout template or null if not found.
  */
 public function findLayout($template)
 {
     if (Utilities::isAbsolutePath($template)) {
         return null;
     }
     $extension = Utilities::getFileExtension($template);
     $dir = $template;
     do {
         $dir = dirname($dir);
         if ($dir === '.') {
             $template = 'layout.' . $extension;
         } else {
             $template = $dir . '/layout.' . $extension;
         }
         $file = $this->findTemplate($template);
         if (isset($file)) {
             return $template;
         }
     } while ($dir != '.');
     return null;
 }