当前位置: 首页>>代码示例>>PHP>>正文


PHP ModuleQuery::create方法代码示例

本文整理汇总了PHP中Thelia\Model\ModuleQuery::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleQuery::create方法的具体用法?PHP ModuleQuery::create怎么用?PHP ModuleQuery::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Model\ModuleQuery的用法示例。


在下文中一共展示了ModuleQuery::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testModuleRefreshCommand

 /**
  * Test ModuleRefreshCommand
  */
 public function testModuleRefreshCommand()
 {
     $moduleManagement = new ModuleManagement();
     $moduleManagement->updateModules();
     $module = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
     if ($module !== null) {
         $module->delete();
         $application = new Application($this->getKernel());
         $moduleRefresh = new ModuleRefreshCommand();
         $moduleRefresh->setContainer($this->getContainer());
         $application->add($moduleRefresh);
         $command = $application->find('module:refresh');
         $commandTester = new CommandTester($command);
         $commandTester->execute(['command' => $command->getName()]);
         $expected = $module;
         $actual = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
         $this->assertEquals($expected->getCode(), $actual->getCode(), 'Last standard module code must be same after deleting this one and calling module:refresh');
         $this->assertEquals($expected->getType(), $actual->getType(), 'Last standard module type must be same after deleting this one and calling module:refresh');
         $this->assertEquals($expected->getFullNamespace(), $actual->getFullNamespace(), 'Last standard module namespace must be same after deleting this one and calling module:refresh');
         // Restore activation status
         $actual->setActivate($expected->getActivate())->save();
     } else {
         $this->markTestIncomplete('This test cannot be complete without at least one standard module.');
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:28,代码来源:ModuleRefreshCommandTest.php

示例2: isModuleActive

 protected function isModuleActive($module_id)
 {
     if (null !== ($module = ModuleQuery::create()->findPk($module_id))) {
         return $module->getActivate();
     }
     return false;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:7,代码来源:ModuleHook.php

示例3: processHookFunction

 /**
  * Generates the content of the hook
  *
  * {hook name="hook_code" var1="value1" var2="value2" ... }
  *
  * This function create an event, feed it with the custom variables passed to the function (var1, var2, ...) and
  * dispatch it to the hooks that respond to it.
  *
  * The name of the event is `hook.{context}.{hook_code}` where :
  *      * context : the id of the context of the smarty render : 1: frontoffice, 2: backoffice, 3: email, 4: pdf
  *      * hook_code : the code of the hook
  *
  * The event collects all the fragments of text rendered in each modules functions that listen to this event.
  * Finally, this fragments are concatenated and injected in the template
  *
  * @param array        $params the params passed in the smarty function
  * @param \TheliaSmarty\Template\SmartyParser $smarty the smarty parser
  *
  * @return string the contents generated by modules
  */
 public function processHookFunction($params, &$smarty)
 {
     $hookName = $this->getParam($params, 'name');
     $module = intval($this->getParam($params, 'module', 0));
     $moduleCode = $this->getParam($params, 'modulecode', "");
     $type = $smarty->getTemplateDefinition()->getType();
     $event = new HookRenderEvent($hookName, $params);
     $event->setArguments($this->getArgumentsFromParams($params));
     $eventName = sprintf('hook.%s.%s', $type, $hookName);
     // this is a hook specific to a module
     if (0 === $module && "" !== $moduleCode) {
         if (null !== ($mod = ModuleQuery::create()->findOneByCode($moduleCode))) {
             $module = $mod->getId();
         }
     }
     if (0 !== $module) {
         $eventName .= '.' . $module;
     }
     $this->getDispatcher()->dispatch($eventName, $event);
     $content = trim($event->dump());
     if ($this->debug && $smarty->getRequest()->get('SHOW_HOOK')) {
         $content = sprintf('<div style="background-color: #C82D26; color: #fff; border-color: #000000; border: solid;">%s</div>%s', $hookName, $content);
     }
     $this->hookResults[$hookName] = $content;
     // support for compatibility with module_include
     if ($type === TemplateDefinition::BACK_OFFICE) {
         $content .= $this->moduleIncludeCompat($params, $smarty);
     }
     return $content;
 }
开发者ID:badelas,项目名称:thelia,代码行数:50,代码来源:Hook.php

示例4: processHook

 protected function processHook(ContainerBuilder $container, $definition)
 {
     foreach ($container->findTaggedServiceIds('hook.event_listener') as $id => $events) {
         $class = $container->getDefinition($id)->getClass();
         // the class must extends BaseHook
         $implementClass = HookDefinition::BASE_CLASS;
         if (!is_subclass_of($class, $implementClass)) {
             throw new \InvalidArgumentException(sprintf('Hook class "%s" must extends class "%s".', $class, $implementClass));
         }
         // retrieve the module id
         $properties = $container->getDefinition($id)->getProperties();
         $module = null;
         if (array_key_exists('module', $properties)) {
             $moduleCode = explode(".", $properties['module'])[1];
             if (null !== ($module = ModuleQuery::create()->findOneByCode($moduleCode))) {
                 $module = $module->getId();
             }
         }
         foreach ($events as $event) {
             $this->registerHook($class, $module, $id, $event);
         }
     }
     // now we can add listeners for active hooks and active module
     $this->addHooksMethodCall($definition);
 }
开发者ID:hadesain,项目名称:thelia,代码行数:25,代码来源:RegisterHookListenersPass.php

示例5: updateModules

 public function updateModules()
 {
     $finder = new Finder();
     $finder->name('module.xml')->in($this->baseModuleDir . '/*/Config');
     $descriptorValidator = new ModuleDescriptorValidator();
     foreach ($finder as $file) {
         $content = $descriptorValidator->getDescriptor($file->getRealPath());
         $reflected = new \ReflectionClass((string) $content->fullnamespace);
         $code = basename(dirname($reflected->getFileName()));
         $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $module = ModuleQuery::create()->filterByCode($code)->findOne();
             if (null === $module) {
                 $module = new Module();
                 $module->setCode($code)->setFullNamespace((string) $content->fullnamespace)->setType($this->getModuleType($reflected))->setActivate(0)->save($con);
             }
             $this->saveDescription($module, $content, $con);
             $con->commit();
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
开发者ID:fachriza,项目名称:thelia,代码行数:25,代码来源:ModuleManagement.php

示例6: checkValidInvoice

 protected function checkValidInvoice()
 {
     $order = $this->getSession()->getOrder();
     if (null === $order || null === $order->getChoosenInvoiceAddress() || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->getChoosenInvoiceAddress()) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
         throw new RedirectException($this->retrieveUrlFromRouteId('order.invoice'));
     }
 }
开发者ID:fachriza,项目名称:thelia,代码行数:7,代码来源:BaseFrontController.php

示例7: getModule

 /**
  * @param  string                    $itemName the modume code
  * @return Module                    the module object
  * @throws \InvalidArgumentException if module was not found
  */
 protected function getModule($itemName)
 {
     if (null !== ($module = ModuleQuery::create()->findPk($itemName))) {
         return $module;
     }
     throw new \InvalidArgumentException($this->getTranslator()->trans("No module found for code '%item'", ['%item' => $itemName]));
 }
开发者ID:margery,项目名称:thelia,代码行数:12,代码来源:TranslationsController.php

示例8: verifyModuleId

 public function verifyModuleId($value, ExecutionContextInterface $context)
 {
     $module = ModuleQuery::create()->findPk($value);
     if (null === $module) {
         $context->addViolation(Translator::getInstance()->trans("Module ID not found"));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:7,代码来源:ModuleModificationForm.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $moduleCode = $this->formatModuleName($input->getArgument("module"));
     $module = ModuleQuery::create()->findOneByCode($moduleCode);
     if (null === $module) {
         throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
     }
     if ($module->getActivate() == BaseModule::IS_NOT_ACTIVATED) {
         throw new \RuntimeException(sprintf("module %s is already deactivated", $moduleCode));
     }
     try {
         $event = new ModuleToggleActivationEvent($module->getId());
         $module = ModuleQuery::create()->findPk($module->getId());
         if ($module->getMandatory() == BaseModule::IS_MANDATORY) {
             if (!$this->askConfirmation($input, $output)) {
                 return;
             }
             $event->setAssumeDeactivate(true);
         }
         if ($input->getOption("with-dependencies")) {
             $event->setRecursive(true);
         }
         $this->getDispatcher()->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event);
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf("Deactivation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
     }
     //impossible to change output class in CommandTester...
     if (method_exists($output, "renderBlock")) {
         $output->renderBlock(array('', sprintf("Deactivation succeed for module %s", $moduleCode), ''), "bg=green;fg=black");
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:31,代码来源:ModuleDeactivateCommand.php

示例10: setUp

 public function setUp()
 {
     $stubContainer = $this->getMockBuilder('\\Symfony\\Component\\DependencyInjection\\ContainerInterface')->disableOriginalConstructor()->getMock();
     $this->action = new ModuleHook($stubContainer, $this->getMockEventDispatcher());
     $this->module = ModuleQuery::create()->findOneByActivate(1);
     $this->hook = HookQuery::create()->findOneByActivate(true);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:7,代码来源:ModuleHookTest.php

示例11: buildForm

 protected function buildForm($change_mode = false)
 {
     $this->formBuilder->add("id", "hidden", array("required" => true, "constraints" => array(new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array(array($this, "verifyProfileId")))))));
     foreach (ModuleQuery::create()->find() as $module) {
         $this->formBuilder->add(self::MODULE_ACCESS_FIELD_PREFIX . ':' . str_replace(".", ":", $module->getCode()), "choice", array("choices" => array(AccessManager::VIEW => AccessManager::VIEW, AccessManager::CREATE => AccessManager::CREATE, AccessManager::UPDATE => AccessManager::UPDATE, AccessManager::DELETE => AccessManager::DELETE), "attr" => array("tag" => "modules", "module_code" => $module->getCode()), "multiple" => true, "constraints" => array()));
     }
 }
开发者ID:badelas,项目名称:thelia,代码行数:7,代码来源:ProfileUpdateModuleAccessForm.php

示例12: process

 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('event_dispatcher')) {
         return;
     }
     $definition = $container->getDefinition('event_dispatcher');
     foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events) {
         foreach ($events as $event) {
             $priority = isset($event['priority']) ? $event['priority'] : 0;
             if (!isset($event['event'])) {
                 throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.event_listener" tags.', $id));
             }
             if (!isset($event['method'])) {
                 $event['method'] = 'on' . preg_replace_callback(array('/(?<=\\b)[a-z]/i', '/[^a-z0-9]/i'), function ($matches) {
                     return strtoupper($matches[0]);
                 }, $event['event']);
                 $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']);
             }
             $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority));
         }
     }
     foreach ($container->findTaggedServiceIds('kernel.event_subscriber') as $id => $attributes) {
         // We must assume that the class value has been correctly filled, even if the service is created by a factory
         $class = $container->getDefinition($id)->getClass();
         $refClass = new \ReflectionClass($class);
         $interface = 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface';
         if (!$refClass->implementsInterface($interface)) {
             throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
         }
         $definition->addMethodCall('addSubscriberService', array($id, $class));
     }
     // We have to check if Propel is initialized before registering hooks
     $managers = Propel::getServiceContainer()->getConnectionManagers();
     if (!array_key_exists('thelia', $managers)) {
         return;
     }
     foreach ($container->findTaggedServiceIds('hook.event_listener') as $id => $events) {
         $class = $container->getDefinition($id)->getClass();
         // the class must extends BaseHook
         $implementClass = HookDefinition::BASE_CLASS;
         if (!is_subclass_of($class, $implementClass)) {
             throw new \InvalidArgumentException(sprintf('Hook class "%s" must extends class "%s".', $class, $implementClass));
         }
         // retrieve the module id
         $properties = $container->getDefinition($id)->getProperties();
         $module = null;
         if (array_key_exists('module', $properties)) {
             $moduleCode = explode(".", $properties['module'])[1];
             if (null !== ($module = ModuleQuery::create()->findOneByCode($moduleCode))) {
                 $module = $module->getId();
             }
         }
         foreach ($events as $event) {
             $this->registerHook($class, $module, $id, $event);
         }
     }
     // now we can add listeners for active hooks and active module
     $this->addHooksMethodCall($definition);
 }
开发者ID:alex63530,项目名称:thelia,代码行数:59,代码来源:RegisterListenersPass.php

示例13: preActivation

 /**
  *
  * return false if CreditAccount module is not present
  *
  * @param ConnectionInterface $con
  * @return bool|void
  */
 public function preActivation(ConnectionInterface $con = null)
 {
     $module = ModuleQuery::create()->filterByCode('CreditAccount')->filterByActivate(self::IS_ACTIVATED)->findOne();
     if (null === $module) {
         throw new \RuntimeException(Translator::getInstance()->trans('CreditAccount must be installed and activated', [], 'loyalty'));
     }
     return true;
 }
开发者ID:gillesbourgeat,项目名称:Loyalty,代码行数:15,代码来源:Loyalty.php

示例14: verifyDeliveryModule

 public function verifyDeliveryModule($value, ExecutionContextInterface $context)
 {
     $module = ModuleQuery::create()->filterActivatedByTypeAndId(BaseModule::DELIVERY_MODULE_TYPE, $value)->findOne();
     if (null === $module) {
         $context->addViolation(Translator::getInstance()->trans("Delivery module ID not found"));
     } elseif (!$module->isDeliveryModule()) {
         $context->addViolation(sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\\Module\\DeliveryModuleInterface"), $module->getCode()));
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:9,代码来源:OrderDelivery.php

示例15: getModule

 private function getModule(InputInterface $input)
 {
     $module = null;
     $moduleCode = $input->getArgument("module");
     if (!empty($moduleCode)) {
         if (null === ($module = ModuleQuery::create()->findOneByCode($moduleCode))) {
             throw new \RuntimeException(sprintf("Module %s does not exist.", $moduleCode));
         }
     }
     return $module;
 }
开发者ID:SimonWaters,项目名称:thelia,代码行数:11,代码来源:HookCleanCommand.php


注:本文中的Thelia\Model\ModuleQuery::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。