本文整理汇总了PHP中Thelia\Model\ConfigQuery类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery类的具体用法?PHP ConfigQuery怎么用?PHP ConfigQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: buildArray
/**
* this method returns an array ***Thanks cap'tain obvious \(^.^)/***
*->
* @return array
*/
public function buildArray()
{
// Find the address ... To find ! \m/
$zipcode = $this->getZipcode();
$city = $this->getCity();
$address = $this->getAddress();
$address = array("zipcode" => $zipcode, "city" => $city, "address" => "", "countrycode" => "FR");
if (empty($zipcode) || empty($city)) {
$search = AddressQuery::create();
$customer = $this->securityContext->getCustomerUser();
if ($customer !== null) {
$search->filterByCustomerId($customer->getId());
$search->filterByIsDefault("1");
} else {
throw new \ErrorException("Customer not connected.");
}
$search = $search->findOne();
$address["zipcode"] = $search->getZipcode();
$address["city"] = $search->getCity();
$address["address"] = $search->getAddress1();
$address["countrycode"] = $search->getCountry()->getIsoalpha2();
}
// Then ask the Web Service
$request = new FindByAddress();
$request->setAddress($address["address"])->setZipCode($address["zipcode"])->setCity($address["city"])->setCountryCode($address["countrycode"])->setFilterRelay("1")->setRequestId(md5(microtime()))->setLang("FR")->setOptionInter("1")->setShippingDate(date("d/m/Y"))->setAccountNumber(ConfigQuery::read('socolissimo_login'))->setPassword(ConfigQuery::read('socolissimo_pwd'));
try {
$response = $request->exec();
} catch (InvalidArgumentException $e) {
$response = array();
} catch (\SoapFault $e) {
$response = array();
}
return $response;
}
示例3: createOrUpdate
/**
* @param int $titleId customer title id (from customer_title table)
* @param string $firstname customer first name
* @param string $lastname customer last name
* @param string $address1 customer address
* @param string $address2 customer adress complement 1
* @param string $address3 customer adress complement 2
* @param string $phone customer phone number
* @param string $cellphone customer cellphone number
* @param string $zipcode customer zipcode
* @param string $city
* @param int $countryId customer country id (from Country table)
* @param string $email customer email, must be unique
* @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password
* @param string $lang
* @param int $reseller
* @param null $sponsor
* @param int $discount
* @param null $company
* @param null $ref
* @param bool $forceEmailUpdate true if the email address could be updated.
* @param int $stateId customer state id (from State table)
* @throws \Exception
* @throws \Propel\Runtime\Exception\PropelException
*/
public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email = null, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0, $company = null, $ref = null, $forceEmailUpdate = false, $stateId = null)
{
$this->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setEmail($email, $forceEmailUpdate)->setPassword($plainPassword)->setReseller($reseller)->setSponsor($sponsor)->setDiscount($discount)->setRef($ref);
if (!is_null($lang)) {
$this->setLangId($lang);
}
$con = Propel::getWriteConnection(CustomerTableMap::DATABASE_NAME);
$con->beginTransaction();
try {
if ($this->isNew()) {
$address = new Address();
$address->setLabel(Translator::getInstance()->trans("Main address"))->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->setIsDefault(1);
$this->addAddress($address);
if (ConfigQuery::isCustomerEmailConfirmationEnable()) {
$this->setConfirmationToken(bin2hex(random_bytes(32)));
}
} else {
$address = $this->getDefaultAddress();
$address->setCompany($company)->setTitleId($titleId)->setFirstname($firstname)->setLastname($lastname)->setAddress1($address1)->setAddress2($address2)->setAddress3($address3)->setPhone($phone)->setCellphone($cellphone)->setZipcode($zipcode)->setCity($city)->setCountryId($countryId)->setStateId($stateId)->save($con);
}
$this->save($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
示例4: getAuthentifiedUser
/**
* @see \Thelia\Core\Security\Authentication\AuthenticatorInterface::getAuthentifiedUser()
*/
public function getAuthentifiedUser()
{
if ($this->request->isMethod($this->options['required_method'])) {
if (!$this->loginForm->isValid()) {
throw new ValidatorException("Form is not valid.");
}
// Retreive user
$username = $this->getUsername();
$password = $this->loginForm->get($this->options['password_field_name'])->getData();
$user = $this->userProvider->getUser($username);
if ($user === null) {
throw new UsernameNotFoundException(sprintf("Username '%s' was not found.", $username));
}
// Check user password
$authOk = $user->checkPassword($password) === true;
if ($authOk !== true) {
throw new WrongPasswordException(sprintf("Wrong password for user '%s'.", $username));
}
if (ConfigQuery::isCustomerEmailConfirmationEnable() && $user instanceof Customer) {
// Customer (confirmation_token & enable) introduces since Thelia 2.4
// this test prevent backward compatibility and if option is enable when customer has been created
if ($user->getConfirmationToken() !== null && !$user->getEnable()) {
throw (new CustomerNotConfirmedException())->setUser($user);
}
}
return $user;
}
throw new \RuntimeException("Invalid method.");
}
示例5: update_status
public function update_status(OrderEvent $event)
{
if ($event->getOrder()->getDeliveryModuleId() === DpdClassic::getModuleId()) {
if ($event->getOrder()->getStatusId() === DpdClassic::STATUS_SENT) {
$contact_email = ConfigQuery::read('store_email');
if ($contact_email) {
$message = MessageQuery::create()->filterByName('order_confirmation_dpdclassic')->findOne();
if (false === $message) {
throw new \Exception("Failed to load message 'order_confirmation_dpdclassic'.");
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->parser->assign('order_id', $order->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->getMailer()->send($instance);
}
}
}
}
示例6: 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;
}
示例7: 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);
}
}
}
}
示例8: __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);
}
示例9: onMainHeadBottom
public function onMainHeadBottom(HookRenderEvent $event)
{
$value = trim(ConfigQuery::read("hookanalytics_trackingcode", ""));
if ("" != $value) {
$event->add($value);
}
}
示例10: 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']);
}
}
示例11: 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);
}
}
}
}
示例12: 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"]);
}
示例13: loadStatsAjaxAction
public function loadStatsAjaxAction()
{
if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW))) {
return $response;
}
$cacheExpire = ConfigQuery::getAdminCacheHomeStatsTTL();
/** @var AdapterInterface $cacheAdapter */
$cacheAdapter = $this->container->get('thelia.cache');
$month = (int) $this->getRequest()->query->get('month', date('m'));
$year = (int) $this->getRequest()->query->get('year', date('Y'));
$cacheKey = self::STATS_CACHE_KEY . "_" . $month . "_" . $year;
$cacheItem = $cacheAdapter->getItem($cacheKey);
// force flush
if ($this->getRequest()->query->get('flush', "0")) {
$cacheAdapter->deleteItem($cacheItem);
}
if (!$cacheItem->isHit()) {
$data = $this->getStatus($month, $year);
$cacheItem->set(json_encode($data));
$cacheItem->expiresAfter($cacheExpire);
if ($cacheExpire) {
$cacheAdapter->save($cacheItem);
}
}
return $this->jsonResponse($cacheItem->get());
}
示例14: 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');
}
}
}
示例15: 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();
}
}