本文整理汇总了PHP中ExtensionManager::_subscriptions方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtensionManager::_subscriptions方法的具体用法?PHP ExtensionManager::_subscriptions怎么用?PHP ExtensionManager::_subscriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtensionManager
的用法示例。
在下文中一共展示了ExtensionManager::_subscriptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyMembers
/**
* Given a delegate name, notify all extensions that have registered to that
* delegate to executing their callbacks with a `$context` array parameter
* that contains information about the current Symphony state.
*
* @param string $delegate
* The delegate name
* @param string $page
* The current page namespace that this delegate operates in
* @param array $context
* The `$context` param is an associative array that at minimum will contain
* the current Administration class, the current page object and the delegate
* name. Other context information may be passed to this function when it is
* called. eg.
*
* array(
* 'parent' =>& $this->Parent,
* 'page' => $page,
* 'delegate' => $delegate
* );
*
*/
public function notifyMembers($delegate, $page, array $context = array())
{
if ((int) Symphony::Configuration()->get('allow_page_subscription', 'symphony') != 1) {
return;
}
if (is_null(self::$_subscriptions)) {
self::$_subscriptions = Symphony::Database()->fetch("\n\t\t\t\t\tSELECT t1.name, t2.page, t2.delegate, t2.callback\n\t\t\t\t\tFROM `tbl_extensions` as t1 INNER JOIN `tbl_extensions_delegates` as t2 ON t1.id = t2.extension_id\n\t\t\t\t\tWHERE t1.status = 'enabled'");
}
// Make sure $page is an array
if (!is_array($page)) {
$page = array($page);
}
// Support for global delegate subscription
if (!in_array('*', $page)) {
$page[] = '*';
}
$services = array();
foreach (self::$_subscriptions as $subscription) {
if ($subscription['delegate'] != $delegate) {
continue;
}
if (!in_array($subscription['page'], $page)) {
continue;
}
$services[] = $subscription;
}
if (empty($services)) {
return null;
}
$parent = Symphony::Engine();
$context += array('parent' => &$parent, 'page' => $page, 'delegate' => $delegate);
foreach ($services as $s) {
$obj = $this->getInstance($s['name']);
if (is_object($obj) && method_exists($obj, $s['callback'])) {
$obj->{$s['callback']}($context);
}
}
}
示例2: notifyMembers
public function notifyMembers($delegate, $page, $context = array())
{
if ((int) Symphony::Configuration()->get('allow_page_subscription', 'symphony') != 1) {
return;
}
if (is_null(self::$_subscriptions)) {
self::$_subscriptions = Symphony::Database()->fetch("\n\t\t\t\t\tSELECT t1.name, t2.page, t2.delegate, t2.callback\n\t\t\t\t\tFROM `tbl_extensions` as t1 INNER JOIN `tbl_extensions_delegates` as t2 ON t1.id = t2.extension_id\n\t\t\t\t\tWHERE t1.status = 'enabled'");
}
// Make sure $page is an array
if (!is_array($page)) {
// Support for pseudo-global delegates (including legacy support for /administration/)
if (preg_match('/\\/?(administration|backend)\\/?/', $page)) {
$page = array('backend', '/backend/', 'administration', '/administration/');
} else {
$page = array($page);
}
}
// Support for global delegate subscription
if (!in_array('*', $page)) {
$page[] = '*';
}
$services = null;
foreach (self::$_subscriptions as $subscription) {
foreach ($page as $p) {
if ($p == $subscription['page'] && $delegate == $subscription['delegate']) {
if (!is_array($services)) {
$services = array();
}
$services[] = $subscription;
}
}
}
if (!is_array($services) || empty($services)) {
return NULL;
}
$context += array('parent' => &$this->_Parent, 'page' => $page, 'delegate' => $delegate);
foreach ($services as $s) {
$obj = $this->create($s['name']);
if (is_object($obj) && in_array($s['callback'], get_class_methods($obj))) {
$obj->{$s['callback']}($context);
unset($obj);
}
}
}