本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getEnabledAddons方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getEnabledAddons方法的具体用法?PHP MauticFactory::getEnabledAddons怎么用?PHP MauticFactory::getEnabledAddons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Factory\MauticFactory
的用法示例。
在下文中一共展示了MauticFactory::getEnabledAddons方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAddonBundles
/**
* @return array
*/
protected function getAddonBundles()
{
return $this->factory->getEnabledAddons();
}
示例2: getIntegrationObjects
/**
* Get a list of integration helper classes
*
* @param array|string $services
* @param array $withFeatures
* @param bool $alphabetical
* @param null|int $addonFilter
*
* @return mixed
*/
public function getIntegrationObjects($services = null, $withFeatures = null, $alphabetical = false, $addonFilter = null)
{
static $integrations, $available;
if (empty($integrations)) {
$em = $this->factory->getEntityManager();
$available = $integrations = array();
// And we'll be scanning the addon bundles for additional classes, so have that data on standby
$addons = $this->factory->getEnabledAddons();
// Quickly figure out which addons are enabled so we only process those
/** @var \Mautic\AddonBundle\Entity\AddonRepository $addonRepo */
$addonRepo = $em->getRepository('MauticAddonBundle:Addon');
$addonStatuses = $addonRepo->getBundleStatus(true);
// Scan the addons for integration classes
foreach ($addons as $addon) {
if (is_dir($addon['directory'] . '/Integration')) {
$finder = new Finder();
$finder->files()->name('*Integration.php')->in($addon['directory'] . '/Integration')->ignoreDotFiles(true);
if ($alphabetical) {
$finder->sortByName();
}
$id = $addonStatuses[$addon['bundle']]['id'];
foreach ($finder as $file) {
$available[] = array('addon' => $em->getReference('MauticAddonBundle:Addon', $id), 'integration' => substr($file->getBaseName(), 0, -15), 'namespace' => str_replace('MauticAddon', '', $addon['bundle']));
}
}
}
$integrationSettings = $this->getIntegrationSettings();
// Get all the addon integrations
foreach ($available as $id => $a) {
if ($addonFilter && $a['addon']->getId() != $addonFilter) {
continue;
}
if (!isset($integrations[$a['integration']])) {
$class = "\\MauticAddon\\" . $a['namespace'] . "\\Integration\\" . $a['integration'] . "Integration";
$reflectionClass = new \ReflectionClass($class);
if ($reflectionClass->isInstantiable()) {
$integrations[$a['integration']] = new $class($this->factory);
if (!isset($integrationSettings[$a['integration']])) {
$integrationSettings[$a['integration']] = new Integration();
$integrationSettings[$a['integration']]->setName($a['integration']);
}
$integrationSettings[$a['integration']]->setAddon($a['addon']);
$integrations[$a['integration']]->setIntegrationSettings($integrationSettings[$a['integration']]);
}
}
}
if (empty($alphabetical)) {
// Sort by priority
uasort($integrations, function ($a, $b) {
$aP = (int) $a->getPriority();
$bP = (int) $b->getPriority();
if ($aP === $bP) {
return 0;
}
return $aP < $bP ? -1 : 1;
});
}
}
if (!empty($services)) {
if (!is_array($services) && isset($integrations[$services])) {
return array($services => $integrations[$services]);
} elseif (is_array($services)) {
$specific = array();
foreach ($services as $s) {
if (isset($integrations[$s])) {
$specific[$s] = $integrations[$s];
}
}
return $specific;
} else {
throw new MethodNotAllowedHttpException(array_keys($available));
}
} elseif (!empty($withFeatures)) {
if (!is_array($withFeatures)) {
$withFeatures = array($withFeatures);
}
$specific = array();
foreach ($integrations as $n => $d) {
$settings = $d->getIntegrationSettings();
$features = $settings->getSupportedFeatures();
foreach ($withFeatures as $f) {
if (in_array($f, $features)) {
$specific[$n] = $d;
break;
}
}
}
return $specific;
}
return $integrations;
//.........这里部分代码省略.........