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


PHP ConfigQuery::write方法代码示例

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


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

示例1: saveAction

 /**
  * Fill the form with the configuration data
  */
 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, [OpenGraph::DOMAIN_NAME], AccessManager::UPDATE))) {
         return $response;
     }
     // Create the form from the request
     $form = $this->createForm('open.graph.configuration.form');
     // Initialize the potential error
     $error_message = null;
     try {
         // Check the form against constraints violations
         $validateForm = $this->validateForm($form);
         // Get the form field values
         $data = $validateForm->getData();
         OpenGraph::setConfigValue(OpenGraphConfigValue::ENABLE_SHARING_BUTTONS, is_bool($data["enable_sharing_buttons"]) ? (int) $data["enable_sharing_buttons"] : $data["enable_sharing_buttons"]);
         foreach ($data as $name => $value) {
             ConfigQuery::write("opengraph_" . $name, $value, false, true);
         }
         // Redirect to the configuration page if everything is OK
         return $this->redirectToConfigurationPage();
     } catch (FormValidationException $e) {
         // Form cannot be validated. Create the error message using
         // the BaseAdminController helper method.
         $error_message = $this->createStandardFormValidationErrorMessage($e);
     }
     if (null !== $error_message) {
         $this->setupFormErrorContext('configuration', $error_message, $form);
         $response = $this->render("module-configure", ['module_code' => 'OpenGraph']);
     }
     return $response;
 }
开发者ID:thelia-modules,项目名称:OpenGraph,代码行数:34,代码来源:OpenGraphController.php

示例2: saveAction

 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $response = null;
     $configStoreForm = new ConfigStoreForm($this->getRequest());
     try {
         $form = $this->validateForm($configStoreForm);
         $data = $form->getData();
         // Update store
         foreach ($data as $name => $value) {
             if (!in_array($name, array('success_url', 'error_message'))) {
                 ConfigQuery::write($name, $value, false);
             }
         }
         $this->adminLogAppend(AdminResources::STORE, AccessManager::UPDATE, "Store configuration changed");
         if ($this->getRequest()->get('save_mode') == 'stay') {
             $response = $this->generateRedirectFromRoute('admin.configuration.store.default');
         } else {
             $response = $this->generateSuccessRedirect($configStoreForm);
         }
     } catch (\Exception $ex) {
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $this->setupFormErrorContext($this->getTranslator()->trans("Store configuration failed."), $error_msg, $configStoreForm, $ex);
         $response = $this->renderTemplate();
     }
     return $response;
 }
开发者ID:badelas,项目名称:thelia,代码行数:32,代码来源:ConfigStoreController.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: 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

示例5: exapaqConfigure

 public function exapaqConfigure()
 {
     if (null !== ($response = $this->checkAuth([AdminResources::MODULE], ['Predict'], AccessManager::UPDATE))) {
         return $response;
     }
     $error_msg = false;
     $save_mode = "stay";
     $form = new ConfigureForm($this->getRequest());
     try {
         $vform = $this->validateForm($form);
         $save_mode = $this->getRequest()->request->get("save_mode");
         ConfigQuery::write("store_exapaq_account", $vform->get("account_number")->getData());
         ConfigQuery::write("store_cellphone", $vform->get("store_cellphone")->getData());
         ConfigQuery::write("store_predict_option", $vform->get("predict_option")->getData() ? "1" : "");
     } catch (FormValidationException $ex) {
         // Form cannot be validated
         $error_msg = $this->createStandardFormValidationErrorMessage($ex);
     } catch (\Exception $ex) {
         // Any other error
         $error_msg = $ex->getMessage();
     }
     if (false !== $error_msg) {
         $form->setErrorMessage($error_msg);
         $this->getParserContext()->addForm($form)->setGeneralError($error_msg);
     }
     if ($save_mode !== "stay") {
         return $this->generateRedirectFromRoute("admin.module", [], ['_controller' => 'Thelia\\Controller\\Admin\\ModuleController::indexAction']);
     }
     return $this->render("module-configure", ["module_code" => "Predict", "tab" => "configure"]);
 }
开发者ID:lopes-vincent,项目名称:Predict,代码行数:30,代码来源:ConfigurationController.php

示例6: tearDown

 /**
  * Shuts the kernel down if it was used in the test.
  */
 protected function tearDown()
 {
     ConfigQuery::write('one_domain_foreach_lang', $this->isMultiDomainActivated);
     if (null !== static::$kernel) {
         static::$kernel->shutdown();
     }
 }
开发者ID:NicolasMugnier,项目名称:thelia,代码行数:10,代码来源:WebTestCase.php

示例7: updateToVersion

 protected function updateToVersion($version, Database $database, Tlog $logger)
 {
     if (file_exists(THELIA_ROOT . '/setup/update/' . $version . '.sql')) {
         $logger->debug(sprintf('inserting file %s', $version . '$sql'));
         $database->insertSql(null, array(THELIA_ROOT . '/setup/update/' . $version . '.sql'));
         $logger->debug(sprintf('end inserting file %s', $version . '$sql'));
     }
     ConfigQuery::write('thelia_version', $version);
 }
开发者ID:alex63530,项目名称:thelia,代码行数:9,代码来源:Update.php

示例8: buildForm

 /**
  *
  * in this function you add all the fields you need for your Form.
  * Form this you have to call add method on $this->formBuilder attribute :
  *
  * $this->formBuilder->add("name", "text")
  *   ->add("email", "email", array(
  *           "attr" => array(
  *               "class" => "field"
  *           ),
  *           "label" => "email",
  *           "constraints" => array(
  *               new \Symfony\Component\Validator\Constraints\NotBlank()
  *           )
  *       )
  *   )
  *   ->add('age', 'integer');
  *
  * @return null
  */
 protected function buildForm()
 {
     $account = ConfigQuery::read("store_exapaq_account");
     if (!is_numeric($account)) {
         ConfigQuery::write("store_exapaq_account", 0);
         $account = 0;
     }
     $translator = Translator::getInstance();
     $this->formBuilder->add("account_number", "integer", array("label" => $translator->trans("Account number", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "account_number"], "constraints" => [new NotBlank()], "required" => true, "data" => $account))->add("store_cellphone", "text", array("label" => $translator->trans("Store's cellphone", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "store_cellphone"], "required" => false, "data" => ConfigQuery::read("store_cellphone")))->add("predict_option", "checkbox", array("label" => $translator->trans("Predict SMS option", [], Predict::MESSAGE_DOMAIN), "label_attr" => ["for" => "predict_option"], "required" => false, "data" => @(bool) ConfigQuery::read("store_predict_option")));
 }
开发者ID:lopes-vincent,项目名称:Predict,代码行数:30,代码来源:ConfigureForm.php

示例9: testFormatTime

 public function testFormatTime()
 {
     $this->assertEquals("1 hour(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 61);
     $this->assertEquals("1 hour(s) 1 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 59);
     $this->assertEquals("59 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 5);
     $this->assertEquals("5 minute(s)", $this->form->getWaitingTime());
     ConfigQuery::write("form_firewall_time_to_wait", 132);
     $this->assertEquals("2 hour(s) 12 minute(s)", $this->form->getWaitingTime());
 }
开发者ID:alex63530,项目名称:thelia,代码行数:12,代码来源:FirewallTest.php

示例10: preActivation

 public function preActivation(ConnectionInterface $con = null)
 {
     $prefix = ConfigQuery::read(self::CONFIG_PATH);
     if ($prefix === null) {
         ConfigQuery::write(self::CONFIG_PATH, '', false, true);
     }
     $enabled = ConfigQuery::read(self::CONFIG_USE_DEFAULT_PATH, null);
     if ($enabled === null) {
         ConfigQuery::write(self::CONFIG_USE_DEFAULT_PATH, true, false, true);
     }
     return true;
 }
开发者ID:enurit,项目名称:BackOfficePath,代码行数:12,代码来源:BackOfficePath.php

示例11: saveAction

 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, ['Twitter'], AccessManager::UPDATE))) {
         return $response;
     }
     $form = new ConfigurationForm($this->getRequest());
     $configurationForm = $this->validateForm($form);
     $consumer_key = $configurationForm->get('consumer_key')->getData();
     $consumer_secret = $configurationForm->get('consumer_secret')->getData();
     $screen_name = $configurationForm->get('screen_name')->getData();
     $count = $configurationForm->get('count')->getData();
     $cache_lifetime = $configurationForm->get('cache_lifetime')->getData();
     // $debug_mode     = $configurationForm->get('debug_mode')->getData();
     $errorMessage = null;
     $response = null;
     // Save config values
     ConfigQuery::write('twitter_consumer_key', $consumer_key, 1, 1);
     ConfigQuery::write('twitter_consumer_secret', $consumer_secret, 1, 1);
     ConfigQuery::write('twitter_screen_name', $screen_name, 1, 1);
     ConfigQuery::write('twitter_count', $count, 1, 1);
     ConfigQuery::write('twitter_cache_lifetime', $cache_lifetime * 60, 1, 1);
     // Minutes
     ConfigQuery::write('twitter_last_updated', 0, 1, 1);
     if ($screen_name && $consumer_key && $consumer_secret) {
         if (!extension_loaded('openssl')) {
             $sslError = $this->getTranslator()->trans("This module requires the PHP extension open_ssl to work.", [], Twitter::DOMAIN_NAME);
         } else {
             $config = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'output_format' => 'array');
             try {
                 $connection = new TwitterOAuth($config);
                 $bearer_token = $connection->getBearerToken();
             } catch (\Exception $e) {
                 $errorMessage = $e->getMessage();
             }
             try {
                 $params = array('screen_name' => $screen_name, 'count' => 1, 'exclude_replies' => true);
                 $response = $connection->get('statuses/user_timeline', $params);
                 if ($response['error']) {
                     throw new TwitterException($response['error']);
                 }
             } catch (\Exception $e) {
                 $erroMessage = $this->getTranslator()->trans("Unrecognized screen name", [], Twitter::DOMAIN_NAME);
             }
         }
     }
     $response = RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Twitter'));
     if (null !== $errorMessage) {
         $this->setupFormErrorContext($this->getTranslator()->trans("Twitter configuration failed.", [], Twitter::DOMAIN_NAME), $errorMessage, $form);
         $response = $this->render("module-configure", ['module_code' => 'Twitter']);
     }
     return $response;
 }
开发者ID:nicolasleon,项目名称:Twitter,代码行数:52,代码来源:ConfigurationController.php

示例12: saveAction

 public function saveAction()
 {
     $baseForm = new MailjetConfigurationForm($this->getRequest());
     try {
         $form = $this->validateForm($baseForm);
         $data = $form->getData();
         ConfigQuery::write(Mailjet::CONFIG_API_KEY, $data["api_key"]);
         ConfigQuery::write(Mailjet::CONFIG_API_SECRET, $data["api_secret"]);
         ConfigQuery::write(Mailjet::CONFIG_API_WS_ADDRESS, $data["ws_address"]);
         ConfigQuery::write(Mailjet::CONFIG_NEWSLETTER_LIST, $data["newsletter_list"]);
         $this->getParserContext()->set("success", true);
     } catch (\Exception $e) {
         $this->getParserContext()->setGeneralError($e->getMessage())->addForm($baseForm);
     }
     if ("close" === $this->getRequest()->request->get("save_mode")) {
         return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/modules"));
     }
 }
开发者ID:Boyquotes,项目名称:Mailjet,代码行数:18,代码来源:MailjetConfigController.php

示例13: saveAction

 public function saveAction()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('hookanalytics'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new \HookAnalytics\Form\Configuration($this->getRequest());
     $resp = array("error" => 0, "message" => "");
     $response = null;
     try {
         $vform = $this->validateForm($form);
         $data = $vform->getData();
         ConfigQuery::write("hookanalytics_trackingcode", $data["trackingcode"], false, true);
     } catch (\Exception $e) {
         $resp["error"] = 1;
         $resp["message"] = $e->getMessage();
     }
     return JsonResponse::create($resp);
 }
开发者ID:margery,项目名称:thelia,代码行数:18,代码来源:Configuration.php

示例14: getTweets

 public function getTweets()
 {
     $cache_path = realpath('.') . '/cache/tweets';
     $last_updated = ConfigQuery::read('twitter_last_updated');
     $tweets_file = $cache_path . '/' . Twitter::TWEETS_FILENAME;
     $tweets = [];
     // Is the cache stale ?
     // if( $last_updated + 0 < time() )
     if ($last_updated + $this->cache_lifetime < time()) {
         if (!is_dir($cache_path)) {
             mkdir($cache_path);
             chmod($cache_path, 0755);
         }
         // Get the tweets
         $config = ['consumer_key' => $this->consumer_key, 'consumer_secret' => $this->consumer_secret];
         try {
             $connection = new TwitterOAuth($config);
             $bearer_token = $connection->getBearerToken();
         } catch (\Exception $e) {
             $errorMessage = $e->getMessage();
         }
         try {
             $params = array('screen_name' => $this->screen_name, 'count' => $this->count, 'exclude_replies' => true);
             $tweets = $connection->get('statuses/user_timeline', $params);
             if ($tweets['error']) {
                 throw new TwitterException($tweets['error']);
             }
             // Cache tweets
             unlink($tweets_file);
             $fh = fopen($tweets_file, 'w');
             fwrite($fh, json_encode($tweets));
             fclose($fh);
             // Update cache refresh timestamp
             ConfigQuery::write('twitter_last_updated', time(), 1, 1);
         } catch (\Exception $e) {
             $erroMessage = Translator::getInstance()->trans("Unrecognized screen name", [], Twitter::DOMAIN_NAME);
         }
     } else {
         // Get tweets from the cache
         $tweets = json_decode(file_get_contents($tweets_file));
     }
     return $tweets;
 }
开发者ID:nicolasleon,项目名称:Twitter,代码行数:43,代码来源:Twitter.php

示例15: save

 public function save()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('SoColissimo'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new ConfigureSoColissimo($this->getRequest());
     try {
         $vform = $this->validateForm($form);
         ConfigQuery::write('socolissimo_login', $vform->get('accountnumber')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_pwd', $vform->get('password')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_url_prod', $vform->get('url_prod')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_url_test', $vform->get('url_test')->getData(), 1, 1);
         ConfigQuery::write('socolissimo_test_mode', $vform->get('test_mode')->getData(), 1, 1);
         $this->redirectToRoute("admin.module.configure", [], ['module_code' => 'SoColissimo', 'current_tab' => 'configure']);
     } catch (\Exception $e) {
         $this->setupFormErrorContext(Translator::getInstance()->trans("So Colissimo update config"), $e->getMessage(), $form, $e);
         return $this->render('module-configure', ['module_code' => 'SoColissimo', 'current_tab' => 'configure']);
     }
 }
开发者ID:ThomasArnaud,项目名称:SoColissimo,代码行数:19,代码来源:SaveConfig.php


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