本文整理汇总了PHP中Zend_Loader_PluginLoader::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Loader_PluginLoader::load方法的具体用法?PHP Zend_Loader_PluginLoader::load怎么用?PHP Zend_Loader_PluginLoader::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Loader_PluginLoader
的用法示例。
在下文中一共展示了Zend_Loader_PluginLoader::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initPlugins
protected function _initPlugins()
{
$this->bootstrap('frontController');
$pluginsLoader = new Zend_Loader_PluginLoader();
$pluginsLoader->addPrefixPath('Plugin', $this->getResourceLoader()->getBasePath() . '/plugins');
$pluginsLoader->load("LayoutLoader");
$pluginsLoader->load("AclUtils");
if ($pluginsLoader->isLoaded('LayoutLoader')) {
Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_LayoutLoader());
}
}
示例2: _initPlugins
protected function _initPlugins()
{
$this->bootstrap('frontController');
$pluginsLoader = new Zend_Loader_PluginLoader();
$pluginsLoader->addPrefixPath("Plugin", APPLICATION_PATH . '/plugins');
$pluginsLoader->load("Layout");
if ($pluginsLoader->isLoaded("Layout")) {
$front = Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_Layout());
}
$pluginsLoader->load("Acl");
if ($pluginsLoader->isLoaded("Acl")) {
$front = Zend_Controller_Front::getInstance()->registerPlugin(new Plugin_Acl());
}
}
示例3: __construct
/**
* 构造函数
*
* @param string $backend
* @param string $frontend
* @throws ZtChart_Model_Assemble_Exception
*/
public function __construct($backend, $frontend = 'PHPArray')
{
$loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Assemble_Backend_' => realpath(__DIR__ . '/Assemble/Backend'), 'ZtChart_Model_Assemble_Frontend_' => realpath(__DIR__ . '/Assemble/Frontend')));
$backendName = is_array($backend) ? key($backend) : $backend;
if (false === ($backendClass = $loader->load($backendName, false))) {
throw new ZtChart_Model_Assemble_Exception("Specified backend class '{$backendName}' could not be found");
}
$this->_backend = new $backendClass($backend);
$frontendName = is_array($frontend) ? key($frontend) : $frontend;
if (false === ($frontendClass = $loader->load($frontendName, false))) {
throw new ZtChart_Model_Assemble_Exception("Specified frontend class '{$frontendName}' could not be found");
}
$this->_frontend = new $frontendClass($frontend);
}
示例4: _loadAclClasses
/**
* Load ACL classes from Brightfame Framework
*
* @return void
*/
protected function _loadAclClasses()
{
$loader = new Zend_Loader_PluginLoader(array('Brightfame_Acl_Role' => APPLICATION_PATH . '/../library/Brightfame/Acl/Role/'));
foreach (array('Guest', 'Member', 'Administrator') as $role) {
$loader->load($role);
}
}
示例5: loadForm
/**
* Load a form with the provided options.
*
* @param string $name The name of the form to be loaded
* @param array|Zend_Config $options Options to be passed to the form
* constructor.
*
* @return Zend_Form
*/
public function loadForm($name, $options = null)
{
$module = $this->getRequest()->getModuleName();
$front = $this->getFrontController();
$default = $front->getDispatcher()->getDefaultModule();
if (empty($module)) {
$module = $default;
}
$moduleDirectory = $front->getControllerDirectory($module);
$formsDirectory = dirname($moduleDirectory) . '/forms';
$prefix = ('default' == $module ? '' : ucfirst($module) . '_') . 'Form_';
$this->pluginLoader->addPrefixPath($prefix, $formsDirectory);
$name = ucfirst((string) $name);
$formClass = $this->pluginLoader->load($name);
return new $formClass($options);
}
示例6: __construct
/**
* 构造函数
*
* @param string $daemon
* @param array|Zend_Config $config
* @param ZtChart_Model_Monitor_Console $console
*/
public function __construct($daemon, $config = array(), ZtChart_Model_Monitor_Console $console = null)
{
if ($config instanceof Zend_Config) {
$config = $config->toArray();
}
if (null === $console) {
$console = ZtChart_Model_Monitor_Console::getInstance();
}
$loader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Monitor_Daemon' => realpath(__DIR__ . '/Monitor/Daemon')));
if (false === ($daemonClass = $loader->load($daemon, false))) {
throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' could not be found.");
} else {
if (!is_subclass_of($daemonClass, 'ZtChart_Model_Monitor_Daemon_Abstract')) {
throw new ZtChart_Model_Monitor_Exception("Specified daemon class '{$daemon}' is illegal.");
} else {
$this->_daemon = new $daemonClass($console, $config);
}
}
}
示例7: loadValidator
/**
* Lazy-load a validator
*
* @param array $validator Validator definition
* @return Zend_Validate_Interface
* @see Zend_Form_Element::loadValidator() (function from Zend_Form_Element borrowed and modified)
*/
protected function loadValidator(array $validator)
{
$origName = $validator['name'];
$name = $this->pluginLoader->load($validator['name']);
if (array_key_exists($name, $this->validators)) {
throw new Webdesktop_Model_Exception(sprintf('Validator instance already exists for validator "%s"', $origName));
}
if (empty($validator['options'])) {
$instance = new $name();
} else {
$r = new ReflectionClass($name);
if ($r->hasMethod('__construct')) {
$instance = $r->newInstanceArgs((array) $validator['options']);
} else {
$instance = $r->newInstance();
}
}
$this->validators[$origName] = $instance;
return $instance;
}
示例8: getManipulatorInstance
/**
* Returns an manipulator instance based on its name.
*
* @param string $manipulator
* @return Gem_Manipulator_Adapter_Interface
*/
public static function getManipulatorInstance($manipulator)
{
$args = array();
if (is_array($manipulator)) {
$args = $manipulator;
$manipulator = array_shift($args);
}
// TODO: Move to allow other plugins...
$loader = new Zend_Loader_PluginLoader();
$loader->addPrefixPath('Yag_Manipulator_Adapter', 'Yag/Manipulator/Adapter/');
$className = $loader->load($manipulator);
$class = new ReflectionClass($className);
if (!$class->implementsInterface('Yag_Manipulator_Adapter_Interface')) {
require_once 'Yag/Manipulator/Exception.php';
throw new Gem_Manipulator_Exception('Manipulator must implement interface "Yag_Manipulator_Adapter_Interface".');
}
if ($class->hasMethod('__construct')) {
$object = $class->newInstanceArgs($args);
} else {
$object = $class->newInstance();
}
return $object;
}
示例9: setupPlugins
/**
* It loads plugins.
* @param Zend_Config $method
*/
protected function setupPlugins($method)
{
if (empty($this->_loadedPlugins) && !empty($this->_plugins)) {
foreach ($this->_plugins as $pluginName => $options) {
try {
$classname = $this->_pluginLoader->load($pluginName);
$r = new ReflectionClass($classname);
if ($r->isSubclassOf('App_Rest_Plugin_Abstract')) {
$this->_loadedPlugins[$pluginName] = new $classname($this, $method, $options);
} else {
unset($this->_plugins[$pluginName]);
$this->log(sprintf("Loading plugin %s.Class %s is not a App_Rest_Plugin_Abstract descendent", $pluginName, $classname), Zend_Log::CRIT);
}
} catch (Zend_Loader_PluginLoader_Exception $e) {
$this->log($e->getMessage(), Zend_Log::CRIT);
}
}
} else {
foreach ($this->_loadedPlugins as $plugin) {
$plugin->setRestMethod($method);
}
}
return $this;
}
示例10: testClassFilesAreSearchedInLifoOrder
public function testClassFilesAreSearchedInLifoOrder()
{
$loader = new Zend_Loader_PluginLoader(array());
$loader->addPrefixPath('Zend_View_Helper', $this->libPath . '/Zend/View/Helper');
$loader->addPrefixPath('ZfTest', dirname(__FILE__) . '/_files/ZfTest');
try {
$className = $loader->load('FormSubmit');
} catch (Exception $e) {
$paths = $loader->getPaths();
$this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
}
$this->assertEquals($className, $loader->getClassName('FormSubmit'));
$this->assertEquals('ZfTest_FormSubmit', $loader->getClassName('FormSubmit'));
}
示例11: factory
/**
* 工厂方法,返回指定游戏的在线人数日志数据表对象
*
* @param integer $gameType
* @param string $datetime
* @param mixed $config
* @return ZtChart_Model_DbTable_Infoserver
*/
public static function factory($gameType, $datetime = null, $config = array())
{
$loader = new Zend_Loader_PluginLoader(array(__CLASS__ => realpath(__DIR__ . '/Infoserver')));
if (false !== ($class = $loader->load(ZtChart_Model_GameType::getShortName($gameType), false))) {
$infoserver = new $class($gameType, $datetime, $config);
} else {
$infoserver = new self($gameType, $datetime, $config);
}
return $infoserver;
}
示例12: testPrefixesEndingInBackslashDenoteNamespacedClasses
/**
* @group ZF-7350
*/
public function testPrefixesEndingInBackslashDenoteNamespacedClasses()
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$this->markTestSkipped(__CLASS__ . '::' . __METHOD__ . ' requires PHP 5.3.0 or greater');
return;
}
$loader = new Zend_Loader_PluginLoader(array());
$loader->addPrefixPath('Zfns\\', dirname(__FILE__) . '/_files/Zfns');
try {
$className = $loader->load('Foo');
} catch (Exception $e) {
$paths = $loader->getPaths();
$this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
}
$this->assertEquals('Zfns\\Foo', $className);
$this->assertEquals('Zfns\\Foo', $loader->getClassName('Foo'));
}
示例13: _getAdapter
/**
* 取得Auth适配器
*
* @param string $adapter
* @return Zend_Auth_Adapter_Interface
*/
protected function _getAdapter($adapter = null)
{
if (empty($adapter)) {
$adapter = $this->_adapter;
}
$pluginLoader = new Zend_Loader_PluginLoader(array('ZtChart_Model_Auth_Adapter_' => realpath(__DIR__ . '/../models/Auth/Adapter'), 'Zend_Auth_Adapter_' => 'Zend/Auth/Adapter'));
if (false === ($adapterClass = $pluginLoader->load($adapter, false))) {
throw new Zend_Application_Resource_Exception("Specified Auth Adapter '{$adapter}' could not be found");
}
return new $adapterClass();
}
示例14: _initPlugins
/**
* init additional plugins
*
* @return void
*/
protected function _initPlugins()
{
// get front controller instance
$front = Zend_Controller_Front::getInstance();
// create loader
$loader = new Zend_Loader_PluginLoader();
$loader->addPrefixPath('Plugin', Zend_Registry::get('config')->resources->frontController->pluginsDirectory);
$pluginAuthentication = $loader->load('Authentication');
// register plugin
$front->registerPlugin(new $pluginAuthentication());
}
示例15: testWin32UnderscoreSpacedShortNamesWillLoad
/**
* @issue ZF-2741
*/
public function testWin32UnderscoreSpacedShortNamesWillLoad()
{
$loader = new Zend_Loader_PluginLoader(array());
$loader->addPrefixPath('Zend_Filter', $this->libPath . '/Zend/Filter');
try {
// Plugin loader will attempt to load "c:\path\to\library/Zend/Filter/Word\UnderscoreToDash.php"
$className = $loader->load('Word_UnderscoreToDash');
} catch (Exception $e) {
$paths = $loader->getPaths();
$this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
}
$this->assertEquals($className, $loader->getClassName('Word_UnderscoreToDash'));
}