本文整理汇总了PHP中Thelia\Model\CountryQuery::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CountryQuery::create方法的具体用法?PHP CountryQuery::create怎么用?PHP CountryQuery::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\CountryQuery
的用法示例。
在下文中一共展示了CountryQuery::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildModelCriteria
public function buildModelCriteria()
{
$search = CountryQuery::create();
/* manage translations */
$this->configureI18nProcessing($search);
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$area = $this->getArea();
if (null !== $area) {
$search->filterByAreaId($area, Criteria::IN);
}
$withArea = $this->getWith_area();
if (true === $withArea) {
$search->filterByAreaId(null, Criteria::ISNOTNULL);
} elseif (false === $withArea) {
$search->filterByAreaId(null, Criteria::ISNULL);
}
$exclude = $this->getExclude();
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
$search->addAscendingOrderByColumn('i18n_TITLE');
return $search;
}
示例2: buildModelCriteria
public function buildModelCriteria()
{
$search = CountryQuery::create();
/* manage translations */
$this->configureI18nProcessing($search);
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$area = $this->getArea();
if (null !== $area) {
$search->useCountryAreaQuery('with_area')->filterByAreaId($area, Criteria::IN)->endUse();
}
$excludeArea = $this->getExcludeArea();
if (null !== $excludeArea) {
// FIXME : did not find a way to do this in a single request :(
// select * from country where id not in (select country_id from country_area where area in (...))
$countries = CountryAreaQuery::create()->filterByAreaId($excludeArea, Criteria::IN)->select(['country_id'])->find();
$search->filterById($countries->toArray(), Criteria::NOT_IN);
}
$withArea = $this->getWithArea();
if (true === $withArea) {
$search->joinCountryArea('with_area', Criteria::LEFT_JOIN)->where('`with_area`.country_id ' . Criteria::ISNOTNULL);
} elseif (false === $withArea) {
$search->joinCountryArea('with_area', Criteria::LEFT_JOIN)->where('`with_area`.country_id ' . Criteria::ISNULL);
}
$exclude = $this->getExclude();
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
$search->addAscendingOrderByColumn('i18n_TITLE');
return $search;
}
示例3: generateFacadeStub
/**
* Generate adapter stub
*
* @param int $cartTotalPrice Cart total price
* @param string $checkoutCurrency Checkout currency
* @param string $i18nOutput Output from each translation
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
public function generateFacadeStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR', $i18nOutput = '')
{
$stubFacade = $this->getMockBuilder('\\Thelia\\Coupon\\BaseFacade')->disableOriginalConstructor()->getMock();
$currencies = CurrencyQuery::create();
$currencies = $currencies->find();
$stubFacade->expects($this->any())->method('getAvailableCurrencies')->will($this->returnValue($currencies));
$stubFacade->expects($this->any())->method('getCartTotalPrice')->will($this->returnValue($cartTotalPrice));
$stubFacade->expects($this->any())->method('getCheckoutCurrency')->will($this->returnValue($checkoutCurrency));
$stubFacade->expects($this->any())->method('getConditionEvaluator')->will($this->returnValue(new ConditionEvaluator()));
$stubTranslator = $this->getMockBuilder('\\Thelia\\Core\\Translation\\Translator')->disableOriginalConstructor()->getMock();
$stubTranslator->expects($this->any())->method('trans')->will($this->returnValue($i18nOutput));
$stubFacade->expects($this->any())->method('getTranslator')->will($this->returnValue($stubTranslator));
$stubDispatcher = $this->getMockBuilder('\\Symfony\\Component\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
$stubDispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($dummy, $cartEvent) {
$ci = new CartItem();
$ci->setId(3)->setPrice(123)->setPromo(0)->setProductId($this->freeProduct->getId());
$cartEvent->setCartItem($ci);
}));
$stubFacade->expects($this->any())->method('getDispatcher')->will($this->returnValue($stubDispatcher));
$stubSession = $this->getMockBuilder('\\Thelia\\Core\\HttpFoundation\\Session\\Session')->disableOriginalConstructor()->getMock();
$stubSession->expects($this->any())->method('get')->will($this->onConsecutiveCalls(-1, 3));
$stubRequest = $this->getMockBuilder('\\Thelia\\Core\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
$stubRequest->expects($this->any())->method('getSession')->will($this->returnValue($stubSession));
$stubFacade->expects($this->any())->method('getRequest')->will($this->returnValue($stubRequest));
$country = CountryQuery::create()->findOneByByDefault(1);
$stubFacade->expects($this->any())->method('getDeliveryCountry')->will($this->returnValue($country));
return $stubFacade;
}
示例4: toggleDefault
public function toggleDefault(CountryToggleDefaultEvent $event)
{
if (null !== ($country = CountryQuery::create()->findPk($event->getCountryId()))) {
$country->toggleDefault();
$event->setCountry($country);
}
}
示例5: verifyCountry
public function verifyCountry($value, ExecutionContextInterface $context)
{
$address = CountryQuery::create()->findPk($value);
if (null === $address) {
$context->addViolation(Translator::getInstance()->trans("Country ID not found"));
}
}
示例6: 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));
}
示例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: migrateSystemAction
public function migrateSystemAction()
{
$response = $this->checkAuth(AdminResources::COUNTRY, array(), AccessManager::UPDATE);
if (null !== $response) {
return $response;
}
// load country not migrated
$dataForm = [];
$migratedCountries = json_decode(ConfigQuery::read('thelia_country_state_migration', '[]'), true);
$countries = CountryQuery::create()->filterByHasStates(1);
/** @var Country $country */
foreach ($countries as $country) {
$oldCountries = CountryQuery::create()->filterByHasStates(0)->filterByIsocode($country->getIsoCode())->find();
/** @var Country $oldCountry */
foreach ($oldCountries as $oldCountry) {
if (!isset($migratedCountries[$oldCountry->getId()])) {
$dataForm[] = ['migrate' => false, 'country' => $oldCountry->getId(), 'new_country' => $country->getId(), 'new_state' => null];
}
}
}
// prepare form
$form = $this->createForm('thelia.admin.country.state.migration', 'form', ['migrations' => $dataForm]);
$this->getParserContext()->addForm($form);
return $this->render('countries-migrate', ['countriesMigrated' => $migratedCountries, 'showForm' => count($dataForm) != 0]);
}
示例9: removeCountry
public function removeCountry(AreaRemoveCountryEvent $event)
{
if (null !== ($country = CountryQuery::create()->findPk($event->getCountryId()))) {
$event->setArea($country->getArea());
$country->setDispatcher($event->getDispatcher());
$country->setAreaId(null)->save();
}
}
示例10: buildForm
protected function buildForm()
{
$countryList = array();
foreach (CountryQuery::create()->find() as $country) {
$countryList[$country->getId()] = $country->getId();
}
$this->formBuilder->add("id", "hidden", array("required" => true, "constraints" => array(new Constraints\NotBlank(), new Constraints\Callback(array("methods" => array(array($this, "verifyTaxRuleId")))))))->add("tax_list", "hidden", array("required" => true, "attr" => array("id" => 'tax_list'), "constraints" => array(new Constraints\Callback(array("methods" => array(array($this, "verifyTaxList")))))))->add("country_list", "choice", array("choices" => $countryList, "required" => true, "multiple" => true, "constraints" => array(new Constraints\NotBlank())));
}
示例11: getDeliveryOrderCountry
/**
* @return array|mixed|\Thelia\Model\Country
* @throws \UnexpectedValueException
*/
public function getDeliveryOrderCountry()
{
$country_id = $this->getDeliveryOrderAddress()->getCountryId();
$country = CountryQuery::create()->findPK($country_id);
if ($country === null) {
throw new \UnexpectedValueException("The country doesn't exist");
}
return $country;
}
示例12: testRemoveCountry
/**
* @param AreaModel $area
* @depends testAddCountry
* @return AreaModel
*/
public function testRemoveCountry(AreaModel $area)
{
$country = CountryQuery::create()->filterByArea($area)->find()->getFirst();
$event = new AreaRemoveCountryEvent($area->getId(), $country->getId());
$areaAction = new Area();
$areaAction->removeCountry($event);
$updatedCountry = CountryAreaQuery::create()->filterByCountryId($country->getId())->filterByStateId(null)->filterByAreaId($area->getId())->findOne();
$updatedArea = $event->getArea();
$this->assertInstanceOf('Thelia\\Model\\Area', $updatedArea);
$this->assertNull($updatedCountry);
return $event->getArea();
}
示例13: socolissimoDeliveryPrice
public function socolissimoDeliveryPrice($params, $smarty)
{
$deliveryMode = $params["delivery-mode"];
$country = CountryQuery::create()->findOneById($params["country"]);
$cartWeight = $this->request->getSession()->getSessionCart($this->dispatcher)->getWeight();
$cartAmount = $this->request->getSession()->getSessionCart($this->dispatcher)->getTaxedAmount($country);
try {
$price = SoColissimo::getPostageAmount($country->getAreaId(), $cartWeight, $cartAmount, $deliveryMode);
} catch (DeliveryException $ex) {
$smarty->assign('isValidMode', false);
}
$smarty->assign('deliveryModePrice', $price);
}
示例14: testRemoveCountry
/**
* @param AreaModel $area
* @depends testAddCountry
*/
public function testRemoveCountry(AreaModel $area)
{
$country = CountryQuery::create()->filterByArea($area)->find()->getFirst();
$event = new AreaRemoveCountryEvent($area->getId(), $country->getId());
$event->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface"));
$areaAction = new Area();
$areaAction->removeCountry($event);
$updatedCountry = CountryQuery::create()->findPk($country->getId());
$updatedArea = $event->getArea();
$this->assertInstanceOf('Thelia\\Model\\Area', $updatedArea);
$this->assertNull($updatedCountry->getAreaId());
return $event->getArea();
}
示例15: getSummary
/**
* @inheritdoc
*/
public function getSummary()
{
$i18nOperator = Operators::getI18n($this->translator, $this->operators[self::COUNTRIES_LIST]);
$cntryStrList = '';
$cntryIds = $this->values[self::COUNTRIES_LIST];
if (null !== ($cntryList = CountryQuery::create()->findPks($cntryIds))) {
/** @var Country $cntry */
foreach ($cntryList as $cntry) {
$cntryStrList .= $cntry->getTitle() . ', ';
}
$cntryStrList = rtrim($cntryStrList, ', ');
}
return $this->getSummaryLabel($cntryStrList, $i18nOperator);
}