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


PHP Model\LangQuery类代码示例

本文整理汇总了PHP中Thelia\Model\LangQuery的典型用法代码示例。如果您正苦于以下问题:PHP LangQuery类的具体用法?PHP LangQuery怎么用?PHP LangQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     // delete existing message
     $message = MessageQuery::create()->filterByName('mail_virtualproduct')->findOne($con);
     if (null !== $message) {
         $message->delete($con);
     }
     // create new message
     $message = new Message();
     $message->setName('mail_virtualproduct')->setSecured(0);
     $basePath = __DIR__ . '/Config/message/%s.xml';
     $languages = LangQuery::create()->find();
     foreach ($languages as $language) {
         $locale = $language->getLocale();
         $message->setLocale($locale);
         $path = sprintf($basePath, $language->getLocale());
         if (file_exists($path) && is_readable($path)) {
             $dom = new SimpleXMLElement(file_get_contents($path));
             if ($dom) {
                 $message->setTitle((string) $dom->title);
                 $message->setSubject((string) $dom->subject);
                 $message->setTextMessage((string) $dom->text);
                 $message->setHtmlMessage((string) $dom->html);
             }
         }
     }
     $message->save();
 }
开发者ID:alex63530,项目名称:thelia,代码行数:28,代码来源:VirtualProductDelivery.php

示例2: registerPreviousUrl

 /**
  * Save the previous URL in session which is based on the referer header or the request, or
  * the _previous_url request attribute, if defined.
  *
  * If the value of _previous_url is "dont-save", the current referrer is not saved.
  *
  * @param FilterResponseEvent $event
  */
 public function registerPreviousUrl(PostResponseEvent $event)
 {
     $request = $event->getRequest();
     $referrer = $request->attributes->get('_previous_url', null);
     if (null !== $referrer) {
         // A previous URL (or the keyword 'dont-save') has been specified.
         if ('dont-save' == $referrer) {
             // We should not save the current URL as the previous URL
             $referrer = null;
         }
     } else {
         // The current URL will become the previous URL
         $referrer = $request->getUri();
     }
     // Set previous URL, if defined
     if (null !== $referrer) {
         $session = $request->getSession();
         if (ConfigQuery::read("one_domain_foreach_lang", false) == 1) {
             $components = parse_url($referrer);
             $lang = LangQuery::create()->filterByUrl(sprintf("%s://%s", $components["scheme"], $components["host"]), ModelCriteria::LIKE)->findOne();
             if (null !== $lang) {
                 $session->setReturnToUrl($referrer);
             }
         } else {
             if (false !== strpos($referrer, $request->getSchemeAndHttpHost())) {
                 $session->setReturnToUrl($referrer);
             }
         }
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:38,代码来源:RequestListener.php

示例3: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     // register config variables
     if (null === ConfigQuery::read(self::CONFIG_TRACKING_URL, null)) {
         ConfigQuery::write(self::CONFIG_TRACKING_URL, self::DEFAULT_TRACKING_URL);
     }
     if (null === ConfigQuery::read(self::CONFIG_PICKING_METHOD, null)) {
         ConfigQuery::write(self::CONFIG_PICKING_METHOD, self::DEFAULT_PICKING_METHOD);
     }
     if (null === ConfigQuery::read(self::CONFIG_TAX_RULE_ID, null)) {
         ConfigQuery::write(self::CONFIG_TAX_RULE_ID, self::DEFAULT_TAX_RULE_ID);
     }
     // create new message
     if (null === MessageQuery::create()->findOneByName('mail_custom_delivery')) {
         $message = new Message();
         $message->setName('mail_custom_delivery')->setHtmlTemplateFileName('custom-delivery-shipping.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('custom-delivery-shipping.txt')->setTextLayoutFileName('')->setSecured(0);
         $languages = LangQuery::create()->find();
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Custom delivery shipping message', [], $locale));
             $message->setSubject($this->trans('Your order {$order_ref} has been shipped', [], $locale));
         }
         $message->save();
     }
 }
开发者ID:egruel,项目名称:jus-de-corossol,代码行数:26,代码来源:CustomDelivery.php

示例4: checkLocalizedDate

 /**
  * Validate a date entered with the default Language date format.
  *
  * @param string                    $value
  * @param ExecutionContextInterface $context
  */
 public function checkLocalizedDate($value, ExecutionContextInterface $context)
 {
     $format = LangQuery::create()->findOneByByDefault(true)->getDateFormat();
     if (false === \DateTime::createFromFormat($format, $value)) {
         $context->addViolation(Translator::getInstance()->trans("Date '%date' is invalid, please enter a valid date using %fmt format", ['%fmt' => $format, '%date' => $value]));
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:13,代码来源:CouponCreationForm.php

示例5: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     $languages = LangQuery::create()->find();
     ConfigQuery::write(self::CONFIG_ENABLED, self::DEFAULT_ENABLED);
     ConfigQuery::write(self::CONFIG_THRESHOLD, self::DEFAULT_THRESHOLD);
     ConfigQuery::write(self::CONFIG_EMAILS, self::DEFAULT_EMAILS);
     // create new message
     if (null === MessageQuery::create()->findOneByName('stockalert_customer')) {
         $message = new Message();
         $message->setName('stockalert_customer')->setHtmlTemplateFileName('alert-customer.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-customer.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Stock Alert - Customer', [], $locale));
             $message->setSubject($this->trans('Product {$product_title} is available again', [], $locale));
         }
         $message->save();
         $message = new Message();
         $message->setName('stockalert_administrator')->setHtmlTemplateFileName('alert-administrator.html')->setHtmlLayoutFileName('')->setTextTemplateFileName('alert-administrator.txt')->setTextLayoutFileName('')->setSecured(0);
         foreach ($languages as $language) {
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Stock Alert - Administrator', [], $locale));
             $message->setSubject($this->trans('Product {$product_title} is (nearly) out of stock', [], $locale));
         }
         $message->save();
     }
     try {
         RestockingAlertQuery::create()->findOne();
     } catch (\Exception $e) {
         $database = new Database($con);
         $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']);
     }
 }
开发者ID:Mertiozys,项目名称:StockAlert,代码行数:34,代码来源:StockAlert.php

示例6: uploadImage

 public function uploadImage()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, ['carousel'], AccessManager::CREATE))) {
         return $response;
     }
     $request = $this->getRequest();
     $form = $this->createForm('carousel.image');
     $error_message = null;
     try {
         $this->validateForm($form);
         /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $fileBeingUploaded */
         $fileBeingUploaded = $request->files->get(sprintf('%s[file]', $form->getName()), null, true);
         $fileModel = new Carousel();
         $fileCreateOrUpdateEvent = new FileCreateOrUpdateEvent(1);
         $fileCreateOrUpdateEvent->setModel($fileModel);
         $fileCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
         $this->dispatch(TheliaEvents::IMAGE_SAVE, $fileCreateOrUpdateEvent);
         // Compensate issue #1005
         $langs = LangQuery::create()->find();
         /** @var Lang $lang */
         foreach ($langs as $lang) {
             $fileCreateOrUpdateEvent->getModel()->setLocale($lang->getLocale())->setTitle('')->save();
         }
         $response = $this->redirectToConfigurationPage();
     } catch (FormValidationException $e) {
         $error_message = $this->createStandardFormValidationErrorMessage($e);
     }
     if (null !== $error_message) {
         $this->setupFormErrorContext('carousel upload', $error_message, $form);
         $response = $this->render("module-configure", ['module_code' => 'Carousel']);
     }
     return $response;
 }
开发者ID:MaximeMorille,项目名称:thelia,代码行数:33,代码来源:ConfigurationController.php

示例7: setUp

 public function setUp()
 {
     $this->locale = LangQuery::create()->findOne()->getLocale();
     $this->dispatcher = $this->getMock('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $stubContainer = $this->getMockBuilder('\\Symfony\\Component\\DependencyInjection\\ContainerInterface')->disableOriginalConstructor()->getMock();
     $this->action = new Hook($stubContainer);
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:HookTest.php

示例8: retrieveLocale

 protected function retrieveLocale($viewLocale)
 {
     if (strlen($viewLocale) == 2) {
         if (null !== ($lang = LangQuery::create()->findOneByCode($viewLocale))) {
             $viewLocale = $lang->getLocale();
         }
     }
     return $viewLocale;
 }
开发者ID:margery,项目名称:thelia,代码行数:9,代码来源:RewritingUrlQuery.php

示例9: applyUserLocale

 protected function applyUserLocale(Admin $user)
 {
     // Set the current language according to Admin locale preference
     $locale = $user->getLocale();
     if (null === ($lang = LangQuery::create()->findOneByLocale($locale))) {
         $lang = Lang::getDefaultLanguage();
     }
     $this->getSession()->setLang($lang);
 }
开发者ID:alex63530,项目名称:thelia,代码行数:9,代码来源:SessionController.php

示例10: getLocaleList

 protected function getLocaleList()
 {
     $locales = array();
     $list = LangQuery::create()->find();
     foreach ($list as $item) {
         $locales[$item->getLocale()] = $item->getLocale();
     }
     return $locales;
 }
开发者ID:margery,项目名称:thelia,代码行数:9,代码来源:AdministratorCreationForm.php

示例11: updateAction

 public function updateAction($lang_id)
 {
     if (null !== ($response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $this->checkXmlHttpRequest();
     $lang = LangQuery::create()->findPk($lang_id);
     $langForm = $this->createForm(AdminForm::LANG_UPDATE, 'form', array('id' => $lang->getId(), 'title' => $lang->getTitle(), 'code' => $lang->getCode(), 'locale' => $lang->getLocale(), 'date_time_format' => $lang->getDateTimeFormat(), 'date_format' => $lang->getDateFormat(), 'time_format' => $lang->getTimeFormat(), 'decimal_separator' => $lang->getDecimalSeparator(), 'thousands_separator' => $lang->getThousandsSeparator(), 'decimals' => $lang->getDecimals()));
     $this->getParserContext()->addForm($langForm);
     return $this->render('ajax/language-update-modal', array('lang_id' => $lang_id));
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:11,代码来源:LangController.php

示例12: export

 /**
  * @param  integer  $id
  * @return Response
  *
  * This method is called when the route /admin/export/{id}
  * is called with a POST request.
  */
 public function export($id)
 {
     if (null === ($export = $this->getExport($id))) {
         return $this->pageNotFound();
     }
     /**
      * Get needed services
      */
     $archiveBuilderManager = $this->getArchiveBuilderManager($this->container);
     $formatterManager = $this->getFormatterManager($this->container);
     /**
      * Get the archive builders
      */
     $archiveBuilders = [];
     foreach ($archiveBuilderManager->getNames() as $archiveBuilder) {
         $archiveBuilders[$archiveBuilder] = $archiveBuilder;
     }
     /**
      * Define and validate the form
      */
     $form = new ExportForm($this->getRequest());
     $errorMessage = null;
     try {
         $boundForm = $this->validateForm($form);
         $lang = LangQuery::create()->findPk($boundForm->get("language")->getData());
         $archiveBuilder = null;
         /**
          * Get the formatter and the archive builder if we have to compress the file(s)
          */
         /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */
         $formatter = $formatterManager->get($boundForm->get("formatter")->getData());
         if ($boundForm->get("do_compress")->getData()) {
             /** @var \Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface $archiveBuilder */
             $archiveBuilder = $archiveBuilderManager->get($boundForm->get("archive_builder")->getData());
         }
         /**
          * Return the generated Response
          */
         return $this->processExport($formatter, $export->getHandleClassInstance($this->container), $archiveBuilder, $lang, $boundForm->get("images")->getData(), $boundForm->get("documents")->getData());
     } catch (FormValidationException $e) {
         $errorMessage = $this->createStandardFormValidationErrorMessage($e);
     } catch (\Exception $e) {
         $errorMessage = $e->getMessage();
     }
     /**
      * If has an error, display it
      */
     if (null !== $errorMessage) {
         $form->setErrorMessage($errorMessage);
         $this->getParserContext()->addForm($form)->setGeneralError($errorMessage);
     }
     return $this->exportView($id);
 }
开发者ID:alex63530,项目名称:thelia,代码行数:60,代码来源:ExportController.php

示例13: buildModelCriteria

 public function buildModelCriteria()
 {
     $search = LangQuery::create();
     if (null !== ($id = $this->getId())) {
         $search->filterById($id, Criteria::IN);
     }
     if (null !== ($code = $this->getCode())) {
         $search->filterByCode($code, Criteria::IN);
     }
     if (null !== ($locale = $this->getLocale())) {
         $search->filterByLocale($locale, Criteria::IN);
     }
     if (!$this->getBackendContext() && Type\BooleanOrBothType::ANY !== ($visible = $this->getVisible())) {
         $search->filterByVisible($visible);
     }
     if (Type\BooleanOrBothType::ANY !== ($active = $this->getActive())) {
         $search->filterByActive($active);
     }
     if ($this->getDefaultOnly()) {
         $search->filterByByDefault(true);
     }
     if ($this->getExcludeDefault()) {
         $search->filterByByDefault(false);
     }
     if (null !== ($exclude = $this->getExclude())) {
         $search->filterById($exclude, Criteria::NOT_IN);
     }
     $orders = $this->getOrder();
     foreach ($orders as $order) {
         switch ($order) {
             case "id":
                 $search->orderById(Criteria::ASC);
                 break;
             case "id_reverse":
                 $search->orderById(Criteria::DESC);
                 break;
             case "alpha":
                 $search->orderByTitle(Criteria::ASC);
                 break;
             case "alpha_reverse":
                 $search->orderByTitle(Criteria::DESC);
                 break;
             case "position":
                 $search->orderByPosition(Criteria::ASC);
                 break;
             case "position_reverse":
                 $search->orderByPosition(Criteria::DESC);
                 break;
         }
     }
     return $search;
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:52,代码来源:Lang.php

示例14: setI18n

 /**
  * populate a list of field for each locale for an object
  *
  * @param mixed $object     the object to populate
  * @param array $fields     list of field to populate
  * @param array $localeList list of locale to use populate the object
  */
 protected function setI18n(&$object, $fields = array("Title"), $localeList = null)
 {
     if (null === $localeList) {
         if (null === self::$localeList) {
             self::$localeList = LangQuery::create()->select("Locale")->find()->toArray();
         }
         $localeList = self::$localeList;
     }
     foreach ($localeList as $locale) {
         foreach ($fields as $name) {
             $object->getTranslation($locale)->setByName($name, $locale . ' : ' . $name);
         }
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:21,代码来源:I18nTestTrait.php

示例15: createMailMessage

 public function createMailMessage()
 {
     // Create payment confirmation message from templates, if not already defined
     if (null === MessageQuery::create()->findOneByName(self::CONFIRMATION_MESSAGE_NAME)) {
         $languages = LangQuery::create()->find();
         $message = new Message();
         $message->setName(self::CONFIRMATION_MESSAGE_NAME)->setHtmlTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.html')->setTextTemplateFileName(self::CONFIRMATION_MESSAGE_NAME . '.txt');
         foreach ($languages as $language) {
             /** @var Lang $language */
             $locale = $language->getLocale();
             $message->setLocale($locale)->setTitle(Translator::getInstance()->trans("Payment confirmation for Stripe Payment", [], self::MESSAGE_DOMAIN, $locale))->setSubject(Translator::getInstance()->trans('Payment confirmation of your order {$order_ref} on {$store_name}', [], self::MESSAGE_DOMAIN, $locale));
         }
         $message->save();
     }
 }
开发者ID:neywen,项目名称:StripePayment,代码行数:15,代码来源:StripePayment.php


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