本文整理汇总了PHP中Thelia\Model\ConfigQuery::read方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery::read方法的具体用法?PHP ConfigQuery::read怎么用?PHP ConfigQuery::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\ConfigQuery
的用法示例。
在下文中一共展示了ConfigQuery::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onMainHeadBottom
public function onMainHeadBottom(HookRenderEvent $event)
{
$value = trim(ConfigQuery::read("hookanalytics_trackingcode", ""));
if ("" != $value) {
$event->add($value);
}
}
示例2: __construct
public function __construct()
{
$this->url = ConfigQuery::read('hookpiwikanalytics_url', false);
$this->website_id = ConfigQuery::read('hookpiwikanalytics_website_id', false);
\PiwikTracker::$URL = $this->url;
$this->tracker = new \PiwikTracker($this->website_id);
}
示例3: 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);
}
}
}
}
示例4: postActivation
/**
* @inheritdoc
*/
public function postActivation(ConnectionInterface $con = null)
{
$fileSystem = new Filesystem();
//Check for environment
if ($env = $this->getContainer()->getParameter('kernel.environment')) {
//Check for backward compatibility
if ($env !== "prod" && $env !== "dev") {
//Remove separtion between dev and prod in particular environment
$env = str_replace('_dev', '', $env);
$this->webMediaEnvPath = $this->webMediaPath . DS . $env;
}
}
// Create symbolic links or hard copy in the web directory
// (according to \Thelia\Action\Document::CONFIG_DELIVERY_MODE),
// to make the TinyMCE code available.
if (false === $fileSystem->exists($this->webJsPath)) {
if (ConfigQuery::read(Document::CONFIG_DELIVERY_MODE) === 'symlink') {
$fileSystem->symlink($this->jsPath, $this->webJsPath);
} else {
$fileSystem->mirror($this->jsPath, $this->webJsPath);
}
}
// Create the media directory in the web root , if required
if (null !== $this->webMediaEnvPath) {
if (false === $fileSystem->exists($this->webMediaEnvPath)) {
$fileSystem->mkdir($this->webMediaEnvPath . DS . 'upload');
$fileSystem->mkdir($this->webMediaEnvPath . DS . 'thumbs');
}
} else {
if (false === $fileSystem->exists($this->webMediaPath)) {
$fileSystem->mkdir($this->webMediaPath . DS . 'upload');
$fileSystem->mkdir($this->webMediaPath . DS . 'thumbs');
}
}
}
示例5: update_status
public function update_status(OrderEvent $event)
{
if ($event->getOrder()->getDeliveryModuleId() === LocalPickup::getModCode()) {
if ($event->getOrder()->isSent()) {
$contact_email = ConfigQuery::read('store_email');
if ($contact_email) {
$message = MessageQuery::create()->filterByName('order_confirmation_localpickup')->findOne();
if (false === $message) {
throw new \Exception("Failed to load message 'order_confirmation_localpickup'.");
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$store = ConfigQuery::create();
$country = CountryQuery::create()->findPk($store->read("store_country"));
$country = CountryI18nQuery::create()->filterById($country->getId())->findOneByLocale($order->getLang()->getLocale())->getTitle();
$this->parser->assign('order_id', $order->getId());
$this->parser->assign('order_ref', $order->getRef());
$this->parser->assign('store_name', $store->read("store_name"));
$this->parser->assign('store_address1', $store->read("store_address1"));
$this->parser->assign('store_address2', $store->read("store_address2"));
$this->parser->assign('store_address3', $store->read("store_address3"));
$this->parser->assign('store_zipcode', $store->read("store_zipcode"));
$this->parser->assign('store_city', $store->read("store_city"));
$this->parser->assign('store_country', $country);
$message->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->getMailer()->send($instance);
}
}
}
}
示例6: parseResults
public function parseResults(LoopResult $loopResult)
{
$taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
$locale = $this->request->getSession()->getLang()->getLocale();
$checkAvailability = ConfigQuery::checkAvailableStock();
$defaultAvailability = intval(ConfigQuery::read('default-available-stock', 100));
foreach ($loopResult->getResultDataCollection() as $cartItem) {
$product = $cartItem->getProduct(null, $locale);
$productSaleElement = $cartItem->getProductSaleElements();
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ITEM_ID", $cartItem->getId());
$loopResultRow->set("TITLE", $product->getTitle());
$loopResultRow->set("REF", $product->getRef());
$loopResultRow->set("QUANTITY", $cartItem->getQuantity());
$loopResultRow->set("PRODUCT_ID", $product->getId());
$loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale()));
if (!$checkAvailability || $product->getVirtual() === 1) {
$loopResultRow->set("STOCK", $defaultAvailability);
} else {
$loopResultRow->set("STOCK", $productSaleElement->getQuantity());
}
$loopResultRow->set("PRICE", $cartItem->getPrice())->set("PROMO_PRICE", $cartItem->getPromoPrice())->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
$loopResultRow->set("PRODUCT_SALE_ELEMENTS_ID", $productSaleElement->getId());
$loopResultRow->set("PRODUCT_SALE_ELEMENTS_REF", $productSaleElement->getRef());
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
示例7: updateStatus
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
$Predict = new Predict();
if ($order->isSent() && $order->getDeliveryModuleId() == $Predict->getModuleModel()->getId()) {
$contact_email = ConfigQuery::read('store_email');
if ($contact_email) {
$message = MessageQuery::create()->filterByName('mail_predict')->findOne();
if (false === $message) {
throw new \Exception(Translator::getInstance()->trans("Failed to load message '%mail_tpl_name'.", ["%mail_tpl_name" => "mail_predict"], Predict::MESSAGE_DOMAIN));
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->parser->assign('customer_id', $customer->getId());
$this->parser->assign('order_ref', $order->getRef());
$this->parser->assign('order_date', $order->getCreatedAt());
$this->parser->assign('order_id', $order->getId());
$this->parser->assign('update_date', $order->getUpdatedAt());
$this->parser->assign('package', $order->getDeliveryRef());
$message->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->mailer->send($instance);
Tlog::getInstance()->debug("Predict shipping message sent to customer " . $customer->getEmail());
} else {
$customer = $order->getCustomer();
Tlog::getInstance()->debug("Predict shipping message no contact email customer_id", $customer->getId());
}
}
}
示例8: process
public function process()
{
$logger = Tlog::getInstance();
$logger->setLevel(Tlog::DEBUG);
$updatedVersions = array();
$currentVersion = ConfigQuery::read('thelia_version');
$logger->debug("start update process");
if (true === $this->isLatestVersion($currentVersion)) {
$logger->debug("You already have the latest version. No update available");
throw new UpToDateException('You already have the latest version. No update available');
}
$index = array_search($currentVersion, self::$version);
$con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction();
$logger->debug("begin transaction");
$database = new Database($con->getWrappedConnection());
try {
$size = count(self::$version);
for ($i = ++$index; $i < $size; $i++) {
$this->updateToVersion(self::$version[$i], $database, $logger);
$updatedVersions[] = self::$version[$i];
}
$con->commit();
$logger->debug('update successfully');
} catch (PropelException $e) {
$con->rollBack();
$logger->error(sprintf('error during update process with message : %s', $e->getMessage()));
throw $e;
}
$logger->debug('end of update processing');
return $updatedVersions;
}
示例9: testAction
public function testAction()
{
// Check current user authorization
if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::UPDATE))) {
return $response;
}
$contactEmail = ConfigQuery::read('store_email');
$storeName = ConfigQuery::read('store_name', 'Thelia');
$json_data = array("success" => false, "message" => "");
if ($contactEmail) {
$emailTest = $this->getRequest()->get("email", $contactEmail);
$message = $this->getTranslator()->trans("Email test from : %store%", array("%store%" => $storeName));
$htmlMessage = "<p>{$message}</p>";
$instance = \Swift_Message::newInstance()->addTo($emailTest, $storeName)->addFrom($contactEmail, $storeName)->setSubject($message)->setBody($message, 'text/plain')->setBody($htmlMessage, 'text/html');
try {
$this->getMailer()->send($instance);
$json_data["success"] = true;
$json_data["message"] = $this->getTranslator()->trans("Your configuration seems to be ok. Checked out your mailbox : %email%", array("%email%" => $emailTest));
} catch (\Exception $ex) {
$json_data["message"] = $ex->getMessage();
}
} else {
$json_data["message"] = $this->getTranslator()->trans("You have to configure your store email first !");
}
$response = JsonResponse::create($json_data);
return $response;
}
示例10: update_status
/**
* Checks if we are the payment module for the order, and if the order is paid,
* then send a confirmation email to the customer.
*
* @params OrderEvent $order
*/
public function update_status(OrderEvent $event)
{
$payzen = new Payzen();
if ($event->getOrder()->isPaid() && $payzen->isPaymentModuleFor($event->getOrder())) {
$contact_email = ConfigQuery::read('store_email', false);
Tlog::getInstance()->debug("Sending confirmation email from store contact e-mail {$contact_email}");
if ($contact_email) {
$message = MessageQuery::create()->filterByName(Payzen::CONFIRMATION_MESSAGE_NAME)->findOne();
if (false === $message) {
throw new \Exception(sprintf("Failed to load message '%s'.", Payzen::CONFIRMATION_MESSAGE_NAME));
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->parser->assign('order_id', $order->getId());
$this->parser->assign('order_ref', $order->getRef());
$message->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->getMailer()->send($instance);
Tlog::getInstance()->debug("Confirmation email sent to customer " . $customer->getEmail());
}
} else {
Tlog::getInstance()->debug("No confirmation email sent (order not paid, or not the proper payement module.");
}
}
示例11: getPostageAmount
/**
* @param $areaId
* @param $weight
*
* @return mixed
* @throws DeliveryException
*/
public static function getPostageAmount($areaId, $weight)
{
$freeshipping = @(bool) ConfigQuery::read("predict_freeshipping");
$postage = 0;
if (!$freeshipping) {
$prices = static::getPrices();
/* check if Predict delivers the asked area */
if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new DeliveryException("Predict delivery unavailable for the chosen delivery country");
}
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if ($weight > $maxWeight) {
throw new DeliveryException(sprintf("Predict delivery unavailable for this cart weight (%s kg)", $weight));
}
$postage = current($areaPrices);
while (prev($areaPrices)) {
if ($weight > key($areaPrices)) {
break;
}
$postage = current($areaPrices);
}
}
return $postage;
}
示例12: setUp
protected function setUp()
{
// We have to shut down the "One domain for each lang feature" before tests,
// to prevent 302 redirections during the tests.
$this->isMultiDomainActivated = ConfigQuery::read('one_domain_foreach_lang');
ConfigQuery::write('one_domain_foreach_lang', false);
}
示例13: processDocument
/**
* Process document and write the result in the document cache.
*
* When the original document is required, create either a symbolic link with the
* original document in the cache dir, or copy it in the cache dir if it's not already done.
*
* This method updates the cache_file_path and file_url attributes of the event
*
* @param DocumentEvent $event Event
*
* @throws \Thelia\Exception\DocumentException
* @throws \InvalidArgumentException , DocumentException
*/
public function processDocument(DocumentEvent $event)
{
$subdir = $event->getCacheSubdirectory();
$sourceFile = $event->getSourceFilepath();
if (null == $subdir || null == $sourceFile) {
throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null");
}
$originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true);
if (!file_exists($originalDocumentPathInCache)) {
if (!file_exists($sourceFile)) {
throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile));
}
$mode = ConfigQuery::read('original_document_delivery_mode', 'symlink');
if ($mode == 'symlink') {
if (false == symlink($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir));
}
} else {
// mode = 'copy'
if (false == @copy($sourceFile, $originalDocumentPathInCache)) {
throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir));
}
}
}
// Compute the document URL
$documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache));
// Update the event with file path and file URL
$event->setDocumentPath($documentUrl);
$event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE));
}
示例14: updateStatus
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
$socolissimo = new SoColissimo();
if ($order->isSent() && $order->getDeliveryModuleId() == $socolissimo->getModuleModel()->getId()) {
$contact_email = ConfigQuery::read('store_email');
if ($contact_email) {
$message = MessageQuery::create()->filterByName('mail_socolissimo')->findOne();
if (false === $message) {
throw new \Exception("Failed to load message 'order_confirmation'.");
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->parser->assign('customer_id', $customer->getId());
$this->parser->assign('order_ref', $order->getRef());
$this->parser->assign('order_date', $order->getCreatedAt());
$this->parser->assign('update_date', $order->getUpdatedAt());
$this->parser->assign('package', $order->getDeliveryRef());
$message->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->mailer->send($instance);
}
}
}
示例15: doRequest
public function doRequest(GetResponseEvent $event)
{
if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
return;
}
$prefix = ConfigQuery::read("back_office_path");
$defaultEnabled = intval(ConfigQuery::read("back_office_path_default_enabled", "1"));
$pathInfo = $event->getRequest()->getPathInfo();
$url = $event->getRequest()->server->get('REQUEST_URI');
// Discard the default /admin URL
$isValid = 1 !== $defaultEnabled && strpos($pathInfo, '/' . BackOfficePath::DEFAULT_THELIA_PREFIX) === 0 && $prefix !== null && $prefix !== "";
if ($isValid) {
/** @var \Symfony\Component\Routing\RequestContext $context */
$context = $event->getKernel()->getContainer()->get('request.context');
$context->fromRequest($event->getRequest());
throw new NotFoundHttpException();
}
// Check if the URL is an backOffice URL
$isValid = strpos($pathInfo, '/' . $prefix) === 0 && $prefix !== null && $prefix !== "";
if ($isValid) {
$newUrl = $this->replaceUrl($url, $prefix, BackOfficePath::DEFAULT_THELIA_PREFIX);
$event->getRequest()->server->set('REQUEST_URI', $newUrl);
$event->getRequest()->initialize($event->getRequest()->query->all(), $event->getRequest()->request->all(), $event->getRequest()->attributes->all(), $event->getRequest()->cookies->all(), $event->getRequest()->files->all(), $event->getRequest()->server->all(), $event->getRequest()->getContent());
}
}