mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Initial fixes
This commit is contained in:
parent
a5b059506b
commit
54a909ab1c
22 changed files with 116 additions and 151 deletions
|
|
@ -74,7 +74,7 @@ class ChannelContext extends DefaultContext
|
|||
isset($data['shipping']) ? $data['shipping'] : null,
|
||||
isset($data['payments']) ? $data['payments'] : null,
|
||||
false
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\ChannelBundle\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
|
@ -35,7 +36,7 @@ class Configuration implements ConfigurationInterface
|
|||
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('driver')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
|
|
@ -85,7 +86,13 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('model')->defaultValue('Sylius\Component\Channel\Model\Channel')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->scalarNode('repository')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\Bundle\ChannelBundle\Form\Type\ChannelType')->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default')->defaultValue('Sylius\Bundle\ChannelBundle\Form\Type\ChannelType')->end()
|
||||
->scalarNode('choice')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
|
|
|||
|
|
@ -21,15 +21,31 @@ use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
|
|||
*/
|
||||
class ChannelRepository extends EntityRepository implements ChannelRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findMatchingHostname($hostname)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('channel');
|
||||
|
||||
$queryBuilder
|
||||
->andWhere('channel.url LIKE :hostname')
|
||||
->andWhere($queryBuilder->expr()->like('channel.url', ':hostname'))
|
||||
->setParameter('hostname', '%'.$hostname.'%')
|
||||
;
|
||||
|
||||
return $queryBuilder->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findDefault()
|
||||
{
|
||||
return $this
|
||||
->getCollectionQueryBuilder()
|
||||
->getQuery()
|
||||
->setMaxResults(1)
|
||||
->getSingleResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\ChannelBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Channel choice form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class ChannelChoiceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Channel class name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $className
|
||||
*/
|
||||
public function __construct($className)
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'class' => $this->className
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_channel_choice';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\ChannelBundle\Form\Type;
|
||||
|
||||
/**
|
||||
* Channel choice form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class ChannelEntityChoiceType extends ChannelChoiceType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return 'entity';
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
<parameters>
|
||||
<parameter key="sylius.repository.channel.class">Sylius\Bundle\ChannelBundle\Doctrine\ORM\ChannelRepository</parameter>
|
||||
<parameter key="sylius.form.type.channel_choice.class">Sylius\Bundle\ChannelBundle\Form\Type\ChannelEntityChoiceType</parameter>
|
||||
</parameters>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -17,21 +17,10 @@
|
|||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.form.type.channel.class">Sylius\Bundle\ChannelBundle\Form\Type\ChannelType</parameter>
|
||||
<parameter key="sylius.context.channel.class">Sylius\Component\Channel\Context\ChannelContext</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.form.type.channel" class="%sylius.form.type.channel.class%">
|
||||
<argument>%sylius.model.channel.class%</argument>
|
||||
<argument>%sylius.validation_group.channel%</argument>
|
||||
<tag name="form.type" alias="sylius_channel" />
|
||||
</service>
|
||||
<service id="sylius.form.type.channel_choice" class="%sylius.form.type.channel_choice.class%">
|
||||
<argument>%sylius.model.channel.class%</argument>
|
||||
<tag name="form.type" alias="sylius_channel_choice" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.context.channel" class="%sylius.context.channel.class%" />
|
||||
</services>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,24 @@ class ChannelContext extends BaseChannelContext implements ChannelContextInterfa
|
|||
$this->channelResolver = $channelResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getChannel()
|
||||
{
|
||||
if (null === $this->channel) {
|
||||
$this->channel = $this->channelResolver->resolve();
|
||||
}
|
||||
return $this->channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function onKernelRequest(KernelEvent $event)
|
||||
{
|
||||
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
|
||||
$this->channel = $this->channelResolver->resolve($event->getRequest());
|
||||
$this->channel = $this->channelResolver->resolve($event->getRequest()->getHost());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ class ProductController extends BaseProductController
|
|||
/**
|
||||
* @param Request $request
|
||||
* @param array $criteria
|
||||
*
|
||||
* @return null|ProductInterface
|
||||
*/
|
||||
public function findOr404(Request $request, array $criteria = array())
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
|
||||
use Pagerfanta\PagerfantaInterface;
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
|
||||
class PaymentRepository extends EntityRepository
|
||||
|
|
@ -28,9 +29,8 @@ class PaymentRepository extends EntityRepository
|
|||
$this->_em->getFilters()->disable('softdeleteable');
|
||||
|
||||
$queryBuilder = $this->getCollectionQueryBuilder();
|
||||
|
||||
$queryBuilder
|
||||
->leftJoin($this->getAlias().'.order', 'paymentOrder')
|
||||
->leftJoin($this->getPropertyName('order'), 'paymentOrder')
|
||||
->leftJoin('paymentOrder.billingAddress', 'address')
|
||||
->addSelect('paymentOrder')
|
||||
->addSelect('address')
|
||||
|
|
@ -38,31 +38,31 @@ class PaymentRepository extends EntityRepository
|
|||
|
||||
if (!empty($criteria['number'])) {
|
||||
$queryBuilder
|
||||
->andWhere('paymentOrder.number = :number')
|
||||
->andWhere($queryBuilder->expr()->eq('paymentOrder.number', ':number'))
|
||||
->setParameter('number', $criteria['number'])
|
||||
;
|
||||
}
|
||||
if (!empty($criteria['channel'])) {
|
||||
$queryBuilder
|
||||
->andWhere('paymentOrder.channel = :channel')
|
||||
->andWhere($queryBuilder->expr()->eq('paymentOrder.channel', ':channel'))
|
||||
->setParameter('channel', $criteria['channel'])
|
||||
;
|
||||
}
|
||||
if (!empty($criteria['billingAddress'])) {
|
||||
$queryBuilder
|
||||
->andWhere('address.lastName LIKE :billingAddress')
|
||||
->andWhere($queryBuilder->expr()->like('address.lastName', ':billingAddress'))
|
||||
->setParameter('billingAddress', '%'.$criteria['billingAddress'].'%')
|
||||
;
|
||||
}
|
||||
if (!empty($criteria['createdAtFrom'])) {
|
||||
$queryBuilder
|
||||
->andWhere($queryBuilder->expr()->gte($this->getAlias().'.createdAt', ':createdAtFrom'))
|
||||
->andWhere($queryBuilder->expr()->gte($this->getPropertyName('createdAt'), ':createdAtFrom'))
|
||||
->setParameter('createdAtFrom', date('Y-m-d 00:00:00',strtotime($criteria['createdAtFrom'])))
|
||||
;
|
||||
}
|
||||
if (!empty($criteria['createdAtTo'])) {
|
||||
$queryBuilder
|
||||
->andWhere($queryBuilder->expr()->lte($this->getAlias().'.createdAt', ':createdAtTo'))
|
||||
->andWhere($queryBuilder->expr()->lte($this->getPropertyName('createdAt'), ':createdAtTo'))
|
||||
->setParameter('createdAtTo', date('Y-m-d 23:59:59', strtotime($criteria['createdAtTo'])))
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Pagerfanta\PagerfantaInterface;
|
||||
use Sylius\Bundle\ProductBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\ProductInterface;
|
||||
|
|
@ -26,8 +27,7 @@ use Sylius\Component\Core\Model\TaxonInterface;
|
|||
class ProductRepository extends BaseProductRepository
|
||||
{
|
||||
/**
|
||||
* Create paginator for products categorized
|
||||
* under given taxon.
|
||||
* Create paginator for products categorized under given taxon.
|
||||
*
|
||||
* @param TaxonInterface $taxon
|
||||
* @param array $criteria
|
||||
|
|
@ -49,8 +49,7 @@ class ProductRepository extends BaseProductRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Create paginator for products categorized
|
||||
* under given taxon.
|
||||
* Create paginator for products categorized under given taxon.
|
||||
*
|
||||
* @param TaxonInterface $taxon
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,20 +26,20 @@ class PromotionRepository extends BasePromotionRepository
|
|||
*/
|
||||
public function findActiveByChannel(ChannelInterface $channel)
|
||||
{
|
||||
$qb = $this
|
||||
$queryBuilder = $this
|
||||
->getCollectionQueryBuilder()
|
||||
->orderBy($this->getAlias().'.priority', 'DESC')
|
||||
->orderBy($this->getPropertyName('priority'), 'DESC')
|
||||
;
|
||||
|
||||
$this->filterByActive($qb);
|
||||
$this->filterByActive($queryBuilder);
|
||||
|
||||
$qb
|
||||
->innerJoin($this->getAlias().'.channels', 'channel')
|
||||
->andWhere('channel = :channel')
|
||||
$queryBuilder
|
||||
->innerJoin($this->getPropertyName('channels'), 'channel')
|
||||
->andWhere($queryBuilder->expr()->eq('channel', ':channel'))
|
||||
->setParameter('channel', $channel)
|
||||
;
|
||||
|
||||
return $qb
|
||||
return $queryBuilder
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
|
|
|
|||
|
|
@ -23,13 +23,22 @@ use Symfony\Component\EventDispatcher\GenericEvent;
|
|||
*/
|
||||
class OrderChannelListener
|
||||
{
|
||||
/**
|
||||
* @var ChannelContextInterface
|
||||
*/
|
||||
protected $channelContext;
|
||||
|
||||
/**
|
||||
* @param ChannelContextInterface $channelContext
|
||||
*/
|
||||
public function __construct(ChannelContextInterface $channelContext)
|
||||
{
|
||||
$this->channelContext = $channelContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GenericEvent $event
|
||||
*/
|
||||
public function processOrderChannel(GenericEvent $event)
|
||||
{
|
||||
$order = $event->getSubject();
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ class PaymentStepType extends AbstractResourceType
|
|||
protected $channelContext;
|
||||
|
||||
/**
|
||||
* @param string $dataClass
|
||||
* @param array $validationGroups
|
||||
* @param ChannelContextInterface $channelContext
|
||||
*/
|
||||
public function __construct($dataClass, ChannelContextInterface $channelContext)
|
||||
public function __construct($dataClass, array $validationGroups = array(), ChannelContextInterface $channelContext)
|
||||
{
|
||||
parent::__construct($dataClass);
|
||||
parent::__construct($dataClass, $validationGroups);
|
||||
$this->channelContext = $channelContext;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ class ShippingStepType extends AbstractResourceType
|
|||
protected $channelContext;
|
||||
|
||||
/**
|
||||
* @param string $dataClass
|
||||
* @param array $validationGroups
|
||||
* @param ChannelContextInterface $channelContext
|
||||
*/
|
||||
public function __construct($dataClass, ChannelContextInterface $channelContext)
|
||||
public function __construct($dataClass, array $validationGroups = array(), ChannelContextInterface $channelContext)
|
||||
{
|
||||
parent::__construct($dataClass);
|
||||
parent::__construct($dataClass, $validationGroups);
|
||||
$this->channelContext = $channelContext;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ sylius_channel:
|
|||
classes:
|
||||
channel:
|
||||
model: Sylius\Component\Core\Model\Channel
|
||||
form: Sylius\Bundle\CoreBundle\Form\Type\ChannelType
|
||||
form:
|
||||
default: Sylius\Bundle\CoreBundle\Form\Type\ChannelType
|
||||
|
||||
sylius_cart:
|
||||
resolver: sylius.cart_item_resolver.default
|
||||
|
|
@ -284,7 +285,7 @@ sylius_rbac:
|
|||
sylius.group.update: Edit group
|
||||
sylius.group.delete: Delete group
|
||||
|
||||
sylius.manage.group: Manage channels
|
||||
sylius.manage.channel: Manage channels
|
||||
sylius.channel.show: Show channel
|
||||
sylius.channel.index: List channels
|
||||
sylius.channel.create: Create channel
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@
|
|||
<tag name="form.type" alias="sylius_checkout_addressing" />
|
||||
</service>
|
||||
<service id="sylius.checkout_form.shipping" class="%sylius.checkout_form.shipping.class%">
|
||||
<argument>%sylius.model.cart.class%</argument>
|
||||
<argument>%sylius.model.order.class%</argument>
|
||||
<argument>%sylius.validation_group.order%</argument>
|
||||
<argument type="service" id="sylius.context.channel"/>
|
||||
<tag name="form.type" alias="sylius_checkout_shipping" />
|
||||
</service>
|
||||
|
|
@ -67,7 +68,8 @@
|
|||
<tag name="form.type" alias="sylius_checkout_shipment" />
|
||||
</service>
|
||||
<service id="sylius.checkout_form.payment" class="%sylius.checkout_form.payment.class%">
|
||||
<argument>%sylius.model.cart.class%</argument>
|
||||
<argument>%sylius.model.order.class%</argument>
|
||||
<argument>%sylius.validation_group.order%</argument>
|
||||
<argument type="service" id="sylius.context.channel" />
|
||||
<tag name="form.type" alias="sylius_checkout_payment" />
|
||||
</service>
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ class LoadChannelsData extends DataFixture
|
|||
public function load(ObjectManager $manager)
|
||||
{
|
||||
$url = $this->container->getParameter('router.request_context.host');
|
||||
$manager->persist($this->createChannel('WEB-UK', 'UK Webstore', $url, array('en_GB'), array('GBP'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
|
||||
$manager->persist($this->createChannel('WEB-DE', 'Germany Webstore', null, array('de_DE'), array('EUR'), array('DHL', 'UPS Ground'), array('Dummy', 'Stripe')));
|
||||
$manager->persist($this->createChannel('WEB-US', 'United States Webstore', null, array('en_US'), array('USD'), array('FedEx', 'FedEx World Shipping'), array('Dummy', 'Stripe')));
|
||||
$manager->persist($this->createChannel('MOBILE', 'Mobile Store', null, array('en_GB', 'de_DE'), array('GBP', 'USD', 'EUR'), array('DHL', 'UPS Ground', 'FedEx'), array('Dummy', 'Stripe')));
|
||||
$manager->persist($this->createChannel('WEB-UK', 'UK Webstore', $url, array('en_GB'), array('GBP'), array('DHL', 'UPS Ground'), array('Dummy', 'StripeCheckout')));
|
||||
$manager->persist($this->createChannel('WEB-DE', 'Germany Webstore', null, array('de_DE'), array('EUR'), array('DHL', 'UPS Ground'), array('Dummy', 'StripeCheckout')));
|
||||
$manager->persist($this->createChannel('WEB-US', 'United States Webstore', null, array('en_US'), array('USD'), array('FedEx', 'FedEx World Shipping'), array('Dummy', 'StripeCheckout')));
|
||||
$manager->persist($this->createChannel('MOBILE', 'Mobile Store', null, array('en_GB', 'de_DE'), array('GBP', 'USD', 'EUR'), array('DHL', 'UPS Ground', 'FedEx'), array('Dummy', 'StripeCheckout')));
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class PromotionRepository extends EntityRepository implements PromotionRepositor
|
|||
{
|
||||
$qb = $this
|
||||
->getCollectionQueryBuilder()
|
||||
->orderBy($this->getAlias().'.priority', 'DESC')
|
||||
->orderBy($this->getPropertyName('priority'), 'DESC')
|
||||
;
|
||||
|
||||
$this->filterByActive($qb);
|
||||
|
|
@ -43,9 +43,9 @@ class PromotionRepository extends EntityRepository implements PromotionRepositor
|
|||
protected function getCollectionQueryBuilder()
|
||||
{
|
||||
return parent::getCollectionQueryBuilder()
|
||||
->leftJoin($this->getAlias().'.rules', 'r')
|
||||
->leftJoin($this->getPropertyName('rules'), 'r')
|
||||
->addSelect('r')
|
||||
->leftJoin($this->getAlias().'.actions', 'a')
|
||||
->leftJoin($this->getPropertyName('actions'), 'a')
|
||||
->addSelect('a');
|
||||
}
|
||||
|
||||
|
|
@ -58,14 +58,14 @@ class PromotionRepository extends EntityRepository implements PromotionRepositor
|
|||
return $qb
|
||||
->where(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($this->getAlias().'.startsAt'),
|
||||
$qb->expr()->lt($this->getAlias().'.startsAt', ':date')
|
||||
$qb->expr()->isNull($this->getPropertyName('startsAt')),
|
||||
$qb->expr()->lt($this->getPropertyName('startsAt'), ':date')
|
||||
)
|
||||
)
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($this->getAlias().'.endsAt'),
|
||||
$qb->expr()->gt($this->getAlias().'.endsAt', ':date')
|
||||
$qb->expr()->isNull($this->getPropertyName('endsAt')),
|
||||
$qb->expr()->gt($this->getPropertyName('endsAt'), ':date')
|
||||
)
|
||||
)
|
||||
->setParameter('date', $date)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
namespace Sylius\Component\Channel\Repository;
|
||||
|
||||
use Doctrine\ORM\NonUniqueResultException;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Sylius\Component\Channel\Model\ChannelInterface;
|
||||
|
||||
/**
|
||||
* Repository interface for channels.
|
||||
*
|
||||
|
|
@ -22,8 +26,15 @@ interface ChannelRepositoryInterface
|
|||
* Find channel best matching given hostname.
|
||||
*
|
||||
* @param string $hostname
|
||||
*
|
||||
* @return null|ChannelInterface
|
||||
* @return mixed
|
||||
* @throws NonUniqueResultException
|
||||
*/
|
||||
public function findMatchingHostname($hostname);
|
||||
|
||||
/**
|
||||
* @return ChannelInterface
|
||||
* @throws NonUniqueResultException
|
||||
* @throws NoResultException
|
||||
*/
|
||||
public function findDefault();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,12 @@ class ChannelResolver implements ChannelResolverInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request)
|
||||
public function resolve($hostname = null)
|
||||
{
|
||||
return $this->channelRepository->findMatchingHostname($request->getHost());
|
||||
if (null === $hostname || null === $channel = $this->channelRepository->findMatchingHostname($hostname)) {
|
||||
return $this->channelRepository->findDefault();
|
||||
}
|
||||
|
||||
return $channel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Sylius\Component\Core\Channel;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Sylius\Component\Channel\Model\ChannelInterface;
|
||||
|
||||
/**
|
||||
* Interface for service defining the currently used channel.
|
||||
|
|
@ -23,9 +23,9 @@ interface ChannelResolverInterface
|
|||
/**
|
||||
* Get currently used channel.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $hostname
|
||||
*
|
||||
* @return null|ChannelInterface
|
||||
* @return ChannelInterface
|
||||
*/
|
||||
public function resolve(Request $request);
|
||||
public function resolve($hostname = null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue