mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Introduce interfaces for all core models
This commit is contained in:
parent
2e1c094587
commit
66be34c375
35 changed files with 799 additions and 387 deletions
|
|
@ -12,9 +12,6 @@ default:
|
|||
default_session: symfony2
|
||||
selenium2: ~
|
||||
Behat\Symfony2Extension\Extension:
|
||||
kernel:
|
||||
path: app/AppKernel.php
|
||||
class: AppKernel
|
||||
mink_driver: true
|
||||
|
||||
saucelabs:
|
||||
|
|
|
|||
555
composer.lock
generated
555
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Cart;
|
||||
|
||||
use Sylius\Bundle\AssortmentBundle\Model\Variant\VariantInterface;
|
||||
use Sylius\Bundle\CartBundle\Model\CartItemInterface;
|
||||
use Sylius\Bundle\CartBundle\Resolver\ItemResolverInterface;
|
||||
use Sylius\Bundle\CartBundle\Resolver\ItemResolvingException;
|
||||
use Sylius\Bundle\CoreBundle\Model\VariantInterface;
|
||||
use Sylius\Bundle\InventoryBundle\Checker\AvailabilityCheckerInterface;
|
||||
use Sylius\Bundle\ResourceBundle\Model\RepositoryInterface;
|
||||
use Symfony\Component\Form\FormFactory;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ abstract class DataFixture extends AbstractFixture implements ContainerAwareInte
|
|||
*/
|
||||
protected function getVariantGenerator()
|
||||
{
|
||||
return $this->get('sylius.variant_generator');
|
||||
return $this->get('sylius.generator.variant');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class LoadOrdersData extends DataFixture
|
|||
$item->setVariant($variant);
|
||||
$item->setUnitPrice($variant->getPrice());
|
||||
$item->setQuantity(rand(1, 5));
|
||||
|
||||
$order->addItem($item);
|
||||
}
|
||||
|
||||
$shipment = $this->getShipmentRepository()->createNew();
|
||||
|
|
@ -50,6 +52,7 @@ class LoadOrdersData extends DataFixture
|
|||
$order->setCreatedAt($this->faker->dateTimeBetween('1 year ago', 'now'));
|
||||
|
||||
$order->calculateTotal();
|
||||
$order->complete();
|
||||
|
||||
$this->setReference('Sylius.Order-'.$i, $order);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\EventListener;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Model\ProductInterface;
|
||||
use Sylius\Bundle\CoreBundle\Model\VariantInterface;
|
||||
use Sylius\Bundle\CoreBundle\Uploader\ImageUploaderInterface;
|
||||
use Sylius\Bundle\TaxonomiesBundle\Model\TaxonInterface;
|
||||
use Sylius\Bundle\TaxonomiesBundle\Model\TaxonomyInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use Sylius\Bundle\AssortmentBundle\Model\CustomizableProductInterface;
|
||||
use Sylius\Bundle\AssortmentBundle\Model\Variant\VariantInterface;
|
||||
|
||||
class ImageUploadListener
|
||||
{
|
||||
|
|
@ -30,8 +30,8 @@ class ImageUploadListener
|
|||
public function uploadProductImage(GenericEvent $event)
|
||||
{
|
||||
$subject = $event->getSubject();
|
||||
if (!$subject instanceof CustomizableProductInterface && !$subject instanceof VariantInterface) {
|
||||
throw new \InvalidArgumentException('CustomizableProductInterface or VariantInterface expected.');
|
||||
if (!$subject instanceof ProductInterface && !$subject instanceof VariantInterface) {
|
||||
throw new \InvalidArgumentException('ProductInterface or VariantInterface expected.');
|
||||
}
|
||||
|
||||
$variant = $subject instanceof VariantInterface ? $subject : $subject->getMasterVariant();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\AssortmentBundle\Form\Type\CustomizableProductType as BaseProductType;
|
||||
use Sylius\Bundle\VariableProductBundle\Form\Type\VariableProductType as BaseProductType;
|
||||
use Sylius\Bundle\CoreBundle\Model\Product;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\AssortmentBundle\Form\Type\VariantType as BaseVariantType;
|
||||
use Sylius\Bundle\VariableProductBundle\Form\Type\VariantType as BaseVariantType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use Sylius\Bundle\ResourceBundle\Model\TimestampableInterface;
|
|||
|
||||
interface ImageInterface extends TimestampableInterface
|
||||
{
|
||||
public function getId();
|
||||
public function hasFile();
|
||||
public function getFile();
|
||||
public function setFile(SplFileInfo $file);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace Sylius\Bundle\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\InventoryBundle\Model\InventoryUnit as BaseInventoryUnit;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentInterface as BaseShipmentInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentItemInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShippableInterface;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ class InventoryUnit extends BaseInventoryUnit implements InventoryUnitInterface
|
|||
/**
|
||||
* Shipment
|
||||
*
|
||||
* @var ShipmentInterface
|
||||
* @var BaseShipmentInterface
|
||||
*/
|
||||
protected $shipment;
|
||||
|
||||
|
|
@ -71,19 +71,30 @@ class InventoryUnit extends BaseInventoryUnit implements InventoryUnitInterface
|
|||
$this->shippingState = ShipmentItemInterface::STATE_READY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOrder(OrderInterface $order = null)
|
||||
{
|
||||
$this->order = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,38 +108,46 @@ class InventoryUnit extends BaseInventoryUnit implements InventoryUnitInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setShipment(ShipmentInterface $shipment = null)
|
||||
public function setShipment(BaseShipmentInterface $shipment = null)
|
||||
{
|
||||
$this->shipment = $shipment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getShippable()
|
||||
{
|
||||
return $this->getStockable();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setShippable(ShippableInterface $shippable)
|
||||
{
|
||||
$this->setStockable($shippable);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getShippingState()
|
||||
{
|
||||
return $this->shippingState;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setShippingState($state)
|
||||
{
|
||||
$this->shippingState = $state;
|
||||
}
|
||||
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Sylius\Bundle\InventoryBundle\Model\InventoryUnitInterface as BaseInventoryU
|
|||
use Sylius\Bundle\ShippingBundle\Model\ShipmentItemInterface;
|
||||
|
||||
/**
|
||||
* Sylius core inventory unit interface.
|
||||
* Inventory unit interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
|
|
@ -23,4 +23,6 @@ interface InventoryUnitInterface extends
|
|||
BaseInventoryUnitInterface,
|
||||
ShipmentItemInterface
|
||||
{
|
||||
public function getOrder();
|
||||
public function setOrder(OrderInterface $order);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@ namespace Sylius\Bundle\CoreBundle\Model;
|
|||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;
|
||||
use Sylius\Bundle\CartBundle\Model\Cart;
|
||||
use Sylius\Bundle\SalesBundle\Model\AdjustmentInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentInterface;
|
||||
|
||||
/**
|
||||
* Order entity.
|
||||
|
|
@ -77,6 +75,7 @@ class Order extends Cart implements OrderInterface
|
|||
|
||||
$this->inventoryUnits = new ArrayCollection();
|
||||
$this->shipments = new ArrayCollection();
|
||||
$this->currency = 'EUR'; // @todo: Temporary
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Model;
|
||||
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;
|
||||
use Sylius\Bundle\PromotionsBundle\Model\PromotionSubjectInterface;
|
||||
use Sylius\Bundle\CartBundle\Model\CartInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentInterface;
|
||||
use Sylius\Bundle\PromotionsBundle\Model\PromotionSubjectInterface;
|
||||
|
||||
/**
|
||||
* Sylius core Order model.
|
||||
|
|
|
|||
|
|
@ -20,18 +20,32 @@ use Sylius\Bundle\CartBundle\Model\CartItem;
|
|||
*/
|
||||
class OrderItem extends CartItem implements OrderItemInterface
|
||||
{
|
||||
/**
|
||||
* Product variant.
|
||||
*
|
||||
* @var VariantInterface
|
||||
*/
|
||||
protected $variant;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->variant->getProduct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVariant()
|
||||
{
|
||||
return $this->variant;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setVariant(VariantInterface $variant)
|
||||
{
|
||||
$this->variant = $variant;
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@ use Doctrine\Common\Collections\Collection;
|
|||
use Sylius\Bundle\VariableProductBundle\Model\VariableProduct as BaseProduct;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShippingCategoryInterface;
|
||||
use Sylius\Bundle\TaxationBundle\Model\TaxCategoryInterface;
|
||||
use Sylius\Bundle\TaxationBundle\Model\TaxableInterface;
|
||||
|
||||
/**
|
||||
* Sylius core product entity.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Product extends BaseProduct implements TaxableInterface
|
||||
class Product extends BaseProduct implements ProductInterface
|
||||
{
|
||||
/*
|
||||
* Variant selection methods.
|
||||
|
|
@ -104,9 +103,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the variant selection method.
|
||||
*
|
||||
* @return string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVariantSelectionMethod()
|
||||
{
|
||||
|
|
@ -114,9 +111,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set variant selection method.
|
||||
*
|
||||
* @param string $variantSelectionMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setVariantSelectionMethod($variantSelectionMethod)
|
||||
{
|
||||
|
|
@ -130,9 +125,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if variant is selectable by simple variant choice.
|
||||
*
|
||||
* @return Boolean
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVariantSelectionMethodChoice()
|
||||
{
|
||||
|
|
@ -140,9 +133,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get pretty label for variant selection method.
|
||||
*
|
||||
* @return string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVariantSelectionMethodLabel()
|
||||
{
|
||||
|
|
@ -152,9 +143,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get taxons.
|
||||
*
|
||||
* @return Collection
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTaxons()
|
||||
{
|
||||
|
|
@ -162,9 +151,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set categorization taxons.
|
||||
*
|
||||
* @param Collection $taxons
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setTaxons(Collection $taxons)
|
||||
{
|
||||
|
|
@ -172,9 +159,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets product price.
|
||||
*
|
||||
* @return float $price
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
|
|
@ -182,11 +167,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets product price.
|
||||
*
|
||||
* @param float $price
|
||||
*
|
||||
* @return Product
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPrice($price)
|
||||
{
|
||||
|
|
@ -196,9 +177,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get product short description.
|
||||
*
|
||||
* @return string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getShortDescription()
|
||||
{
|
||||
|
|
@ -206,11 +185,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Set product short description.
|
||||
*
|
||||
* @param string $shortDescription
|
||||
*
|
||||
* @return Product
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setShortDescription($shortDescription)
|
||||
{
|
||||
|
|
@ -268,9 +243,7 @@ class Product extends BaseProduct implements TaxableInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Get hash of variant selection methods and labels.
|
||||
*
|
||||
* @return array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getVariantSelectionMethodLabels()
|
||||
{
|
||||
|
|
|
|||
149
src/Sylius/Bundle/CoreBundle/Model/ProductInterface.php
Normal file
149
src/Sylius/Bundle/CoreBundle/Model/ProductInterface.php
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShippingCategoryInterface;
|
||||
use Sylius\Bundle\TaxationBundle\Model\TaxCategoryInterface;
|
||||
use Sylius\Bundle\VariableProductBundle\Model\VariableProductInterface;
|
||||
|
||||
/**
|
||||
* Product interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ProductInterface extends VariableProductInterface
|
||||
{
|
||||
/**
|
||||
* Get product SKU.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSku();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setSku($sku);
|
||||
|
||||
/**
|
||||
* Get the variant selection method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariantSelectionMethod();
|
||||
|
||||
/**
|
||||
* Set variant selection method.
|
||||
*
|
||||
* @param string $variantSelectionMethod
|
||||
*/
|
||||
public function setVariantSelectionMethod($variantSelectionMethod);
|
||||
|
||||
/**
|
||||
* Check if variant is selectable by simple variant choice.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isVariantSelectionMethodChoice();
|
||||
|
||||
/**
|
||||
* Get pretty label for variant selection method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariantSelectionMethodLabel();
|
||||
|
||||
/**
|
||||
* Get taxons.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTaxons();
|
||||
|
||||
/**
|
||||
* Set categorization taxons.
|
||||
*
|
||||
* @param Collection $taxons
|
||||
*/
|
||||
public function setTaxons(Collection $taxons);
|
||||
|
||||
/**
|
||||
* Gets product price.
|
||||
*
|
||||
* @return integer $price
|
||||
*/
|
||||
public function getPrice();
|
||||
|
||||
/**
|
||||
* Sets product price.
|
||||
*
|
||||
* @param float $price
|
||||
*/
|
||||
public function setPrice($price);
|
||||
|
||||
/**
|
||||
* Get product short description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShortDescription();
|
||||
|
||||
/**
|
||||
* Set product short description.
|
||||
*
|
||||
* @param string $shortDescription
|
||||
*/
|
||||
public function setShortDescription($shortDescription);
|
||||
|
||||
/**
|
||||
* Get taxation category.
|
||||
*
|
||||
* @return TaxCategoryInterface
|
||||
*/
|
||||
public function getTaxCategory();
|
||||
|
||||
/**
|
||||
* Set taxation category.
|
||||
*
|
||||
* @param TaxCategoryInterface $category
|
||||
*/
|
||||
public function setTaxCategory(TaxCategoryInterface $category = null);
|
||||
|
||||
/**
|
||||
* Get product shipping category.
|
||||
*
|
||||
* @return ShippingCategoryInterface
|
||||
*/
|
||||
public function getShippingCategory();
|
||||
|
||||
/**
|
||||
* Set product shipping category.
|
||||
*
|
||||
* @param ShippingCategoryInterface $category
|
||||
*/
|
||||
public function setShippingCategory(ShippingCategoryInterface $category = null);
|
||||
|
||||
/**
|
||||
* Get all product images.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getImages();
|
||||
|
||||
/**
|
||||
* Get product main image.
|
||||
*
|
||||
* @return ImageInterface
|
||||
*/
|
||||
public function getImage();
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ use Sylius\Bundle\ShippingBundle\Model\Shipment as BaseShipment;
|
|||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Shipment extends BaseShipment
|
||||
class Shipment extends BaseShipment implements ShipmentInterface
|
||||
{
|
||||
/**
|
||||
* Order.
|
||||
|
|
@ -28,9 +28,7 @@ class Shipment extends BaseShipment
|
|||
protected $order;
|
||||
|
||||
/**
|
||||
* Get the order.
|
||||
*
|
||||
* @return OrderInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
|
|
@ -38,9 +36,7 @@ class Shipment extends BaseShipment
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOrder(OrderInterface $order = null)
|
||||
{
|
||||
|
|
|
|||
37
src/Sylius/Bundle/CoreBundle/Model/ShipmentInterface.php
Normal file
37
src/Sylius/Bundle/CoreBundle/Model/ShipmentInterface.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShipmentInterface as BaseShipmentInterface;
|
||||
|
||||
/**
|
||||
* Shipment interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ShipmentInterface extends BaseShipmentInterface
|
||||
{
|
||||
/**
|
||||
* Get the order.
|
||||
*
|
||||
* @return OrderInterface
|
||||
*/
|
||||
public function getOrder();
|
||||
|
||||
/**
|
||||
* Set the order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
public function setOrder(OrderInterface $order = null);
|
||||
}
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ use Sylius\Bundle\ShippingBundle\Model\ShippingMethod as BaseShippingMethod;
|
|||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class ShippingMethod extends BaseShippingMethod
|
||||
class ShippingMethod extends BaseShippingMethod implements ShippingMethodInterface
|
||||
{
|
||||
/**
|
||||
* Geographical zone.
|
||||
|
|
@ -29,9 +29,7 @@ class ShippingMethod extends BaseShippingMethod
|
|||
protected $zone;
|
||||
|
||||
/**
|
||||
* Get zone.
|
||||
*
|
||||
* @return ZoneInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getZone()
|
||||
{
|
||||
|
|
@ -39,9 +37,7 @@ class ShippingMethod extends BaseShippingMethod
|
|||
}
|
||||
|
||||
/**
|
||||
* Set zone.
|
||||
*
|
||||
* @param ZoneInterface $zone
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setZone(ZoneInterface $zone)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\AddressingBundle\Model\ZoneInterface;
|
||||
use Sylius\Bundle\ShippingBundle\Model\ShippingMethodInterface as BaseShippingMethodInterface;
|
||||
|
||||
/**
|
||||
* Shipping method interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ShippingMethodInterface extends BaseShippingMethodInterface
|
||||
{
|
||||
/**
|
||||
* Get zone.
|
||||
*
|
||||
* @return ZoneInterface
|
||||
*/
|
||||
public function getZone();
|
||||
|
||||
/**
|
||||
* Set zone.
|
||||
*
|
||||
* @param ZoneInterface $zone
|
||||
*/
|
||||
public function setZone(ZoneInterface $zone);
|
||||
}
|
||||
|
|
@ -29,9 +29,7 @@ class TaxRate extends BaseTaxRate
|
|||
protected $zone;
|
||||
|
||||
/**
|
||||
* Get zone.
|
||||
*
|
||||
* @return ZoneInterface
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getZone()
|
||||
{
|
||||
|
|
@ -39,9 +37,7 @@ class TaxRate extends BaseTaxRate
|
|||
}
|
||||
|
||||
/**
|
||||
* Set zone.
|
||||
*
|
||||
* @param ZoneInterface $zone
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setZone(ZoneInterface $zone)
|
||||
{
|
||||
|
|
|
|||
37
src/Sylius/Bundle/CoreBundle/Model/TaxRateInterface.php
Normal file
37
src/Sylius/Bundle/CoreBundle/Model/TaxRateInterface.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\AddressingBundle\Model\ZoneInterface;
|
||||
use Sylius\Bundle\TaxationBundle\Model\TaxRateInterface as BaseTaxRateInterface;
|
||||
|
||||
/**
|
||||
* Tax rate interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface TaxRateInterface extends BaseTaxRateInterface
|
||||
{
|
||||
/**
|
||||
* Get zone.
|
||||
*
|
||||
* @return ZoneInterface
|
||||
*/
|
||||
public function getZone();
|
||||
|
||||
/**
|
||||
* Set zone.
|
||||
*
|
||||
* @param ZoneInterface $zone
|
||||
*/
|
||||
public function setZone(ZoneInterface $zone);
|
||||
}
|
||||
|
|
@ -1,5 +1,14 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\Model\ImageInterface;
|
||||
|
|
@ -85,5 +94,4 @@ class Taxon extends BaseTaxon implements ImageInterface
|
|||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use Sylius\Bundle\TaxonomiesBundle\Model\Taxonomy as BaseTaxonomy;
|
||||
|
|
@ -13,5 +22,4 @@ class Taxonomy extends BaseTaxonomy
|
|||
{
|
||||
$this->setRoot(new Taxon());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,18 +11,17 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Model;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use FOS\UserBundle\Entity\User as BaseUser;
|
||||
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;
|
||||
use DateTime;
|
||||
use Sylius\Bundle\ResourceBundle\Model\TimestampableInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use FOS\UserBundle\Model\User as BaseUser;
|
||||
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;
|
||||
|
||||
/**
|
||||
* User entity.
|
||||
* User model.
|
||||
*
|
||||
* @author Paweł Jędrzjewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class User extends BaseUser implements TimestampableInterface
|
||||
class User extends BaseUser implements UserInterface
|
||||
{
|
||||
protected $firstName;
|
||||
protected $lastName;
|
||||
|
|
@ -202,7 +201,7 @@ class User extends BaseUser implements TimestampableInterface
|
|||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
}
|
||||
|
||||
|
||||
public function setEmail($email)
|
||||
{
|
||||
parent::setEmail($email);
|
||||
|
|
|
|||
106
src/Sylius/Bundle/CoreBundle/Model/UserInterface.php
Normal file
106
src/Sylius/Bundle/CoreBundle/Model/UserInterface.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?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\CoreBundle\Model;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use FOS\UserBundle\Model\UserInterface as BaseUserInterface;
|
||||
use Sylius\Bundle\AddressingBundle\Model\AddressInterface;
|
||||
use Sylius\Bundle\ResourceBundle\Model\TimestampableInterface;
|
||||
|
||||
/**
|
||||
* User interface.
|
||||
*
|
||||
* @author Paweł Jędrzjewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface UserInterface extends BaseUserInterface, TimestampableInterface
|
||||
{
|
||||
public function getFirstName();
|
||||
|
||||
/**
|
||||
* Set firstname.
|
||||
*
|
||||
* @param string $firstName
|
||||
*/
|
||||
public function setFirstName($firstName);
|
||||
|
||||
public function getLastName();
|
||||
public function setLastName($lastName);
|
||||
|
||||
public function getCurrency();
|
||||
public function setCurrency($currency);
|
||||
|
||||
/**
|
||||
* Get orders.
|
||||
*
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getOrders();
|
||||
|
||||
/**
|
||||
* Get billing address.
|
||||
*
|
||||
* @return AddressInterface
|
||||
*/
|
||||
public function getBillingAddress();
|
||||
|
||||
/**
|
||||
* Set billing address.
|
||||
*
|
||||
* @param AddressInterface $billingAddress
|
||||
*/
|
||||
public function setBillingAddress(AddressInterface $billingAddress = null);
|
||||
|
||||
/**
|
||||
* Get shipping address.
|
||||
*
|
||||
* @return AddressInterface
|
||||
*/
|
||||
public function getShippingAddress();
|
||||
|
||||
/**
|
||||
* Set shipping address.
|
||||
*
|
||||
* @param AddressInterface $shippingAddress
|
||||
*/
|
||||
public function setShippingAddress(AddressInterface $shippingAddress = null);
|
||||
|
||||
/**
|
||||
* Get addresses.
|
||||
*
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getAddresses();
|
||||
|
||||
/**
|
||||
* Add address.
|
||||
*
|
||||
* @param AddressInterface $address
|
||||
*/
|
||||
public function addAddress(AddressInterface $address);
|
||||
|
||||
/**
|
||||
* Remove address.
|
||||
*
|
||||
* @param AddressInterface $addresses
|
||||
*/
|
||||
public function removeAddress(AddressInterface $address);
|
||||
|
||||
/**
|
||||
* Has address?
|
||||
*
|
||||
* @param AddressInterface $addresses
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasAddress(AddressInterface $address);
|
||||
}
|
||||
|
|
@ -62,6 +62,8 @@ class OrderRepository extends EntityRepository
|
|||
{
|
||||
$queryBuilder = parent::getCollectionQueryBuilder();
|
||||
|
||||
$queryBuilder->andWhere($queryBuilder->expr()->isNotNull('o.completedAt'));
|
||||
|
||||
if (!empty($criteria['number'])) {
|
||||
$queryBuilder
|
||||
->andWhere('o.number LIKE :number')
|
||||
|
|
@ -189,4 +191,11 @@ class OrderRepository extends EntityRepository
|
|||
|
||||
return $queryBuilder;
|
||||
}
|
||||
|
||||
protected function getCollectionQueryBuilder()
|
||||
{
|
||||
$queryBuilder = parent::getCollectionQueryBuilder();
|
||||
|
||||
return $queryBuilder->andWhere($queryBuilder->expr()->isNotNull('o.completedAt'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
<cascade>
|
||||
<cascade-persist/>
|
||||
</cascade>
|
||||
<join-column name="shipping_address_id" referenced-column-name="id" nullable="false" />
|
||||
<join-column name="shipping_address_id" referenced-column-name="id" nullable="true" />
|
||||
</many-to-one>
|
||||
<many-to-one field="billingAddress" target-entity="Sylius\Bundle\AddressingBundle\Model\AddressInterface">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
<join-column name="billing_address_id" referenced-column-name="id" nullable="false" />
|
||||
<join-column name="billing_address_id" referenced-column-name="id" nullable="true" />
|
||||
</many-to-one>
|
||||
<one-to-many field="inventoryUnits" target-entity="Sylius\Bundle\InventoryBundle\Model\InventoryUnitInterface" mapped-by="order">
|
||||
<cascade>
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
</cascade>
|
||||
</one-to-many>
|
||||
<many-to-one field="user" target-entity="Sylius\Bundle\CoreBundle\Model\User" inversed-by="orders">
|
||||
<join-column name="user_id" referenced-column-name="id" nullable="false" />
|
||||
<join-column name="user_id" referenced-column-name="id" nullable="true" />
|
||||
</many-to-one>
|
||||
<field name="currency" length="3" />
|
||||
</entity>
|
||||
|
|
|
|||
|
|
@ -9,21 +9,26 @@
|
|||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="shortDescription" column="short_description" type="string" nullable="true" />
|
||||
<field name="variantSelectionMethod" column="variant_selection_method" type="string" nullable="false" />
|
||||
|
||||
<one-to-many field="variants" target-entity="Sylius\Bundle\VariableProductBundle\Model\VariantInterface" mapped-by="product">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
|
||||
<one-to-many field="properties" target-entity="Sylius\Bundle\ProductBundle\Model\ProductPropertyInterface" mapped-by="product">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
|
||||
<many-to-one field="taxCategory" target-entity="Sylius\Bundle\TaxationBundle\Model\TaxCategoryInterface">
|
||||
<join-column name="tax_category_id" referenced-column-name="id" nullable="true" />
|
||||
</many-to-one>
|
||||
|
||||
<many-to-many field="taxons" target-entity="Sylius\Bundle\TaxonomiesBundle\Model\TaxonInterface">
|
||||
<join-table name="sylius_product_taxon">
|
||||
<join-columns>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
<field name="name" column="name" type="string" />
|
||||
|
||||
<many-to-one field="root" target-entity="Sylius\Bundle\TaxonomiesBundle\Model\TaxonInterface">
|
||||
<join-column name="root_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
|
|
|
|||
|
|
@ -178,10 +178,10 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
public function thereAreOrders(TableNode $table)
|
||||
{
|
||||
$manager = $this->getEntityManager();
|
||||
$orderBuilder = $this->getService('sylius.builder.order');
|
||||
$orderRepository = $this->getRepository('order');
|
||||
|
||||
foreach ($table->getHash() as $data) {
|
||||
$order = $orderBuilder->create()->getOrder();
|
||||
$order = $orderRepository->createNew();
|
||||
|
||||
$address = $this->createAddress($data['address']);
|
||||
|
||||
|
|
@ -209,18 +209,27 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
public function orderHasFollowingItems($number, TableNode $items)
|
||||
{
|
||||
$manager = $this->getEntityManager();
|
||||
$orderBuilder = $this->getService('sylius.builder.order');
|
||||
$orderItemRepository = $this->getRepository('order_item');
|
||||
|
||||
$orderBuilder->modify($this->orders[$number]);
|
||||
$order = $this->orders[$number];
|
||||
|
||||
foreach ($items->getHash() as $data) {
|
||||
$product = $this->findOneByName('product', trim($data['product']));
|
||||
$quantity = $data['quantity'];
|
||||
|
||||
$orderBuilder->add($product->getMasterVariant(), $product->getMasterVariant()->getPrice(), $quantity);
|
||||
$item = $orderItemRepository->createNew();
|
||||
|
||||
$item->setVariant($product->getMasterVariant());
|
||||
$item->setUnitPrice($product->getMasterVariant()->getPrice());
|
||||
$item->setQuantity($quantity);
|
||||
|
||||
$order->addItem($item);
|
||||
}
|
||||
|
||||
$manager->persist($orderBuilder->getOrder());
|
||||
$order->calculateTotal();
|
||||
$order->complete();
|
||||
|
||||
$manager->persist($order);
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +404,7 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
$product = $this->findOneByName('product', $productName);
|
||||
$manager = $this->getEntityManager();
|
||||
|
||||
$this->getService('sylius.variant_generator')->generate($product);
|
||||
$this->getService('sylius.generator.variant')->generate($product);
|
||||
|
||||
foreach ($product->getVariants() as $variant) {
|
||||
$variant->setPrice($product->getMasterVariant()->getPrice());
|
||||
|
|
@ -482,7 +491,7 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
'presentation' => isset($data['presentation']) ? $data['presentation'] : $data['name']
|
||||
);
|
||||
if ($choices) {
|
||||
$additionalData['options'] = array('choices' => $choices);
|
||||
$additionalData['configuration'] = array('choices' => $choices);
|
||||
}
|
||||
$this->thereIsProperty($data['name'], $additionalData);
|
||||
}
|
||||
|
|
@ -504,6 +513,7 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
|
||||
$property = $repository->createNew();
|
||||
$property->setName($name);
|
||||
|
||||
foreach ($additionalData as $key => $value) {
|
||||
$property->{'set'.\ucfirst($key)}($value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ class FrontendMenuBuilder extends MenuBuilder
|
|||
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
$child = $menu->addChild($taxonomy->getName(), $childOptions);
|
||||
|
||||
if ($taxonomy->getRoot()->hasPath()) {
|
||||
$child->setLabelAttribute('data-image', $taxonomy->getRoot()->getPath());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@
|
|||
<tr>
|
||||
<th>#</th>
|
||||
<th>{{ 'sylius.product.sku'|trans }}</th>
|
||||
<th>{{ 'sylius.order_item.sellable'|trans }}</th>
|
||||
<th>{{ 'sylius.order_item.product'|trans }}</th>
|
||||
<th>{{ 'sylius.order_item.quantity'|trans }}</th>
|
||||
<th><span class="pull-right">{{ 'sylius.order_item.unit_price'|trans }}</span></th>
|
||||
<th><span class="pull-right">{{ 'sylius.order_item.total'|trans }}</span></th>
|
||||
|
|
@ -143,7 +143,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for item in order.items %}
|
||||
{% set variant = item.sellable %}
|
||||
{% set variant = item.variant %}
|
||||
{% set product = variant.product %}
|
||||
<tr>
|
||||
<td>{{ loop.index }}</td>
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
<div class="control-group">
|
||||
{% for type in ['country', 'province', 'zone'] %}
|
||||
<div id="sylius-zone-members-{{ type }}" data-prototype="{{ form_widget(form.members.vars.prototypes['sylius_zone_member_' ~ type], {'attr': {'class': 'select2 input-large'}})|e }}">
|
||||
{% if form.type.get('value') == type %}
|
||||
{% if form.type.vars.value == type %}
|
||||
{% for member in form.members %}
|
||||
{% if member.offsetExists(form.type.get('value')) %}
|
||||
{% if member.offsetExists(form.type.vars.value) %}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{{ form_widget(member[form.type.get('value')], {'attr': {'class': 'select2 input-large'}}) }}
|
||||
{{ form_widget(member[form.type.vars.value], {'attr': {'class': 'select2 input-large'}}) }}
|
||||
<a href="#" class="btn btn-danger collection-remove-btn"><i class="icon-trash icon-white"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
{% endfor %}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{% set prototypeId = 'sylius-zone-members-' ~ form.type.get('value')|default(constant('Sylius\\Bundle\\AddressingBundle\\Model\\ZoneInterface::TYPE_COUNTRY')) %}
|
||||
{% set prototypeId = 'sylius-zone-members-' ~ form.type.vars.value|default(constant('Sylius\\Bundle\\AddressingBundle\\Model\\ZoneInterface::TYPE_COUNTRY')) %}
|
||||
<a href="#" class="btn btn-success" data-collection-button="add" data-prototype="{{ prototypeId }}" data-collection="{{ prototypeId }}">{{ 'sylius.zone.add_member'|trans }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{{ form_label(form, label|default(null)) }}
|
||||
<div class="controls">
|
||||
{{ form_widget(form, {'attr': attr|default({}), 'empty_value': empty_value|default(null)}) }}
|
||||
{{ form_errors(form)}}
|
||||
{{ form_errors(form) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue