/** * Test LESS add/remove. * * @return void */ public function testLess() { $container = new ResourceContainer(); $container->addCss(['c', 'd.css']); $container->addLessCss(['active' => true, 'a', 'b', 'c']); $container->addLessCss('c'); $container->addLessCss('d'); $this->assertEquals([], array_diff(['a', 'b', 'c', 'd'], $container->getLessCss())); $this->assertEquals(['c'], $container->getCss()); }
/** * Add links to header. * * @return void */ protected function addLinks() { // Convenient shortcut to view helper: $headLink = $this->getView()->plugin('headlink'); // Load CSS (make sure we prepend them in the appropriate order; theme // resources should load before extras added by individual templates): foreach (array_reverse($this->container->getCss()) as $current) { $parts = $this->parseSetting($current); $headLink()->prependStylesheet(trim($parts[0]), isset($parts[1]) ? trim($parts[1]) : 'all', isset($parts[2]) ? trim($parts[2]) : false); } // Compile and load LESS (make sure we prepend them in the appropriate order // theme resources should load before extras added by individual templates): foreach (array_reverse($this->container->getLessCss()) as $current) { $parts = $this->parseSetting($current); $headLink()->prependStylesheet($headLink()->addLessStylesheet(trim($parts[0])), isset($parts[1]) ? trim($parts[1]) : 'all', isset($parts[2]) ? trim($parts[2]) : false); } // If we have a favicon, load it now: $favicon = $this->container->getFavicon(); if (!empty($favicon)) { $imageLink = $this->getView()->plugin('imagelink'); $headLink(['href' => $imageLink($favicon), 'type' => 'image/x-icon', 'rel' => 'shortcut icon']); } }