Fixes #4075: Added CClientScript::hasPackage()

This commit is contained in:
Alexander Makarov
2017-03-24 00:13:36 +03:00
committed by GitHub
parent 9b14ff3e3f
commit 6771558d0c
3 changed files with 30 additions and 0 deletions

View File

@@ -550,6 +550,29 @@ class CClientScript extends CApplicationComponent
return $this->coreScripts[$name]['baseUrl']=$baseUrl;
}
/**
* Checks if package is available.
* @param string $name the name of the script package.
* @return bool
* @since 1.1.18
* @see registerPackage
*/
public function hasPackage($name)
{
if(isset($this->coreScripts[$name]))
return true;
if(isset($this->packages[$name]))
return true;
else
{
if($this->corePackages===null)
$this->corePackages=require(YII_PATH.'/web/js/packages.php');
if(isset($this->corePackages[$name]))
return true;
}
return false;
}
/**
* Registers a script package that is listed in {@link packages}.
* This method is the same as {@link registerCoreScript}.