本文整理汇总了PHP中Thelia\Model\ModuleQuery::getActivated方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleQuery::getActivated方法的具体用法?PHP ModuleQuery::getActivated怎么用?PHP ModuleQuery::getActivated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\ModuleQuery
的用法示例。
在下文中一共展示了ModuleQuery::getActivated方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*
* @api
*/
public function process(ContainerBuilder $container)
{
try {
$chainRouter = $container->getDefinition("router.chainRequest");
} catch (InvalidArgumentException $e) {
return;
}
foreach ($container->findTaggedServiceIds("router.register") as $id => $attributes) {
$priority = isset($attributes[0]["priority"]) ? $attributes[0]["priority"] : 0;
$router = $container->getDefinition($id);
$router->addMethodCall("setOption", array("matcher_cache_class", $container::camelize("ProjectUrlMatcher" . $id)));
$router->addMethodCall("setOption", array("generator_cache_class", $container::camelize("ProjectUrlGenerator" . $id)));
$chainRouter->addMethodCall("add", array(new Reference($id), $priority));
}
if (defined("THELIA_INSTALL_MODE") === false) {
$modules = \Thelia\Model\ModuleQuery::getActivated();
foreach ($modules as $module) {
$moduleBaseDir = $module->getBaseDir();
$routingConfigFilePath = $module->getAbsoluteBaseDir() . DS . "Config" . DS . "routing.xml";
if (file_exists($routingConfigFilePath)) {
$definition = new Definition($container->getParameter("router.class"), array(new Reference("router.module.xmlLoader"), $routingConfigFilePath, array("cache_dir" => $container->getParameter("kernel.cache_dir"), "debug" => $container->getParameter("kernel.debug"), "matcher_cache_class" => $container::camelize("ProjectUrlMatcher" . $moduleBaseDir), "generator_cache_class" => $container::camelize("ProjectUrlGenerator" . $moduleBaseDir)), new Reference("request.context")));
$container->setDefinition("router." . $moduleBaseDir, $definition);
$chainRouter->addMethodCall("add", array(new Reference("router." . $moduleBaseDir), 150));
}
}
}
}
示例2: theliaModule
/**
* Process theliaModule template inclusion function
*
* This function accepts two parameters:
*
* - location : this is the location in the admin template. Example: folder-edit'. The function will search for
* AdminIncludes/<location>.html file, and fetch it as a Smarty template.
* - countvar : this is the name of a template variable where the number of found modules includes will be assigned.
*
* @param array $params
* @param \Smarty_Internal_Template $template
* @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty
*
* @return string
*/
public function theliaModule($params, \Smarty_Internal_Template $template)
{
$content = null;
$count = 0;
if (false !== ($location = $this->getParam($params, 'location', false))) {
if ($this->debug === true && $this->request->get('SHOW_INCLUDE')) {
echo sprintf('<div style="background-color: #C82D26; color: #fff; border-color: #000000; border: solid;">%s</div>', $location);
}
$moduleLimit = $this->getParam($params, 'module', null);
$modules = ModuleQuery::getActivated();
/** @var \Thelia\Model\Module $module */
foreach ($modules as $module) {
if (null !== $moduleLimit && $moduleLimit != $module->getCode()) {
continue;
}
$file = $module->getAbsoluteAdminIncludesPath() . DS . $location . '.html';
if (file_exists($file)) {
$output = trim(file_get_contents($file));
if (!empty($output)) {
$content .= $output;
$count++;
}
}
}
}
if (false !== ($countvarname = $this->getParam($params, 'countvar', false))) {
$template->assign($countvarname, $count);
}
if (!empty($content)) {
return $template->fetch(sprintf("string:%s", $content));
}
return "";
}
示例3: getModuleChoices
protected function getModuleChoices()
{
$choices = array();
$modules = ModuleQuery::getActivated();
/** @var Module $module */
foreach ($modules as $module) {
$choices[$module->getId()] = $module->getTitle();
}
return $choices;
}
示例4: getModuleChoices
protected function getModuleChoices()
{
$choices = array();
$modules = ModuleQuery::getActivated();
/** @var Module $module */
foreach ($modules as $module) {
// Check if module defines a hook ID
if (ModuleHookQuery::create()->filterByModuleId($module->getId())->count() > 0 || IgnoredModuleHookQuery::create()->filterByModuleId($module->getId())->count() > 0) {
$choices[$module->getId()] = $module->getTitle();
}
}
asort($choices);
return $choices;
}
示例5: listDirectoryContent
protected function listDirectoryContent($requiredExtension)
{
$list = array();
$dir = $this->getTemplateHelper()->getActiveMailTemplate()->getAbsolutePath();
$finder = Finder::create()->files()->in($dir)->ignoreDotFiles(true)->sortByName()->name("*.{$requiredExtension}");
foreach ($finder as $file) {
$list[] = $file->getBasename();
}
// Add modules templates
$modules = ModuleQuery::getActivated();
/** @var Module $module */
foreach ($modules as $module) {
$dir = $module->getAbsoluteTemplateBasePath() . DS . TemplateDefinition::EMAIL_SUBDIR . DS . 'default';
if (file_exists($dir)) {
$finder = Finder::create()->files()->in($dir)->ignoreDotFiles(true)->sortByName()->name("*.{$requiredExtension}");
foreach ($finder as $file) {
$fileName = $file->getBasename();
if (!in_array($fileName, $list)) {
$list[] = $fileName;
}
}
}
}
return $list;
}
示例6: loadConfiguration
/**
*
* Load some configuration
* Initialize all plugins
*
*/
protected function loadConfiguration(ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . "/../Config/Resources"));
$finder = Finder::create()->name('*.xml')->depth(0)->in(__DIR__ . "/../Config/Resources");
/** @var \SplFileInfo $file */
foreach ($finder as $file) {
$loader->load($file->getBaseName());
}
if (defined("THELIA_INSTALL_MODE") === false) {
$modules = ModuleQuery::getActivated();
$translationDirs = array();
/** @var Module $module */
foreach ($modules as $module) {
try {
$definition = new Definition();
$definition->setClass($module->getFullNamespace());
$definition->addMethodCall("setContainer", array(new Reference('service_container')));
$container->setDefinition("module." . $module->getCode(), $definition);
$compilers = call_user_func(array($module->getFullNamespace(), 'getCompilers'));
foreach ($compilers as $compiler) {
if (is_array($compiler)) {
$container->addCompilerPass($compiler[0], $compiler[1]);
} else {
$container->addCompilerPass($compiler);
}
}
$loader = new XmlFileLoader($container, new FileLocator($module->getAbsoluteConfigPath()));
$loader->load("config.xml", "module." . $module->getCode());
$envConfigFileName = sprintf("config_%s.xml", $this->environment);
$envConfigFile = sprintf('%s%s%s', $module->getAbsoluteConfigPath(), DS, $envConfigFileName);
if (is_file($envConfigFile) && is_readable($envConfigFile)) {
$loader->load($envConfigFileName, "module." . $module->getCode());
}
} catch (\Exception $e) {
Tlog::getInstance()->addError(sprintf("Failed to load module %s: %s", $module->getCode(), $e->getMessage()), $e);
}
}
/** @var ParserInterface $parser */
$parser = $container->getDefinition('thelia.parser');
/** @var \Thelia\Core\Template\TemplateHelperInterface $templateHelper */
$templateHelper = $container->get('thelia.template_helper');
/** @var Module $module */
foreach ($modules as $module) {
try {
$this->loadModuleTranslationDirectories($module, $translationDirs, $templateHelper);
$this->addStandardModuleTemplatesToParserEnvironment($parser, $module);
} catch (\Exception $e) {
Tlog::getInstance()->addError(sprintf("Failed to load module %s: %s", $module->getCode(), $e->getMessage()), $e);
}
}
// Load core translation
$translationDirs['core'] = THELIA_LIB . 'Config' . DS . 'I18n';
// Load core translation
$translationDirs[Translator::GLOBAL_FALLBACK_DOMAIN] = THELIA_LOCAL_DIR . 'I18n';
// Standard templates (front, back, pdf, mail)
/** @var TemplateDefinition $templateDefinition */
foreach ($templateHelper->getStandardTemplateDefinitions() as $templateDefinition) {
if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) {
$translationDirs[$templateDefinition->getTranslationDomain()] = $dir;
}
}
if ($translationDirs) {
$this->loadTranslation($container, $translationDirs);
}
}
}
示例7: loadConfiguration
/**
*
* Load some configuration
* Initialize all plugins
*
*/
protected function loadConfiguration(ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(THELIA_ROOT . "/core/lib/Thelia/Config/Resources"));
$finder = Finder::create()->name('*.xml')->depth(0)->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources");
/** @var \SplFileInfo $file */
foreach ($finder as $file) {
$loader->load($file->getBaseName());
}
if (defined("THELIA_INSTALL_MODE") === false) {
$modules = ModuleQuery::getActivated();
$translationDirs = array();
/** @var ParserInterface $parser */
$parser = $container->getDefinition('thelia.parser');
/** @var Module $module */
foreach ($modules as $module) {
try {
$definition = new Definition();
$definition->setClass($module->getFullNamespace());
$definition->addMethodCall("setContainer", array(new Reference('service_container')));
$container->setDefinition("module." . $module->getCode(), $definition);
$compilers = call_user_func(array($module->getFullNamespace(), 'getCompilers'));
foreach ($compilers as $compiler) {
if (is_array($compiler)) {
$container->addCompilerPass($compiler[0], $compiler[1]);
} else {
$container->addCompilerPass($compiler);
}
}
$loader = new XmlFileLoader($container, new FileLocator($module->getAbsoluteConfigPath()));
$loader->load("config.xml", "module." . $module->getCode());
// Core module translation
if (is_dir($dir = $module->getAbsoluteI18nPath())) {
$translationDirs[$module->getTranslationDomain()] = $dir;
}
// Admin includes translation
if (is_dir($dir = $module->getAbsoluteAdminIncludesI18nPath())) {
$translationDirs[$module->getAdminIncludesTranslationDomain()] = $dir;
}
// Module back-office template, if any
$templates = TemplateHelper::getInstance()->getList(TemplateDefinition::BACK_OFFICE, $module->getAbsoluteTemplateBasePath());
foreach ($templates as $template) {
$translationDirs[$module->getBackOfficeTemplateTranslationDomain($template->getName())] = $module->getAbsoluteBackOfficeI18nTemplatePath($template->getName());
}
// Module front-office template, if any
$templates = TemplateHelper::getInstance()->getList(TemplateDefinition::FRONT_OFFICE, $module->getAbsoluteTemplateBasePath());
foreach ($templates as $template) {
$translationDirs[$module->getFrontOfficeTemplateTranslationDomain($template->getName())] = $module->getAbsoluteFrontOfficeI18nTemplatePath($template->getName());
}
$this->addStandardModuleTemplatesToParserEnvironment($parser, $module);
} catch (\InvalidArgumentException $e) {
Tlog::getInstance()->addError(sprintf("Failed to load module %s: %s", $module->getCode(), $e->getMessage()), $e);
throw $e;
}
}
// Load core translation
$translationDirs['core'] = THELIA_ROOT . 'core' . DS . 'lib' . DS . 'Thelia' . DS . 'Config' . DS . 'I18n';
// Standard templates (front, back, pdf, mail)
$th = TemplateHelper::getInstance();
/** @var TemplateDefinition $templateDefinition */
foreach ($th->getStandardTemplateDefinitions() as $templateDefinition) {
if (is_dir($dir = $templateDefinition->getAbsoluteI18nPath())) {
$translationDirs[$templateDefinition->getTranslationDomain()] = $dir;
}
}
if ($translationDirs) {
$this->loadTranslation($container, $translationDirs);
}
}
}