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


PHP Model\AddressQuery类代码示例

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


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

示例1: testRenderLoop

 public function testRenderLoop()
 {
     $customerId = CustomerQuery::create()->findOne()->getId();
     $this->handler->expects($this->any())->method("buildDataSet")->willReturn($this->handler->renderLoop("address", ["customer" => $customerId]));
     $lang = Lang::getDefaultLanguage();
     $loop = $this->handler->buildDataSet($lang);
     $this->assertInstanceOf("Thelia\\Core\\Template\\Loop\\Address", $loop);
     $data = $this->handler->buildData($lang);
     $addresses = AddressQuery::create()->filterByCustomerId($customerId)->find()->toArray("Id");
     foreach ($data->getData() as $row) {
         $this->assertArrayHasKey("id", $row);
         $this->assertArrayHasKey($row["id"], $addresses);
         $this->assertEquals(count($addresses), $row["loop_total"]);
         $address = $addresses[$row["id"]];
         $this->assertEquals($row["address1"], $address["Address1"]);
         $this->assertEquals($row["address2"], $address["Address2"]);
         $this->assertEquals($row["address3"], $address["Address3"]);
         $this->assertEquals($row["cellphone"], $address["Cellphone"]);
         $this->assertEquals($row["city"], $address["City"]);
         $this->assertEquals($row["company"], $address["Company"]);
         $this->assertEquals($row["country"], $address["CountryId"]);
         $this->assertEquals($row["create_date"], $address["CreatedAt"]);
         $this->assertEquals($row["update_date"], $address["UpdatedAt"]);
         $this->assertEquals($row["firstname"], $address["Firstname"]);
         $this->assertEquals($row["lastname"], $address["Lastname"]);
         $this->assertEquals($row["id"], $address["Id"]);
         $this->assertEquals($row["label"], $address["Label"]);
         $this->assertEquals($row["phone"], $address["Phone"]);
         $this->assertEquals($row["title"], $address["TitleId"]);
         $this->assertEquals($row["zipcode"], $address["Zipcode"]);
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:32,代码来源:ExportHandlerTest.php

示例2: buildModelCriteria

 public function buildModelCriteria()
 {
     $search = AddressQuery::create();
     $id = $this->getId();
     if (null !== $id && !in_array($id, array('*', 'any'))) {
         $search->filterById($id, Criteria::IN);
     }
     $customer = $this->getCustomer();
     if ($customer === 'current') {
         $currentCustomer = $this->securityContext->getCustomerUser();
         if ($currentCustomer === null) {
             return null;
         } else {
             $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
         }
     } else {
         $search->filterByCustomerId($customer, Criteria::EQUAL);
     }
     $default = $this->getDefault();
     if ($default === true) {
         $search->filterByIsDefault(1, Criteria::EQUAL);
     } elseif ($default === false) {
         $search->filterByIsDefault(0, Criteria::EQUAL);
     }
     $exclude = $this->getExclude();
     if (null !== $exclude && 'none' !== $exclude) {
         $search->filterById($exclude, Criteria::NOT_IN);
     }
     return $search;
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:30,代码来源:Address.php

示例3: 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

示例4: 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;
 }
开发者ID:bcbrr,项目名称:SoColissimo,代码行数:39,代码来源:GetRelais.php

示例5: testFormatAddress

 public function testFormatAddress()
 {
     // Test for address in France
     $countryFR = CountryQuery::create()->filterByIsoalpha2('FR')->findOne();
     $address = AddressQuery::create()->findOne();
     $address->setCountryId($countryFR->getId())->save();
     $data = $this->renderString('{format_address address=$address locale="fr_FR"}', ['address' => $address->getId()]);
     $title = $address->getCustomerTitle()->setLocale('fr_FR')->getShort();
     $expected = ['<p >', sprintf('<span class="recipient">%s %s %s</span><br>', $title, $address->getLastname(), $address->getFirstname()), sprintf('<span class="address-line1">%s</span><br>', $address->getAddress1()), sprintf('<span class="postal-code">%s</span> <span class="locality">%s</span><br>', $address->getZipcode(), $address->getCity()), '<span class="country">France</span>', '</p>'];
     $this->assertEquals($data, implode("\n", $expected));
     // Test for address in USA
     $stateDC = StateQuery::create()->filterByIsocode('DC')->findOne();
     $countryUS = $stateDC->getCountry();
     $address->setCountryId($countryUS->getId())->setStateId($stateDC->getId())->save();
     $data = $this->renderString('{format_address address=$address locale="en_US"}', ['address' => $address->getId()]);
     $title = $address->getCustomerTitle()->setLocale('en_US')->getShort();
     $expected = ['<p >', sprintf('<span class="recipient">%s %s %s</span><br>', $title, $address->getLastname(), $address->getFirstname()), sprintf('<span class="address-line1">%s</span><br>', $address->getAddress1()), sprintf('<span class="locality">%s</span>, <span class="administrative-area">%s</span> <span class="postal-code">%s</span><br>', $address->getCity(), $stateDC->getIsocode(), $address->getZipcode()), '<span class="country">United States</span>', '</p>'];
     $this->assertEquals($data, implode("\n", $expected));
     // Test html tag
     $data = $this->renderString('{format_address html_tag="address" html_class="a_class" html_id="an_id" address=$address}', ['address' => $address->getId()]);
     $this->assertTrue(strpos($data, '<address class="a_class" id="an_id">') !== false);
     // Test plain text
     $data = $this->renderString('{format_address html="0" address=$address locale="en_US"}', ['address' => $address->getId()]);
     $expected = [sprintf('%s %s %s', $title, $address->getLastname(), $address->getFirstname()), sprintf('%s', $address->getAddress1()), sprintf('%s, %s %s', $address->getCity(), $stateDC->getIsocode(), $address->getZipcode()), 'United States'];
     $this->assertEquals($data, implode("\n", $expected));
 }
开发者ID:GuiminZHOU,项目名称:thelia,代码行数:26,代码来源:FormatTest.php

示例6: verifyDeliveryAddress

 public function verifyDeliveryAddress($value, ExecutionContextInterface $context)
 {
     $address = AddressQuery::create()->findPk($value);
     if (null === $address) {
         $context->addViolation(Translator::getInstance()->trans("Address ID not found"));
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:OrderDelivery.php

示例7: isModuleDpdPickup

 public function isModuleDpdPickup(OrderEvent $event)
 {
     $address = AddressIcirelaisQuery::create()->findPk($event->getDeliveryAddress());
     if ($this->check_module($event->getDeliveryModule())) {
         //tmp solution
         $request = $this->getRequest();
         $pr_code = $request->request->get('pr_code');
         if (!empty($pr_code)) {
             // Get details w/ SOAP
             $con = new \SoapClient(__DIR__ . "/../Config/exapaq.wsdl", array('soap_version' => SOAP_1_2));
             $response = $con->GetPudoDetails(array("pudo_id" => $pr_code));
             $xml = new \SimpleXMLElement($response->GetPudoDetailsResult->any);
             if (isset($xml->ERROR)) {
                 throw new \ErrorException("Error while choosing pick-up & go store: " . $xml->ERROR);
             }
             $customer_name = AddressQuery::create()->findPk($event->getDeliveryAddress());
             $request->getSession()->set('DpdPickupDeliveryId', $event->getDeliveryAddress());
             if ($address === null) {
                 $address = new AddressIcirelais();
                 $address->setId($event->getDeliveryAddress());
             }
             // France Métropolitaine
             $address->setCode($pr_code)->setCompany((string) $xml->PUDO_ITEMS->PUDO_ITEM->NAME)->setAddress1((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS1)->setAddress2((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS2)->setAddress3((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS3)->setZipcode((string) $xml->PUDO_ITEMS->PUDO_ITEM->ZIPCODE)->setCity((string) $xml->PUDO_ITEMS->PUDO_ITEM->CITY)->setFirstname($customer_name->getFirstname())->setLastname($customer_name->getLastname())->setTitleId($customer_name->getTitleId())->setCountryId($customer_name->getCountryId())->save();
         } else {
             throw new \ErrorException("No pick-up & go store chosen for DpdPickup delivery module");
         }
     } elseif (null !== $address) {
         $address->delete();
     }
 }
开发者ID:lopes-vincent,项目名称:DpdPickup,代码行数:30,代码来源:SetDeliveryModule.php

示例8: getDeliveryAddress

 /**
  * Return an Address a CouponManager can process
  *
  * @return \Thelia\Model\Address
  */
 public function getDeliveryAddress()
 {
     try {
         return AddressQuery::create()->findPk($this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress());
     } catch (\Exception $ex) {
         throw new \LogicException("Failed to get delivery address (" . $ex->getMessage() . ")");
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:13,代码来源:BaseFacade.php

示例9: consumeAction

 /**
  * Coupon consuming
  */
 public function consumeAction()
 {
     $this->checkCartNotEmpty();
     $message = false;
     $couponCodeForm = $this->createForm(FrontForm::COUPON_CONSUME);
     try {
         $form = $this->validateForm($couponCodeForm, 'post');
         $couponCode = $form->get('coupon-code')->getData();
         if (null === $couponCode || empty($couponCode)) {
             $message = true;
             throw new \Exception($this->getTranslator()->trans('Coupon code can\'t be empty', [], Front::MESSAGE_DOMAIN));
         }
         $couponConsumeEvent = new CouponConsumeEvent($couponCode);
         // Dispatch Event to the Action
         $this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
         /* recalculate postage amount */
         $order = $this->getSession()->getOrder();
         if (null !== $order) {
             $deliveryModule = $order->getModuleRelatedByDeliveryModuleId();
             $deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
             if (null !== $deliveryModule && null !== $deliveryAddress) {
                 $moduleInstance = $deliveryModule->getDeliveryModuleInstance($this->container);
                 $orderEvent = new OrderEvent($order);
                 try {
                     $postage = OrderPostage::loadFromPostage($moduleInstance->getPostage($deliveryAddress->getCountry()));
                     $orderEvent->setPostage($postage->getAmount());
                     $orderEvent->setPostageTax($postage->getAmountTax());
                     $orderEvent->setPostageTaxRuleTitle($postage->getTaxRuleTitle());
                     $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
                 } catch (DeliveryException $ex) {
                     // The postage has been chosen, but changes dues to coupon causes an exception.
                     // Reset the postage data in the order
                     $orderEvent->setDeliveryModule(0);
                     $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
                 }
             }
         }
         return $this->generateSuccessRedirect($couponCodeForm);
     } catch (FormValidationException $e) {
         $message = $this->getTranslator()->trans('Please check your coupon code: %message', ["%message" => $e->getMessage()], Front::MESSAGE_DOMAIN);
     } catch (UnmatchableConditionException $e) {
         $message = $this->getTranslator()->trans('You should <a href="%sign">sign in</a> or <a href="%register">register</a> to use this coupon', ['%sign' => $this->retrieveUrlFromRouteId('customer.login.view'), '%register' => $this->retrieveUrlFromRouteId('customer.create.view')], Front::MESSAGE_DOMAIN);
     } catch (PropelException $e) {
         $this->getParserContext()->setGeneralError($e->getMessage());
     } catch (\Exception $e) {
         $message = $this->getTranslator()->trans('Sorry, an error occurred: %message', ["%message" => $e->getMessage()], Front::MESSAGE_DOMAIN);
     }
     if ($message !== false) {
         Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
         $couponCodeForm->setErrorMessage($message);
         $this->getParserContext()->addForm($couponCodeForm)->setGeneralError($message);
     }
     return $this->generateErrorRedirect($couponCodeForm);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:57,代码来源:CouponController.php

示例10: buildArray

 /**
  * this method returns an array
  *
  * @return array
  */
 public function buildArray()
 {
     $id = $this->getId();
     /** @var \Thelia\Core\HttpFoundation\Session\Session $session */
     $session = $this->container->get('request')->getSession();
     $address = AddressQuery::create()->filterByCustomerId($session->getCustomerUser()->getId())->findPk($id);
     if ($address === null) {
         throw new Exception("The requested address doesn't exist");
     }
     /** @var \Thelia\Model\Customer $customer */
     $customer = $session->getCustomerUser();
     return array('Id' => '0', 'Label' => $address->getLabel(), 'CustomerId' => $address->getCustomerId(), 'TitleId' => $address->getTitleId(), 'Company' => ConfigQuery::read('store_name'), 'Firstname' => $customer->getFirstname(), 'Lastname' => $customer->getLastname(), 'Address1' => ConfigQuery::read('store_address1'), 'Address2' => ConfigQuery::read('store_address2'), 'Address3' => ConfigQuery::read('store_address3'), 'Zipcode' => ConfigQuery::read('store_zipcode'), 'City' => ConfigQuery::read('store_city'), 'CountryId' => ConfigQuery::read('store_country'), 'Phone' => $address->getPhone(), 'Cellphone' => $address->getCellphone(), 'IsDefault' => '0');
 }
开发者ID:bcbrr,项目名称:LocalPickup,代码行数:18,代码来源:LocalAddress.php

示例11: migrateAddress

 protected function migrateAddress(MigrateCountryEvent $event)
 {
     $con = Propel::getWriteConnection(AddressTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         $updatedRows = AddressQuery::create()->filterByCountryId($event->getCountry())->update(['CountryId' => $event->getNewCountry(), 'StateId' => $event->getNewState()]);
         $con->commit();
         return $updatedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:13,代码来源:MigrateCountryListener.php

示例12: checkValidDeliveryFunction

 public function checkValidDeliveryFunction($params, &$smarty)
 {
     $order = $this->request->getSession()->getOrder();
     /* Does address and module still exists ? We assume address owner can't change neither module type */
     if ($order !== null) {
         $checkAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
         $checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId());
     }
     if (null === $order || null == $checkAddress || null === $checkModule) {
         throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1));
     }
     return "";
 }
开发者ID:alex63530,项目名称:thelia,代码行数:13,代码来源:Security.php

示例13: consumeAction

 /**
  * Coupon consuming
  */
 public function consumeAction()
 {
     $this->checkAuth();
     $this->checkCartNotEmpty();
     $message = false;
     $couponCodeForm = new CouponCode($this->getRequest());
     try {
         $form = $this->validateForm($couponCodeForm, 'post');
         $couponCode = $form->get('coupon-code')->getData();
         if (null === $couponCode || empty($couponCode)) {
             $message = true;
             throw new \Exception('Coupon code can\'t be empty');
         }
         $couponConsumeEvent = new CouponConsumeEvent($couponCode);
         // Dispatch Event to the Action
         $this->getDispatcher()->dispatch(TheliaEvents::COUPON_CONSUME, $couponConsumeEvent);
         /* recalculate postage amount */
         $order = $this->getSession()->getOrder();
         if (null !== $order) {
             $deliveryModule = $order->getModuleRelatedByDeliveryModuleId();
             $deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
             if (null !== $deliveryModule && null !== $deliveryAddress) {
                 $moduleInstance = $deliveryModule->getModuleInstance($this->container);
                 $orderEvent = new OrderEvent($order);
                 try {
                     $postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
                     $orderEvent->setPostage($postage);
                     $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_POSTAGE, $orderEvent);
                 } catch (DeliveryException $ex) {
                     // The postage has been chosen, but changes dues to coupon causes an exception.
                     // Reset the postage data in the order
                     $orderEvent->setDeliveryModule(0);
                     $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
                 }
             }
         }
         return $this->generateSuccessRedirect($couponCodeForm);
     } catch (FormValidationException $e) {
         $message = sprintf('Please check your coupon code: %s', $e->getMessage());
     } catch (PropelException $e) {
         $this->getParserContext()->setGeneralError($e->getMessage());
     } catch (\Exception $e) {
         $message = sprintf('Sorry, an error occurred: %s', $e->getMessage());
     }
     if ($message !== false) {
         Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
         $couponCodeForm->setErrorMessage($message);
         $this->getParserContext()->addForm($couponCodeForm)->setGeneralError($message);
     }
 }
开发者ID:alex63530,项目名称:thelia,代码行数:53,代码来源:CouponController.php

示例14: preImport

 public function preImport()
 {
     // Empty address, customer and customer title table
     OrderQuery::create()->deleteAll();
     AddressQuery::create()->deleteAll();
     OrderAddressQuery::create()->deleteAll();
     CustomerQuery::create()->deleteAll();
     // Also empty url rewriting table
     $con = Propel::getConnection(RewritingUrlTableMap::DATABASE_NAME);
     $con->exec('SET FOREIGN_KEY_CHECKS=0');
     RewritingUrlQuery::create()->deleteAll();
     $con->exec('SET FOREIGN_KEY_CHECKS=1');
     $this->cust_corresp->reset();
     if ($this->thelia_version > 150) {
         $this->importCustomerTitle();
     }
 }
开发者ID:JumBay,项目名称:ImportT1,代码行数:17,代码来源:CustomersImport.php

示例15: buildModelCriteria

 public function buildModelCriteria()
 {
     $zipcode = $this->getZipcode();
     $city = $this->getCity();
     if (!empty($zipcode) and !empty($city)) {
         $this->zipcode = $zipcode;
         $this->city = $city;
         $this->addressflag = false;
     } else {
         $search = AddressQuery::create();
         $customer = $this->securityContext->getCustomerUser();
         if ($customer !== null) {
             $search->filterByCustomerId($customer->getId());
             $search->filterByIsDefault("1");
         } else {
             throw new \ErrorException("Customer not connected.");
         }
         return $search;
     }
 }
开发者ID:lopes-vincent,项目名称:DpdPickup,代码行数:20,代码来源:DpdPickupAround.php


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