protected function setTemplatePath($path)
{
// Clear out the prior search dirs
$this->templatePaths = array();
// Actually add the user-specified directories
$this->addTemplatePath($path);
// Set the alternative template search dir
$templatePath = JPATH_THEMES;
$fallback = $templatePath . '/' . $this->container->platform->getTemplate() . '/html/' . $this->container->componentName . '/' . $this->name;
$this->addTemplatePath($fallback);
// Get extra directories through event dispatchers
$extraPathsResults = $this->container->platform->runPlugins('onGetViewTemplatePaths', array($this->container->componentName, $this->getName()));
if (is_array($extraPathsResults) && !empty($extraPathsResults)) {
foreach ($extraPathsResults as $somePaths) {
if (!empty($somePaths)) {
foreach ($somePaths as $aPath) {
$this->addTemplatePath($aPath);
}
}
}
}
}