Module: Allow to define additional CSS/LESS files

refs #9702
This commit is contained in:
Johannes Meyer 2015-08-06 15:10:33 +02:00
parent 59ef54314a
commit 51aa22d429
1 changed files with 38 additions and 1 deletions

View File

@ -162,6 +162,13 @@ class Module
*/
private $app;
/**
* The CSS/LESS files this module provides
*
* @var array
*/
protected $cssFiles = array();
/**
* Routes to add to the route chain
*
@ -388,6 +395,19 @@ class Module
return $manager->getModule($name);
}
/**
* Provide an additional CSS/LESS file
*
* @param string $path The path to the file, relative to self::$cssdir
*
* @return $this
*/
protected function provideCssFile($path)
{
$this->cssFiles[] = $this->cssdir . DIRECTORY_SEPARATOR . $path;
return $this;
}
/**
* Test if module provides css
*
@ -395,7 +415,12 @@ class Module
*/
public function hasCss()
{
return file_exists($this->getCssFilename());
if (file_exists($this->getCssFilename())) {
return true;
}
$this->launchConfigScript();
return !empty($this->cssFiles);
}
/**
@ -408,6 +433,18 @@ class Module
return $this->cssdir . '/module.less';
}
/**
* Return the CSS/LESS files this module provides
*
* @return array
*/
public function getCssFiles()
{
$files = $this->cssFiles;
$files[] = $this->getCssFilename();
return $files;
}
/**
* Test if module provides js
*