private function setPageAssets(Template $template, &$pageData)
 {
     $excludes = $this->getExcludes();
     $jsAssets = $template->getAssets('js', $excludes);
     $cssAssets = $template->getAssets('css', $excludes);
     $paths = $this->getAssetsPath();
     if (count($paths)) {
         foreach ($paths as $path) {
             if (strpos($path, 'css') > -1) {
                 $cssAssets = array_merge($cssAssets, $this->searchAssets($path, 'css', $excludes));
                 sort($cssAssets);
             } else {
                 if (strpos($path, 'js') > -1) {
                     $jsAssets = array_merge($jsAssets, $this->searchAssets($path, 'js', $excludes));
                     sort($jsAssets);
                 }
             }
         }
     }
     if (is_array($pageData) && $pageData['pagina']) {
         $pageData['pagina']['scripts'] = $this->setPublicRelativePath($jsAssets);
         $pageData['pagina']['stylesheets'] = $this->setPublicRelativePath($cssAssets);
     }
     return '';
 }
 /**
  * Generates the collection of the template assets by iterating over the assets
  * in the template directory and adds it to the Resolver
  *
  * @param string $alias
  */
 public function loadTemplateCollection($alias)
 {
     $templateName = $this->matchTemplateName($alias);
     if ($templateName !== false) {
         $path = $this->getExistantTemplatePath($templateName);
         if ($path !== null) {
             $template = new Template();
             $template->setName($templateName);
             $template->setPath($path);
             $extension = pathinfo($alias, PATHINFO_EXTENSION);
             $files = $template->getAssets($extension);
             $this->addToCollections($alias, $files);
         }
     }
 }
Example #3
0
 /**
  * @covers Columnis\Model\Template::getDefinedAssets
  * @covers Columnis\Model\Template::searchAssets
  */
 public function testGetAssets()
 {
     $template = new Template();
     $path = $this->getExampleTemplatePath();
     $template->setPath($path);
     $name = 'example-template';
     $template->setName($name);
     $extensions = array('css', 'js');
     $extension = $extensions[array_rand($extensions)];
     $searchAssets = array('css' => array(realpath($path . DIRECTORY_SEPARATOR . 'css/example.css'), realpath($path . DIRECTORY_SEPARATOR . 'css/example2.css')), 'js' => array(realpath($path . DIRECTORY_SEPARATOR . 'js/example.js')));
     $definedAssets = array('css' => array(realpath(Bootstrap::getTestFilesDir() . 'public.dist/css/jquery-ui.css')), 'js' => array(realpath(Bootstrap::getTestFilesDir() . 'public.dist/js/jquery-1.8.2.min.js')));
     $expectedDefinedAssets = $definedAssets[$extension];
     $expectedSearchAssets = $searchAssets[$extension];
     sort($expectedSearchAssets);
     $expectedAssets = array_merge($expectedDefinedAssets, $expectedSearchAssets);
     $this->assertEquals($expectedAssets, $template->getAssets($extension));
 }