PluginBase::getResources() returns associative array (#2193)

Now, it has string keys, which is the path of the resource file relative to the resources folder.
This commit is contained in:
SOFe 2018-06-11 18:06:54 +08:00 committed by Dylan K. Taylor
parent b9718f9e87
commit 8704d378d4

View File

@ -226,7 +226,7 @@ abstract class PluginBase implements Plugin{
}
/**
* Returns all the resources packaged with the plugin
* Returns all the resources packaged with the plugin in the form ["path/in/resources" => SplFileInfo]
*
* @return \SplFileInfo[]
*/
@ -235,7 +235,8 @@ abstract class PluginBase implements Plugin{
if(is_dir($this->file . "resources/")){
foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->file . "resources/")) as $resource){
if($resource->isFile()){
$resources[] = $resource;
$path = str_replace(DIRECTORY_SEPARATOR, "/", substr((string) $resource, strlen($this->file . "resources/")));
$resources[$path] = $resource;
}
}
}