Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Make CoreBundle optional
Browse files Browse the repository at this point in the history
  • Loading branch information
wbloszyk committed Jun 9, 2020
1 parent efa559c commit 1a2975f
Show file tree
Hide file tree
Showing 44 changed files with 118 additions and 84 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
"sonata-project/block-bundle": "^3.18.3",
"sonata-project/classification-bundle": "^3.3",
"sonata-project/comment-bundle": "^3.1",
"sonata-project/core-bundle": "^3.18.0",
"sonata-project/datagrid-bundle": "^2.5",
"sonata-project/doctrine-extensions": "^1.5",
"sonata-project/doctrine-orm-admin-bundle": "^3.2",
"sonata-project/form-extensions": "^0.1 || ^1.3",
"sonata-project/formatter-bundle": "^3.4 || ^4.0",
"sonata-project/intl-bundle": "^2.4",
"sonata-project/media-bundle": "^3.10",
"sonata-project/notification-bundle": "^3.3",
"sonata-project/seo-bundle": "^2.4",
"sonata-project/twig-extensions": "^0.1 || ^1.2",
"sonata-project/user-bundle": "^4.0",
"symfony/config": "^3.4 || ^4.0",
"symfony/console": "^3.4 || ^4.0",
Expand Down Expand Up @@ -63,7 +64,7 @@
},
"require-dev": {
"friendsofsymfony/rest-bundle": "^2.2",
"jms/serializer-bundle": "^1.0 || ^2.0",
"jms/serializer-bundle": "^2.0 || ^3.0",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"nelmio/api-doc-bundle": "^2.13",
Expand Down
2 changes: 1 addition & 1 deletion src/BasketBundle/Block/BasketBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\Service\AbstractAdminBlockService;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\CoreBundle\Validator\ErrorElement;
use Sonata\Form\Validator\ErrorElement;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand Down
2 changes: 1 addition & 1 deletion src/BasketBundle/Form/ApiBasketElementParentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\BasketBundle\Form;

use Sonata\CoreBundle\Form\Type\BaseDoctrineORMSerializationType;
use Sonata\Form\Type\BaseDoctrineORMSerializationType;

class ApiBasketElementParentType extends BaseDoctrineORMSerializationType
{
Expand Down
2 changes: 1 addition & 1 deletion src/BasketBundle/Form/ApiBasketParentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\BasketBundle\Form;

use Sonata\CoreBundle\Form\Type\BaseDoctrineORMSerializationType;
use Sonata\Form\Type\BaseDoctrineORMSerializationType;

class ApiBasketParentType extends BaseDoctrineORMSerializationType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ file that was distributed with this source code.
{% sonata_template_box 'This is the basket delivery address step template. Feel free to override it.' %}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}
{% endblock %}

{% include '@SonataBasket/Basket/stepper.html.twig' with {step: 'delivery'} %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ file that was distributed with this source code.
{% sonata_template_box 'This is the basket delivery address template. Feel free to override it.' %}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}
{% endblock %}

{% include '@SonataBasket/Basket/stepper.html.twig' with {step: 'delivery'} %}
Expand Down
2 changes: 1 addition & 1 deletion src/BasketBundle/Resources/views/Basket/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file that was distributed with this source code.
#}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}
{% endblock %}

{% sonata_template_box 'This is the basket page template. Feel free to override it.' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ file that was distributed with this source code.
{% sonata_template_box 'This is the basket billing address step template. Feel free to override it.' %}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' with {domain: 'SonataCustomerBundle'} %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] with {domain: 'SonataCustomerBundle'} %}
{% endblock %}

{% include '@SonataBasket/Basket/stepper.html.twig' with {step: 'billing'} %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ file that was distributed with this source code.
{% sonata_template_box 'This is the basket billing step template. Feel free to override it.' %}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}
{% endblock %}

{% include '@SonataBasket/Basket/stepper.html.twig' with {step: 'billing'} %}
Expand Down
2 changes: 1 addition & 1 deletion src/BasketBundle/Serializer/BasketSerializerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\BasketBundle\Serializer;

use Sonata\CoreBundle\Serializer\BaseSerializerHandler;
use Sonata\Form\Serializer\BaseSerializerHandler;

/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
24 changes: 14 additions & 10 deletions src/BasketBundle/SonataBasketBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ public function boot(): void

/**
* Register form mapping information.
*
* NEXT_MAJOR: remove this method
*/
public function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'sonata_basket_basket' => BasketType::class,
'sonata_basket_address' => AddressType::class,
'sonata_basket_shipping' => ShippingType::class,
'sonata_basket_payment' => PaymentType::class,
'sonata_basket_api_form_basket' => ApiBasketType::class,
'sonata_basket_api_form_basket_element' => ApiBasketElementType::class,
'sonata_basket_api_form_basket_parent' => ApiBasketParentType::class,
'sonata_basket_api_form_basket_element_parent' => ApiBasketElementParentType::class,
]);
if (class_exists(FormHelper::class)) {
FormHelper::registerFormTypeMapping([
'sonata_basket_basket' => BasketType::class,
'sonata_basket_address' => AddressType::class,
'sonata_basket_shipping' => ShippingType::class,
'sonata_basket_payment' => PaymentType::class,
'sonata_basket_api_form_basket' => ApiBasketType::class,
'sonata_basket_api_form_basket_element' => ApiBasketElementType::class,
'sonata_basket_api_form_basket_parent' => ApiBasketParentType::class,
'sonata_basket_api_form_basket_element_parent' => ApiBasketElementParentType::class,
]);
}
}
}
2 changes: 1 addition & 1 deletion src/Component/Form/BasketValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Sonata\Component\Basket\BasketInterface;
use Sonata\Component\Product\Pool as ProductPool;
use Sonata\CoreBundle\Validator\ErrorElement;
use Sonata\Form\Validator\ErrorElement;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
Expand Down
2 changes: 0 additions & 2 deletions src/Component/Product/ProductProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public function buildBasketElement(BasketElementInterface $basketElement, ?Produ
* please not you always work with a clone version of the basketElement.
*
* If the basket is valid it will then replace the one in session
*
* @param \Sonata\CoreBundle\Validator\ErrorElement $errorElement
*/
public function validateFormBasketElement(ErrorElement $errorElement, BasketElementInterface $basketElement, BasketInterface $basket);

Expand Down
4 changes: 2 additions & 2 deletions src/CustomerBundle/Block/RecentCustomersBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use Sonata\BlockBundle\Block\Service\AbstractAdminBlockService;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Component\Customer\CustomerManagerInterface;
use Sonata\CoreBundle\Form\Type\ImmutableArrayType;
use Sonata\CoreBundle\Validator\ErrorElement;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
Expand Down
17 changes: 12 additions & 5 deletions src/CustomerBundle/DependencyInjection/SonataCustomerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@
*/
class SonataCustomerExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container): void
public function prepend(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
if ($container->hasExtension('twig')) {
// add custom form widgets
$container->prependExtensionConfig('twig', ['form_themes' => ['@SonataCore/Form/datepicker.html.twig']]);
if (isset($bundles['SonataCoreBundle'])) {
$container->prependExtensionConfig('twig', [
'form_themes' => ['@SonataCore/Form/datepicker.html.twig'],
]);
}
if (isset($bundles['SonataFormBundle'])) {
$container->prependExtensionConfig('twig', [
'form_themes' => ['@SonataForm/Form/datepicker.html.twig'],
]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/CustomerBundle/Form/Type/AddressTypeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\CustomerBundle\Form\Type;

use Sonata\CoreBundle\Form\Type\BaseStatusType;
use Sonata\Form\Type\BaseStatusType;

class AddressTypeType extends BaseStatusType
{
Expand Down
2 changes: 1 addition & 1 deletion src/CustomerBundle/Form/Type/ApiAddressType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\CustomerBundle\Form\Type;

use Sonata\CoreBundle\Form\Type\BaseDoctrineORMSerializationType;
use Sonata\Form\Type\BaseDoctrineORMSerializationType;

class ApiAddressType extends BaseDoctrineORMSerializationType
{
Expand Down
2 changes: 1 addition & 1 deletion src/CustomerBundle/Form/Type/ApiCustomerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\CustomerBundle\Form\Type;

use Sonata\CoreBundle\Form\Type\BaseDoctrineORMSerializationType;
use Sonata\Form\Type\BaseDoctrineORMSerializationType;

class ApiCustomerType extends BaseDoctrineORMSerializationType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% sonata_template_box 'This is the customer addresses list template. Feel free to override it.' %}

{% block sonata_flash_messages %}
{% include '@SonataCore/FlashMessage/render.html.twig' with {domain: 'SonataCustomerBundle'} %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] with {domain: 'SonataCustomerBundle'} %}
{% endblock %}

{% block sonata_profile_address_actions %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ file that was distributed with this source code.
</div>

<div class="span10 col-lg-10">
{% include '@SonataCore/FlashMessage/render.html.twig' %}
{% include ['@SonataCore/FlashMessage/render.html.twig', '@SonataTwig/FlashMessage/render.html.twig'] %}

{% block sonata_profile_content '' %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\CustomerBundle\Serializer;

use Sonata\CoreBundle\Serializer\BaseSerializerHandler;
use Sonata\Form\Serializer\BaseSerializerHandler;

/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
16 changes: 10 additions & 6 deletions src/CustomerBundle/SonataCustomerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ public function boot(): void

/**
* Register form mapping information.
*
* NEXT_MAJOR: remove this method
*/
public function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'sonata_customer_address' => AddressType::class,
'sonata_customer_address_types' => AddressTypeType::class,
'sonata_customer_api_form_customer' => ApiCustomerType::class,
'sonata_customer_api_form_address' => ApiAddressType::class,
]);
if (class_exists(FormHelper::class)) {
FormHelper::registerFormTypeMapping([
'sonata_customer_address' => AddressType::class,
'sonata_customer_address_types' => AddressTypeType::class,
'sonata_customer_api_form_customer' => ApiCustomerType::class,
'sonata_customer_api_form_address' => ApiAddressType::class,
]);
}
}
}
10 changes: 7 additions & 3 deletions src/DeliveryBundle/SonataDeliveryBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ public function boot(): void

/**
* Register form mapping information.
*
* NEXT_MAJOR: remove this method
*/
public function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'sonata_delivery_choice' => DeliveryChoiceType::class,
]);
if (class_exists(FormHelper::class)) {
FormHelper::registerFormTypeMapping([
'sonata_delivery_choice' => DeliveryChoiceType::class,
]);
}
}
}
2 changes: 1 addition & 1 deletion src/InvoiceBundle/Form/Type/InvoiceStatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\InvoiceBundle\Form\Type;

use Sonata\CoreBundle\Form\Type\BaseStatusType;
use Sonata\Form\Type\BaseStatusType;

class InvoiceStatusType extends BaseStatusType
{
Expand Down
2 changes: 1 addition & 1 deletion src/InvoiceBundle/Serializer/InvoiceSerializerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\InvoiceBundle\Serializer;

use Sonata\CoreBundle\Serializer\BaseSerializerHandler;
use Sonata\Form\Serializer\BaseSerializerHandler;

/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
10 changes: 7 additions & 3 deletions src/InvoiceBundle/SonataInvoiceBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ public function boot(): void

/**
* Register form mapping information.
*
* NEXT_MAJOR: remove this method
*/
public function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'sonata_invoice_status' => InvoiceStatusType::class,
]);
if (class_exists(FormHelper::class)) {
FormHelper::registerFormTypeMapping([
'sonata_invoice_status' => InvoiceStatusType::class,
]);
}
}
}
4 changes: 2 additions & 2 deletions src/OrderBundle/Block/RecentOrdersBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Component\Customer\CustomerManagerInterface;
use Sonata\Component\Order\OrderManagerInterface;
use Sonata\CoreBundle\Form\Type\ImmutableArrayType;
use Sonata\CoreBundle\Validator\ErrorElement;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Sonata\CoreBundle\DependencyInjection\Compiler;
namespace Sonata\OrderBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/OrderBundle/Form/Type/OrderStatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\OrderBundle\Form\Type;

use Sonata\CoreBundle\Form\Type\BaseStatusType;
use Sonata\Form\Type\BaseStatusType;

class OrderStatusType extends BaseStatusType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\OrderBundle\Serializer;

use Sonata\CoreBundle\Serializer\BaseSerializerHandler;
use Sonata\Form\Serializer\BaseSerializerHandler;

/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
2 changes: 1 addition & 1 deletion src/OrderBundle/Serializer/OrderSerializerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sonata\OrderBundle\Serializer;

use Sonata\CoreBundle\Serializer\BaseSerializerHandler;
use Sonata\Form\Serializer\BaseSerializerHandler;

/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
Expand Down
10 changes: 7 additions & 3 deletions src/OrderBundle/SonataOrderBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ public function boot(): void

/**
* Register form mapping information.
*
* NEXT_MAJOR: remove this method
*/
public function registerFormMapping(): void
{
FormHelper::registerFormTypeMapping([
'sonata_order_status' => OrderStatusType::class,
]);
if (class_exists(FormHelper::class)) {
FormHelper::registerFormTypeMapping([
'sonata_order_status' => OrderStatusType::class,
]);
}
}
}
Loading

0 comments on commit 1a2975f

Please sign in to comment.