Skip to content

Commit

Permalink
comments for Plugins class, related to #476
Browse files Browse the repository at this point in the history
  • Loading branch information
henriyli committed Mar 9, 2016
1 parent 1c50c8f commit 388320b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions model/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public function __construct($globalPlugins=array()) {
}

/**
* Returns the plugin configurations found from plugin folders inside the plugins folder
* @return array
*/
private function getPlugins()
Expand All @@ -23,6 +24,12 @@ private function getPlugins()
return $plugins;
}

/**
* Returns the plugin configurations found from plugin folders
* inside the plugins folder filtered by filetype.
* @param string $type filetype e.g. 'css', 'js' or 'template'
* @return array
*/
private function filterPlugins($type) {
$plugins = $this->getPlugins();
$ret = array();
Expand All @@ -39,6 +46,13 @@ private function filterPlugins($type) {
return $ret;
}

/**
* Returns the plugin configurations found from plugin folders
* inside the plugins folder filtered by plugin name (the folder name).
* @param string $type filetype e.g. 'css', 'js' or 'template'
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
private function filterPluginsByName($type, $names) {
$files = $this->filterPlugins($type);
foreach ($files as $plugin => $filelist) {
Expand All @@ -49,6 +63,11 @@ private function filterPluginsByName($type, $names) {
return $files;
}

/**
* Returns an array of javascript filepaths
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsJS($names=null) {
if ($names) {
$names = array_merge($this->globalPlugins, $names);
Expand All @@ -57,6 +76,11 @@ public function getPluginsJS($names=null) {
return $this->filterPluginsByName('js', $this->globalPlugins);
}

/**
* Returns an array of css filepaths
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsCSS($names=null) {
if ($names) {
$names = array_merge($this->globalPlugins, $names);
Expand All @@ -65,6 +89,11 @@ public function getPluginsCSS($names=null) {
return $this->filterPluginsByName('css', $this->globalPlugins);
}

/**
* Returns an array of template filepaths
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getPluginsTemplates($names=null) {
if ($names) {
$names = array_merge($this->globalPlugins, $names);
Expand All @@ -73,6 +102,11 @@ public function getPluginsTemplates($names=null) {
return $this->filterPluginsByName('templates', $this->globalPlugins);
}

/**
* Returns an array of template files contents as strings
* @param array $names the plugin name strings (foldernames) in an array
* @return array
*/
public function getTemplates($names=null) {
$templateStrings = array();
$plugins = $this->getPluginsTemplates($names);
Expand Down

0 comments on commit 388320b

Please sign in to comment.