本文整理汇总了PHP中Factory::plugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::plugin方法的具体用法?PHP Factory::plugin怎么用?PHP Factory::plugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::plugin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
/**
* Import a helper (aka "template plugin").
* @param string $name Helper name
*
*/
function &import_helper($name)
{
foreach (func_get_args() as $name) {
$class =& Factory::plugin($name, 'template');
if ($class === false) {
trigger_error("Helper {$name} does not exist");
die;
}
}
if ($class) {
return $class;
}
}
示例2: depend
/**
* Load another plugin as a dependency of this one. Plugins can
* only load dependencies of their own kind. Templates plugins
* load template plugins, page plugins load page plugins.
*
* @param string $plugin The name of the plugin to import. Will be
* saved as $this->depends->$plugin
*/
function depend($plugin)
{
switch (substr(get_class($this), 0, 2)) {
case 'tp':
$type = 'template';
break;
case 'pp':
$type = 'page';
break;
}
foreach (func_get_args() as $arg) {
$this->depends->{$arg} =& Factory::plugin($arg, $type);
}
}
示例3: I18N
// TODO: this should be unset, left for back-compat for now...
//unset($db);
/************************************************************************
* INTERNATIONALIZATION
************************************************************************/
$i18n = new I18N();
$i18n->autoset_language('en');
define('LANG', $i18n->get_language());
Registry::set('pronto:i18n', $i18n);
unset($i18n);
/************************************************************************
* PRELOAD PLUGINS
************************************************************************/
foreach (explode(' ', PLUGINS) as $p) {
if ($p) {
Factory::plugin($p, 'page');
}
}
unset($p);
// left in the symbol table for the cmdline script
$plugins =& Registry::get('pronto:plugins');
/************************************************************************
* REMAINING UTILITY CLASSES
************************************************************************/
$p = new Validator();
Registry::set('pronto:validator', $p);
unset($p);
/************************************************************************
* HANDLE ERRORS/DEBUGGING/PROFILING
************************************************************************/
error_reporting(E_ALL & ~E_NOTICE);
示例4: foreach
/**
* Import a plugin (aka "page plugin").
* @param string $name Plugin name
*/
function &import_plugin($name)
{
foreach (func_get_args() as $name) {
$class =& Factory::plugin($name, 'page');
if ($class === false) {
trigger_error("Plugin {$name} does not exist");
die;
}
}
// reload $this->plugins
$this->plugins =& Registry::get('pronto:plugins');
if ($class) {
return $class;
}
}
示例5:
/**
* Return a new helper (aka "template plugin") object
* If an existing helper object already exists, it will be used.
*
* @param string $name
* @return object
*/
function &helper($name)
{
return Factory::plugin($name, 'template');
}