本文整理汇总了PHP中Piwik\WidgetsList::isDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP WidgetsList::isDefined方法的具体用法?PHP WidgetsList::isDefined怎么用?PHP WidgetsList::isDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\WidgetsList
的用法示例。
在下文中一共展示了WidgetsList::isDefined方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeDisabledPluginFromLayout
public function removeDisabledPluginFromLayout($layout)
{
$layoutObject = $this->decodeLayout($layout);
// if the json decoding works (ie. new Json format)
// we will only return the widgets that are from enabled plugins
if (is_array($layoutObject)) {
$layoutObject = (object) array('config' => array('layout' => '33-33-33'), 'columns' => $layoutObject);
}
if (empty($layoutObject) || empty($layoutObject->columns)) {
$layoutObject = (object) array('config' => array('layout' => '33-33-33'), 'columns' => array());
}
foreach ($layoutObject->columns as &$row) {
if (!is_array($row)) {
$row = array();
continue;
}
foreach ($row as $widgetId => $widget) {
if (isset($widget->parameters->module)) {
$controllerName = $widget->parameters->module;
$controllerAction = $widget->parameters->action;
if (!WidgetsList::isDefined($controllerName, $controllerAction)) {
unset($row[$widgetId]);
}
} else {
unset($row[$widgetId]);
}
}
}
$layout = $this->encodeLayout($layoutObject);
return $layout;
}
示例2: widgetExists
private function widgetExists($widget)
{
if (empty($widget->parameters)) {
return false;
}
$module = $widget->parameters->module;
$action = $widget->parameters->action;
return WidgetsList::isDefined($module, $action);
}
示例3: testIsDefined
public function testIsDefined()
{
// setup the access layer
FakeAccess::$superUser = true;
Translate::loadAllTranslations();
Fixture::createWebsite('2009-01-04 00:11:42', true);
$_GET['idSite'] = 1;
WidgetsList::_reset();
WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls');
$this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls'));
$this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD'));
Translate::reset();
}
示例4: testIsDefined
/**
* @group Core
*/
public function testIsDefined()
{
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
\Piwik\Translate::loadEnglishTranslation();
Fixture::createWebsite('2009-01-04 00:11:42', true);
$_GET['idSite'] = 1;
WidgetsList::_reset();
WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls');
$this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls'));
$this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD'));
}
示例5: factory
/**
* @ignore
* @return Widgets|null
*/
public static function factory($module, $action)
{
if (empty($module) || empty($action)) {
return;
}
$pluginManager = PluginManager::getInstance();
try {
if (!$pluginManager->isPluginActivated($module)) {
return;
}
$plugin = $pluginManager->getLoadedPlugin($module);
} catch (\Exception $e) {
// we are not allowed to use possible widgets, plugin is not active
return;
}
/** @var Widgets $widgetContainer */
$widgetContainer = $plugin->findComponent('Widgets', 'Piwik\\Plugin\\Widgets');
if (empty($widgetContainer)) {
// plugin does not define any widgets, we cannot do anything
return;
}
if (!is_callable(array($widgetContainer, $action))) {
// widget does not implement such a method, we cannot do anything
return;
}
// the widget class implements such an action, but we have to check whether it is actually exposed and whether
// it was maybe disabled by another plugin, this is only possible by checking the widgetslist, unfortunately
if (!WidgetsList::isDefined($module, $action)) {
return;
}
return $widgetContainer;
}