From 90f16881bde524b28ac2ea8ea5064223e3d45818 Mon Sep 17 00:00:00 2001 From: mmoreram Date: Wed, 10 Jun 2015 18:20:58 +0200 Subject: [PATCH] Fixed CustomShipping when disabled * Added test for CustomShipping fix * Fixed Bundles with dependencies for new Elcodi implementation * Added specific methods for all Bundle classes * commands - return null * extension - return null --- app/AppKernel.php | 6 +- .../AttributeBundle/AdminAttributeBundle.php | 15 ++++ .../Admin/BannerBundle/AdminBannerBundle.php | 15 ++++ .../Admin/CartBundle/AdminCartBundle.php | 15 ++++ .../Admin/CoreBundle/AdminCoreBundle.php | 15 ++++ .../Admin/CouponBundle/AdminCouponBundle.php | 15 ++++ .../CurrencyBundle/AdminCurrencyBundle.php | 15 ++++ src/Elcodi/Admin/GeoBundle/AdminGeoBundle.php | 15 ++++ .../LanguageBundle/AdminLanguageBundle.php | 15 ++++ .../Admin/MediaBundle/AdminMediaBundle.php | 15 ++++ .../Admin/MetricBundle/AdminMetricBundle.php | 15 ++++ .../AdminNewsletterBundle.php | 15 ++++ .../Admin/PageBundle/AdminPageBundle.php | 15 ++++ .../PaymentBundle/AdminPaymentBundle.php | 18 +++- .../Admin/PluginBundle/AdminPluginBundle.php | 15 ++++ .../ProductBundle/AdminProductBundle.php | 15 ++++ .../Admin/RuleBundle/AdminRuleBundle.php | 15 ++++ .../ShippingBundle/AdminShippingBundle.php | 15 ++++ .../Admin/StoreBundle/AdminStoreBundle.php | 18 +++- .../TemplateBundle/AdminTemplateBundle.php | 15 ++++ .../Admin/UserBundle/AdminUserBundle.php | 15 ++++ .../ElcodiPaymentSuiteBridgeBundle.php | 3 +- .../ElcodiVisithorBridgeBundle.php | 15 ++++ .../CommonBundle/ElcodiCommonBundle.php | 2 + .../FirewallBundle/ElcodiFirewallBundle.php | 26 ++++++ .../ElcodiCustomShippingExtension.php | 1 + .../ElcodiCustomShippingBundle.php | 4 +- .../ShippingCollectEventListener.php | 37 ++++++-- .../Resources/config/eventListeners.yml | 1 + .../Resources/config/services.yml | 9 ++ .../Functional/Builder/MenuBuilderTest.php | 10 --- .../ShippingCollectEventListenerTest.php | 2 +- .../Functional/Factory/CarrierFactoryTest.php | 10 --- ...yTest.php => ShippingRangeFactoryTest.php} | 12 +-- .../Functional/Form/Type/CarrierTypeTest.php | 36 ++++++++ .../Form/Type/ShippingRangeTypeTest.php | 36 ++++++++ .../Repository/CarrierRepositoryTest.php | 12 --- .../ShippingRangeRepositoryTest.php | 12 --- .../Tests/Functional/app/AppKernel.php | 2 +- .../ShippingCollectEventListenerTest.php | 88 +++++++++++++++++++ .../ElcodiFreePaymentBundle.php | 3 +- .../ElcodiPaypalWebCheckoutBundle.php | 3 +- .../StripeBundle/ElcodiStripeBundle.php | 3 +- .../Store/CartBundle/StoreCartBundle.php | 15 ++++ .../StoreCartCouponBundle.php | 15 ++++ .../ConnectBundle/StoreConnectBundle.php | 33 +++++-- .../Store/CoreBundle/StoreCoreBundle.php | 15 ++++ .../CurrencyBundle/StoreCurrencyBundle.php | 25 ++++++ .../FallbackBundle/StoreFallbackBundle.php | 25 ++++++ src/Elcodi/Store/GeoBundle/StoreGeoBundle.php | 15 ++++ .../LanguageBundle/StoreLanguageBundle.php | 15 ++++ .../Store/MetricBundle/StoreMetricBundle.php | 15 ++++ .../OverrideBundle/StoreOverrideBundle.php | 25 ++++++ .../Store/PageBundle/StorePageBundle.php | 15 ++++ .../ProductBundle/StoreProductBundle.php | 15 ++++ .../Store/UserBundle/StoreUserBundle.php | 15 ++++ 56 files changed, 802 insertions(+), 80 deletions(-) create mode 100644 src/Elcodi/Plugin/CustomShippingBundle/Resources/config/services.yml rename src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/{CarrierRangeFactoryTest.php => ShippingRangeFactoryTest.php} (78%) create mode 100644 src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/CarrierTypeTest.php create mode 100644 src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/ShippingRangeTypeTest.php diff --git a/app/AppKernel.php b/app/AppKernel.php index 9239fbe3..702b26b6 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -172,7 +172,11 @@ public function registerBundles() $bundles[] = new Elcodi\Bridge\VisithorBridgeBundle\ElcodiVisithorBridgeBundle(); } - return $this->getBundleInstances($bundles); + return $this + ->getBundleInstances( + $this, + $bundles + ); } /** diff --git a/src/Elcodi/Admin/AttributeBundle/AdminAttributeBundle.php b/src/Elcodi/Admin/AttributeBundle/AdminAttributeBundle.php index 1e5b4aba..a8dbf98c 100644 --- a/src/Elcodi/Admin/AttributeBundle/AdminAttributeBundle.php +++ b/src/Elcodi/Admin/AttributeBundle/AdminAttributeBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\AttributeBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminAttributeExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/BannerBundle/AdminBannerBundle.php b/src/Elcodi/Admin/BannerBundle/AdminBannerBundle.php index 502d819b..dc2f34b5 100644 --- a/src/Elcodi/Admin/BannerBundle/AdminBannerBundle.php +++ b/src/Elcodi/Admin/BannerBundle/AdminBannerBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\BannerBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminBannerExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/CartBundle/AdminCartBundle.php b/src/Elcodi/Admin/CartBundle/AdminCartBundle.php index 9721b4ae..6376fe6e 100644 --- a/src/Elcodi/Admin/CartBundle/AdminCartBundle.php +++ b/src/Elcodi/Admin/CartBundle/AdminCartBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\CartBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminCartExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/CoreBundle/AdminCoreBundle.php b/src/Elcodi/Admin/CoreBundle/AdminCoreBundle.php index 8c29aa33..0e7c5eab 100644 --- a/src/Elcodi/Admin/CoreBundle/AdminCoreBundle.php +++ b/src/Elcodi/Admin/CoreBundle/AdminCoreBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\CoreBundle; +use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Admin\CoreBundle\DependencyInjection\AdminCoreExtension; @@ -35,4 +36,18 @@ public function getContainerExtension() { return new AdminCoreExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/CouponBundle/AdminCouponBundle.php b/src/Elcodi/Admin/CouponBundle/AdminCouponBundle.php index bba446ce..b612d30e 100644 --- a/src/Elcodi/Admin/CouponBundle/AdminCouponBundle.php +++ b/src/Elcodi/Admin/CouponBundle/AdminCouponBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\CouponBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminCouponExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/CurrencyBundle/AdminCurrencyBundle.php b/src/Elcodi/Admin/CurrencyBundle/AdminCurrencyBundle.php index 0da61886..41135355 100644 --- a/src/Elcodi/Admin/CurrencyBundle/AdminCurrencyBundle.php +++ b/src/Elcodi/Admin/CurrencyBundle/AdminCurrencyBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\CurrencyBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminCurrencyExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/GeoBundle/AdminGeoBundle.php b/src/Elcodi/Admin/GeoBundle/AdminGeoBundle.php index 6b958e74..d1b69c4e 100644 --- a/src/Elcodi/Admin/GeoBundle/AdminGeoBundle.php +++ b/src/Elcodi/Admin/GeoBundle/AdminGeoBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\GeoBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminGeoExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/LanguageBundle/AdminLanguageBundle.php b/src/Elcodi/Admin/LanguageBundle/AdminLanguageBundle.php index 8adbbf52..5d8d256f 100644 --- a/src/Elcodi/Admin/LanguageBundle/AdminLanguageBundle.php +++ b/src/Elcodi/Admin/LanguageBundle/AdminLanguageBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\LanguageBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminLanguageExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/MediaBundle/AdminMediaBundle.php b/src/Elcodi/Admin/MediaBundle/AdminMediaBundle.php index c1a8caa3..4f545c1d 100644 --- a/src/Elcodi/Admin/MediaBundle/AdminMediaBundle.php +++ b/src/Elcodi/Admin/MediaBundle/AdminMediaBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\MediaBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminMediaExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/MetricBundle/AdminMetricBundle.php b/src/Elcodi/Admin/MetricBundle/AdminMetricBundle.php index bf941dfa..5900c8fc 100644 --- a/src/Elcodi/Admin/MetricBundle/AdminMetricBundle.php +++ b/src/Elcodi/Admin/MetricBundle/AdminMetricBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\MetricBundle; +use Symfony\Component\Console\Application; use Symfony\Component\CssSelector\XPath\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminMetricExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/NewsletterBundle/AdminNewsletterBundle.php b/src/Elcodi/Admin/NewsletterBundle/AdminNewsletterBundle.php index 81ab94ce..f6466388 100644 --- a/src/Elcodi/Admin/NewsletterBundle/AdminNewsletterBundle.php +++ b/src/Elcodi/Admin/NewsletterBundle/AdminNewsletterBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\NewsletterBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminNewsletterExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/PageBundle/AdminPageBundle.php b/src/Elcodi/Admin/PageBundle/AdminPageBundle.php index 5099194e..baa36b96 100644 --- a/src/Elcodi/Admin/PageBundle/AdminPageBundle.php +++ b/src/Elcodi/Admin/PageBundle/AdminPageBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\PageBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminPageExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/PaymentBundle/AdminPaymentBundle.php b/src/Elcodi/Admin/PaymentBundle/AdminPaymentBundle.php index 5ebc201d..13176860 100644 --- a/src/Elcodi/Admin/PaymentBundle/AdminPaymentBundle.php +++ b/src/Elcodi/Admin/PaymentBundle/AdminPaymentBundle.php @@ -17,11 +17,13 @@ namespace Elcodi\Admin\PaymentBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Admin\PaymentBundle\DependencyInjection\AdminPaymentExtension; use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class AdminPaymentBundle @@ -38,6 +40,20 @@ public function getContainerExtension() return new AdminPaymentExtension(); } + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } + /** * Return all bundle dependencies. * @@ -45,7 +61,7 @@ public function getContainerExtension() * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Admin\CoreBundle\AdminCoreBundle', diff --git a/src/Elcodi/Admin/PluginBundle/AdminPluginBundle.php b/src/Elcodi/Admin/PluginBundle/AdminPluginBundle.php index 5f9f6203..2f29d4d3 100644 --- a/src/Elcodi/Admin/PluginBundle/AdminPluginBundle.php +++ b/src/Elcodi/Admin/PluginBundle/AdminPluginBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\PluginBundle; +use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Admin\PluginBundle\DependencyInjection\AdminPluginExtension; @@ -35,4 +36,18 @@ public function getContainerExtension() { return new AdminPluginExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/ProductBundle/AdminProductBundle.php b/src/Elcodi/Admin/ProductBundle/AdminProductBundle.php index e0e91f21..98891098 100644 --- a/src/Elcodi/Admin/ProductBundle/AdminProductBundle.php +++ b/src/Elcodi/Admin/ProductBundle/AdminProductBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\ProductBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminProductExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/RuleBundle/AdminRuleBundle.php b/src/Elcodi/Admin/RuleBundle/AdminRuleBundle.php index 6cc44949..84bd0090 100644 --- a/src/Elcodi/Admin/RuleBundle/AdminRuleBundle.php +++ b/src/Elcodi/Admin/RuleBundle/AdminRuleBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\RuleBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminRuleExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/ShippingBundle/AdminShippingBundle.php b/src/Elcodi/Admin/ShippingBundle/AdminShippingBundle.php index c4d33300..98076ecf 100644 --- a/src/Elcodi/Admin/ShippingBundle/AdminShippingBundle.php +++ b/src/Elcodi/Admin/ShippingBundle/AdminShippingBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\ShippingBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminShippingExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/StoreBundle/AdminStoreBundle.php b/src/Elcodi/Admin/StoreBundle/AdminStoreBundle.php index 1d930191..fcb33d1a 100644 --- a/src/Elcodi/Admin/StoreBundle/AdminStoreBundle.php +++ b/src/Elcodi/Admin/StoreBundle/AdminStoreBundle.php @@ -17,11 +17,13 @@ namespace Elcodi\Admin\StoreBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Admin\StoreBundle\DependencyInjection\AdminStoreExtension; use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class AdminStoreBundle @@ -38,6 +40,20 @@ public function getContainerExtension() return new AdminStoreExtension(); } + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } + /** * Return all bundle dependencies. * @@ -45,7 +61,7 @@ public function getContainerExtension() * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Admin\CoreBundle\AdminCoreBundle', diff --git a/src/Elcodi/Admin/TemplateBundle/AdminTemplateBundle.php b/src/Elcodi/Admin/TemplateBundle/AdminTemplateBundle.php index c843ded6..24086b6b 100644 --- a/src/Elcodi/Admin/TemplateBundle/AdminTemplateBundle.php +++ b/src/Elcodi/Admin/TemplateBundle/AdminTemplateBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\TemplateBundle; +use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Admin\TemplateBundle\DependencyInjection\AdminTemplateExtension; @@ -35,4 +36,18 @@ public function getContainerExtension() { return new AdminTemplateExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Admin/UserBundle/AdminUserBundle.php b/src/Elcodi/Admin/UserBundle/AdminUserBundle.php index c91446bb..a1c85865 100644 --- a/src/Elcodi/Admin/UserBundle/AdminUserBundle.php +++ b/src/Elcodi/Admin/UserBundle/AdminUserBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Admin\UserBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new AdminUserExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Bridge/PaymentSuiteBridgeBundle/ElcodiPaymentSuiteBridgeBundle.php b/src/Elcodi/Bridge/PaymentSuiteBridgeBundle/ElcodiPaymentSuiteBridgeBundle.php index 25096519..2fb3ba99 100644 --- a/src/Elcodi/Bridge/PaymentSuiteBridgeBundle/ElcodiPaymentSuiteBridgeBundle.php +++ b/src/Elcodi/Bridge/PaymentSuiteBridgeBundle/ElcodiPaymentSuiteBridgeBundle.php @@ -23,6 +23,7 @@ use Elcodi\Bridge\PaymentSuiteBridgeBundle\DependencyInjection\ElcodiPaymentSuiteBridgeExtension; use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class ElcodiPaymentSuiteBridgeBundle @@ -58,7 +59,7 @@ public function registerCommands(Application $application) * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'PaymentSuite\PaymentCoreBundle\PaymentCoreBundle', diff --git a/src/Elcodi/Bridge/VisithorBridgeBundle/ElcodiVisithorBridgeBundle.php b/src/Elcodi/Bridge/VisithorBridgeBundle/ElcodiVisithorBridgeBundle.php index 8c1965f2..faa35523 100644 --- a/src/Elcodi/Bridge/VisithorBridgeBundle/ElcodiVisithorBridgeBundle.php +++ b/src/Elcodi/Bridge/VisithorBridgeBundle/ElcodiVisithorBridgeBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Bridge\VisithorBridgeBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new ElcodiVisithorBridgeExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Common/CommonBundle/ElcodiCommonBundle.php b/src/Elcodi/Common/CommonBundle/ElcodiCommonBundle.php index 0614dd86..7325d642 100644 --- a/src/Elcodi/Common/CommonBundle/ElcodiCommonBundle.php +++ b/src/Elcodi/Common/CommonBundle/ElcodiCommonBundle.php @@ -44,6 +44,8 @@ public function getContainerExtension() * Disabled as commands are registered as services. * * @param Application $application An Application instance + * + * @return null */ public function registerCommands(Application $application) { diff --git a/src/Elcodi/Common/FirewallBundle/ElcodiFirewallBundle.php b/src/Elcodi/Common/FirewallBundle/ElcodiFirewallBundle.php index a5804fc5..d337590b 100644 --- a/src/Elcodi/Common/FirewallBundle/ElcodiFirewallBundle.php +++ b/src/Elcodi/Common/FirewallBundle/ElcodiFirewallBundle.php @@ -17,7 +17,9 @@ namespace Elcodi\Common\FirewallBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; use Elcodi\Common\FirewallBundle\CompilerPass\FirewallCompilerPass; @@ -45,4 +47,28 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new FirewallCompilerPass()); } + + /** + * Returns the bundle's container extension. + * + * @return ExtensionInterface The container extension + */ + public function getContainerExtension() + { + return null; + } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Plugin/CustomShippingBundle/DependencyInjection/ElcodiCustomShippingExtension.php b/src/Elcodi/Plugin/CustomShippingBundle/DependencyInjection/ElcodiCustomShippingExtension.php index 03f88cc8..141976c9 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/DependencyInjection/ElcodiCustomShippingExtension.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/DependencyInjection/ElcodiCustomShippingExtension.php @@ -112,6 +112,7 @@ public function getConfigFiles(array $config) 'directors', 'formTypes', 'menu', + 'services', ]; } diff --git a/src/Elcodi/Plugin/CustomShippingBundle/ElcodiCustomShippingBundle.php b/src/Elcodi/Plugin/CustomShippingBundle/ElcodiCustomShippingBundle.php index 1bb770f9..454b130b 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/ElcodiCustomShippingBundle.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/ElcodiCustomShippingBundle.php @@ -25,6 +25,7 @@ use Elcodi\Component\Plugin\Interfaces\PluginInterface; use Elcodi\Plugin\CustomShippingBundle\CompilerPass\MappingCompilerPass; use Elcodi\Plugin\CustomShippingBundle\DependencyInjection\ElcodiCustomShippingExtension; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class ElcodiCustomShippingBundle @@ -65,7 +66,7 @@ public function getContainerExtension() * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Bundle\CoreBundle\ElcodiCoreBundle', @@ -74,6 +75,7 @@ public static function getBundleDependencies() 'Elcodi\Bundle\CurrencyBundle\ElcodiCurrencyBundle', 'Elcodi\Bundle\EntityTranslatorBundle\ElcodiEntityTranslatorBundle', 'Elcodi\Bundle\MenuBundle\ElcodiMenuBundle', + new \Elcodi\Bundle\PluginBundle\ElcodiPluginBundle($kernel), ]; } } diff --git a/src/Elcodi/Plugin/CustomShippingBundle/EventListener/ShippingCollectEventListener.php b/src/Elcodi/Plugin/CustomShippingBundle/EventListener/ShippingCollectEventListener.php index 02819557..8df38b1b 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/EventListener/ShippingCollectEventListener.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/EventListener/ShippingCollectEventListener.php @@ -19,6 +19,7 @@ use Elcodi\Component\Cart\Entity\Interfaces\CartInterface; use Elcodi\Component\Currency\Services\CurrencyConverter; +use Elcodi\Component\Plugin\Entity\Plugin; use Elcodi\Component\Shipping\Entity\ShippingMethod; use Elcodi\Component\Shipping\Event\ShippingCollectionEvent; use Elcodi\Component\Zone\Services\ZoneMatcher; @@ -32,6 +33,13 @@ */ class ShippingCollectEventListener { + /** + * @var Plugin + * + * Plugin + */ + protected $plugin; + /** * @var CarrierRepository * @@ -56,15 +64,19 @@ class ShippingCollectEventListener /** * Construct method * + * @param Plugin $plugin Plugin * @param CarrierRepository $carrierRepository Carrier Repository * @param CurrencyConverter $currencyConverter Currency Converter * @param ZoneMatcher $zoneMatcher Zone matcher */ public function __construct( + Plugin $plugin, CarrierRepository $carrierRepository, CurrencyConverter $currencyConverter, ZoneMatcher $zoneMatcher - ) { + ) + { + $this->plugin = $plugin; $this->carrierRepository = $carrierRepository; $this->currencyConverter = $currencyConverter; $this->zoneMatcher = $zoneMatcher; @@ -79,6 +91,14 @@ public function __construct( */ public function addCustomShippingMethods(ShippingCollectionEvent $event) { + if (!$this + ->plugin + ->isEnabled() + ) { + + return $this; + } + $cart = $event->getCart(); $carrierRanges = $this->getAllShippingRangesSatisfiedWithCart($cart); @@ -137,7 +157,8 @@ private function getAllShippingRangesSatisfiedWithCart(CartInterface $cart) private function getShippingRangesSatisfiedByCart( CartInterface $cart, CarrierInterface $carrier - ) { + ) + { $shippingRanges = $carrier->getRanges(); $validShippingRanges = []; @@ -166,7 +187,8 @@ private function getShippingRangesSatisfiedByCart( private function isShippingRangeSatisfiedByCart( CartInterface $cart, ShippingRangeInterface $shippingRange - ) { + ) + { if ($shippingRange->getType() === ElcodiShippingRangeTypes::TYPE_PRICE) { return $this->isShippingPriceRangeSatisfiedByCart($cart, $shippingRange); } elseif ($shippingRange->getType() === ElcodiShippingRangeTypes::TYPE_WEIGHT) { @@ -187,7 +209,8 @@ private function isShippingRangeSatisfiedByCart( private function isShippingPriceRangeSatisfiedByCart( CartInterface $cart, ShippingRangeInterface $shippingRange - ) { + ) + { $cartPrice = $cart->getProductAmount(); $cartPriceCurrency = $cartPrice->getCurrency(); $shippingRangeFromPrice = $shippingRange->getFromPrice(); @@ -220,7 +243,8 @@ private function isShippingPriceRangeSatisfiedByCart( private function isShippingWeightRangeSatisfiedByCart( CartInterface $cart, ShippingRangeInterface $shippingRange - ) { + ) + { $cartWeight = $cart->getWeight(); $cartRangeFromWeight = $shippingRange->getFromWeight(); $cartRangeToWeight = $shippingRange->getToWeight(); @@ -246,7 +270,8 @@ private function isShippingWeightRangeSatisfiedByCart( private function isShippingRangeZonesSatisfiedByCart( CartInterface $cart, ShippingRangeInterface $shippingRange - ) { + ) + { $deliveryAddress = $cart->getDeliveryAddress(); return diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/eventListeners.yml b/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/eventListeners.yml index 9fdb2f73..6c08b60b 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/eventListeners.yml +++ b/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/eventListeners.yml @@ -6,6 +6,7 @@ services: elcodi_plugin.custom_shipping.event_listener.shipping_collect: class: Elcodi\Plugin\CustomShippingBundle\EventListener\ShippingCollectEventListener arguments: + - @elcodi_plugin.custom_shipping - @elcodi.repository.carrier - @elcodi.converter.currency - @elcodi.matcher.zone diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/services.yml b/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/services.yml new file mode 100644 index 00000000..4e9e5c1c --- /dev/null +++ b/src/Elcodi/Plugin/CustomShippingBundle/Resources/config/services.yml @@ -0,0 +1,9 @@ +services: + + # + # Plugin + # + elcodi_plugin.custom_shipping: + parent: elcodi.abstract_plugin + arguments: + - "Elcodi\\Plugin\\CustomShippingBundle\\ElcodiCustomShippingBundle" diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Builder/MenuBuilderTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Builder/MenuBuilderTest.php index 1e003b29..a2ddf4af 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Builder/MenuBuilderTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Builder/MenuBuilderTest.php @@ -24,16 +24,6 @@ */ class MenuBuilderTest extends WebTestCase { - /** - * Schema must be loaded in all test cases - * - * @return boolean Load schema - */ - protected function loadSchema() - { - return false; - } - /** * Returns the callable name of the service * diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/EventListener/ShippingCollectEventListenerTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/EventListener/ShippingCollectEventListenerTest.php index 6903118d..37f1d43e 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/EventListener/ShippingCollectEventListenerTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/EventListener/ShippingCollectEventListenerTest.php @@ -31,7 +31,7 @@ class ShippingCollectEventListenerTest extends WebTestCase */ protected function loadSchema() { - return false; + return true; } /** diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierFactoryTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierFactoryTest.php index e1397f8f..c4bdcafd 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierFactoryTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierFactoryTest.php @@ -24,16 +24,6 @@ */ class CarrierFactoryTest extends WebTestCase { - /** - * Schema must be loaded in all test cases - * - * @return boolean Load schema - */ - protected function loadSchema() - { - return false; - } - /** * Returns the callable name of the service * diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierRangeFactoryTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/ShippingRangeFactoryTest.php similarity index 78% rename from src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierRangeFactoryTest.php rename to src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/ShippingRangeFactoryTest.php index 69e1878e..70007c19 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/CarrierRangeFactoryTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Factory/ShippingRangeFactoryTest.php @@ -22,18 +22,8 @@ /** * Class ShippingRangeFactoryTest */ -class CarrierRangeFactoryTest extends WebTestCase +class ShippingRangeFactoryTest extends WebTestCase { - /** - * Schema must be loaded in all test cases - * - * @return boolean Load schema - */ - protected function loadSchema() - { - return false; - } - /** * Returns the callable name of the service * diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/CarrierTypeTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/CarrierTypeTest.php new file mode 100644 index 00000000..5f0d4150 --- /dev/null +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/CarrierTypeTest.php @@ -0,0 +1,36 @@ + + * @author Aldo Chiecchia + * @author Elcodi Team + */ + +namespace Elcodi\Plugin\CustomShippingBundle\Tests\Functional\Form\Type; + +use Elcodi\Bundle\TestCommonBundle\Functional\WebTestCase; + +/** + * Class CarrierTypeTest + */ +class CarrierTypeTest extends WebTestCase +{ + /** + * Returns the callable name of the service + * + * @return string[] service name + */ + public function getServiceCallableName() + { + return ['elcodi_plugin.custom_shipping.form_type.carrier']; + } +} diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/ShippingRangeTypeTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/ShippingRangeTypeTest.php new file mode 100644 index 00000000..e37765be --- /dev/null +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Form/Type/ShippingRangeTypeTest.php @@ -0,0 +1,36 @@ + + * @author Aldo Chiecchia + * @author Elcodi Team + */ + +namespace Elcodi\Plugin\CustomShippingBundle\Tests\Functional\Form\Type; + +use Elcodi\Bundle\TestCommonBundle\Functional\WebTestCase; + +/** + * Class ShippingRangeTypeTest + */ +class ShippingRangeTypeTest extends WebTestCase +{ + /** + * Returns the callable name of the service + * + * @return string[] service name + */ + public function getServiceCallableName() + { + return ['elcodi_plugin.custom_shipping.form_type.shipping_range']; + } +} diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/CarrierRepositoryTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/CarrierRepositoryTest.php index bccddd97..3c69351d 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/CarrierRepositoryTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/CarrierRepositoryTest.php @@ -24,18 +24,6 @@ */ class CarrierRepositoryTest extends WebTestCase { - /** - * Returns the callable name of the service - * - * @return string[] service name - */ - public function getServiceCallableName() - { - return [ - 'elcodi.repository.carrier', - ]; - } - /** * Test carrier repository provider */ diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/ShippingRangeRepositoryTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/ShippingRangeRepositoryTest.php index 95385106..db646e36 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/ShippingRangeRepositoryTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/Repository/ShippingRangeRepositoryTest.php @@ -24,18 +24,6 @@ */ class ShippingRangeRepositoryTest extends WebTestCase { - /** - * Returns the callable name of the service - * - * @return string[] service name - */ - public function getServiceCallableName() - { - return [ - 'elcodi.repository.shipping_range', - ]; - } - /** * Test shipping_base_range repository provider */ diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/app/AppKernel.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/app/AppKernel.php index 4db0486e..6a05182d 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/app/AppKernel.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/Functional/app/AppKernel.php @@ -34,7 +34,7 @@ class AppKernel extends AbstractElcodiKernel */ public function registerBundles() { - return $this->getBundleInstances([ + return $this->getBundleInstances($this, [ 'Symfony\Bundle\FrameworkBundle\FrameworkBundle', 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle', 'Elcodi\Plugin\CustomShippingBundle\ElcodiCustomShippingBundle', diff --git a/src/Elcodi/Plugin/CustomShippingBundle/Tests/UnitTest/EventListener/ShippingCollectEventListenerTest.php b/src/Elcodi/Plugin/CustomShippingBundle/Tests/UnitTest/EventListener/ShippingCollectEventListenerTest.php index d77eaf1e..d3207771 100644 --- a/src/Elcodi/Plugin/CustomShippingBundle/Tests/UnitTest/EventListener/ShippingCollectEventListenerTest.php +++ b/src/Elcodi/Plugin/CustomShippingBundle/Tests/UnitTest/EventListener/ShippingCollectEventListenerTest.php @@ -18,6 +18,7 @@ namespace Elcodi\Plugin\CustomShippingBundle\Tests\UnitTest\EventListener; use Doctrine\Common\Collections\ArrayCollection; +use Elcodi\Component\Plugin\Entity\Plugin; use PHPUnit_Framework_TestCase; use Prophecy\Argument; @@ -37,6 +38,7 @@ /** * Class ShippingCollectEventListenerTest * + * * Test with disabled plugin * * Test with no carriers * * Test with carrier without ranges * * Test with matching price @@ -49,6 +51,51 @@ */ class ShippingCollectEventListenerTest extends PHPUnit_Framework_TestCase { + /** + * Test with matching price + */ + public function testWithDisabledPlugin() + { + $carrierRepository = $this->getBuiltCarrierRepository( + true, + 500, + 1200, + 700 + ); + + $event = $this->getEvent(); + $event + ->addShippingMethod(\Prophecy\Argument::exact( + new ShippingMethod( + 'custom-shipping-method-price-shipping-range-id', + 'test-carrier', + 'price-shipping-range-name', + '', + Money::create( + 700, + $this->getCurrency() + ) + ) + )) + ->shouldBeCalledTimes(0); + + $event + ->getCart() + ->willReturn( + $this + ->getCart() + ->reveal() + ); + + $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getDisabledPlugin()->reveal(), + $carrierRepository->reveal(), + $this->getCurrencyConverter(1)->reveal(), + $this->getZoneMatcher()->reveal() + ); + $shippingCollectEventListener->addCustomShippingMethods($event->reveal()); + } + /** * Test with no carriers */ @@ -65,6 +112,7 @@ public function testWithNoCarriers() ->willReturn($this->getCart()->reveal()); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(0)->reveal(), $this->getZoneMatcher()->reveal() @@ -88,6 +136,7 @@ public function testWithCarrierWithoutRanges() ->willReturn($this->getCart()->reveal()); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(0)->reveal(), $this->getZoneMatcher()->reveal() @@ -132,6 +181,7 @@ public function testWithMatchingPrice() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(1)->reveal(), $this->getZoneMatcher()->reveal() @@ -165,6 +215,7 @@ public function testWithoutMatchingPrice() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(1)->reveal(), $this->getZoneMatcher()->reveal() @@ -212,6 +263,7 @@ public function testWithMatchingWeight() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(1)->reveal(), $this->getZoneMatcher()->reveal() @@ -248,6 +300,7 @@ public function testWithoutMatchingWeight() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(1)->reveal(), $this->getZoneMatcher()->reveal() @@ -292,6 +345,7 @@ public function testWithDifferentCurrenciesMatching() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(2)->reveal(), $this->getZoneMatcher()->reveal() @@ -325,6 +379,7 @@ public function testWithDifferentCurrenciesWithoutMatching() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(2)->reveal(), $this->getZoneMatcher()->reveal() @@ -361,6 +416,7 @@ public function testWithMatchingPriceAndWeight() ); $shippingCollectEventListener = new ShippingCollectEventListener( + $this->getEnabledPlugin()->reveal(), $carrierRepository->reveal(), $this->getCurrencyConverter(1)->reveal(), $this->getZoneMatcher()->reveal() @@ -618,4 +674,36 @@ private function getCurrency() return $currency; } + + /** + * Get disabled plugin + * + * @return Plugin $plugin + */ + private function getDisabledPlugin() + { + $plugin = $this->prophesize('Elcodi\Component\Plugin\Entity\Plugin'); + + $plugin + ->isEnabled() + ->willReturn(false); + + return $plugin; + } + + /** + * Get enabled plugin + * + * @return Plugin $plugin + */ + private function getEnabledPlugin() + { + $plugin = $this->prophesize('Elcodi\Component\Plugin\Entity\Plugin'); + + $plugin + ->isEnabled() + ->willReturn(true); + + return $plugin; + } } diff --git a/src/Elcodi/Plugin/FreePaymentBundle/ElcodiFreePaymentBundle.php b/src/Elcodi/Plugin/FreePaymentBundle/ElcodiFreePaymentBundle.php index 8ef5cc6f..a5406ab3 100644 --- a/src/Elcodi/Plugin/FreePaymentBundle/ElcodiFreePaymentBundle.php +++ b/src/Elcodi/Plugin/FreePaymentBundle/ElcodiFreePaymentBundle.php @@ -24,6 +24,7 @@ use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; use Elcodi\Component\Plugin\Interfaces\PluginInterface; use Elcodi\Plugin\FreePaymentBundle\DependencyInjection\ElcodiFreePaymentExtension; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class ElcodiFreePaymentBundle @@ -59,7 +60,7 @@ public function registerCommands(Application $application) * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Bridge\PaymentSuiteBridgeBundle\ElcodiPaymentSuiteBridgeBundle', diff --git a/src/Elcodi/Plugin/PaypalWebCheckoutBundle/ElcodiPaypalWebCheckoutBundle.php b/src/Elcodi/Plugin/PaypalWebCheckoutBundle/ElcodiPaypalWebCheckoutBundle.php index f5184705..ce578f09 100644 --- a/src/Elcodi/Plugin/PaypalWebCheckoutBundle/ElcodiPaypalWebCheckoutBundle.php +++ b/src/Elcodi/Plugin/PaypalWebCheckoutBundle/ElcodiPaypalWebCheckoutBundle.php @@ -24,6 +24,7 @@ use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; use Elcodi\Component\Plugin\Interfaces\PluginInterface; use Elcodi\Plugin\PaypalWebCheckoutBundle\DependencyInjection\ElcodiPaypalWebCheckoutExtension; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class ElcodiPaypalWebCheckoutBundle @@ -59,7 +60,7 @@ public function registerCommands(Application $application) * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Bridge\PaymentSuiteBridgeBundle\ElcodiPaymentSuiteBridgeBundle', diff --git a/src/Elcodi/Plugin/StripeBundle/ElcodiStripeBundle.php b/src/Elcodi/Plugin/StripeBundle/ElcodiStripeBundle.php index 12931ddc..c9d6685c 100644 --- a/src/Elcodi/Plugin/StripeBundle/ElcodiStripeBundle.php +++ b/src/Elcodi/Plugin/StripeBundle/ElcodiStripeBundle.php @@ -24,6 +24,7 @@ use Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface; use Elcodi\Component\Plugin\Interfaces\PluginInterface; use Elcodi\Plugin\StripeBundle\DependencyInjection\ElcodiStripeExtension; +use Symfony\Component\HttpKernel\KernelInterface; /** * Class ElcodiStripeBundle @@ -59,7 +60,7 @@ public function registerCommands(Application $application) * * @return array Bundle instances */ - public static function getBundleDependencies() + public static function getBundleDependencies(KernelInterface $kernel) { return [ 'Elcodi\Bridge\PaymentSuiteBridgeBundle\ElcodiPaymentSuiteBridgeBundle', diff --git a/src/Elcodi/Store/CartBundle/StoreCartBundle.php b/src/Elcodi/Store/CartBundle/StoreCartBundle.php index ac7a57d9..7235e000 100644 --- a/src/Elcodi/Store/CartBundle/StoreCartBundle.php +++ b/src/Elcodi/Store/CartBundle/StoreCartBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\CartBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreCartExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/CartCouponBundle/StoreCartCouponBundle.php b/src/Elcodi/Store/CartCouponBundle/StoreCartCouponBundle.php index 2a852c77..1fa932cf 100644 --- a/src/Elcodi/Store/CartCouponBundle/StoreCartCouponBundle.php +++ b/src/Elcodi/Store/CartCouponBundle/StoreCartCouponBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\CartCouponBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreCartCouponExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/ConnectBundle/StoreConnectBundle.php b/src/Elcodi/Store/ConnectBundle/StoreConnectBundle.php index 9a510ac4..d129dec9 100644 --- a/src/Elcodi/Store/ConnectBundle/StoreConnectBundle.php +++ b/src/Elcodi/Store/ConnectBundle/StoreConnectBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\ConnectBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -31,6 +32,23 @@ */ class StoreConnectBundle extends Bundle { + /** + * Builds the bundle. + * + * It is only ever called once when the cache is empty. + * + * This method can be overridden to register compilation passes, + * other extensions, ... + * + * @param ContainerBuilder $container A ContainerBuilder instance + */ + public function build(ContainerBuilder $container) + { + parent::build($container); + + $container->addCompilerPass(new MappingCompilerPass()); + } + /** * Returns the bundle's container extension. * @@ -42,19 +60,16 @@ public function getContainerExtension() } /** - * Builds the bundle. + * Register Commands. * - * It is only ever called once when the cache is empty. + * Disabled as commands are registered as services. * - * This method can be overridden to register compilation passes, - * other extensions, ... + * @param Application $application An Application instance * - * @param ContainerBuilder $container A ContainerBuilder instance + * @return null */ - public function build(ContainerBuilder $container) + public function registerCommands(Application $application) { - parent::build($container); - - $container->addCompilerPass(new MappingCompilerPass()); + return null; } } diff --git a/src/Elcodi/Store/CoreBundle/StoreCoreBundle.php b/src/Elcodi/Store/CoreBundle/StoreCoreBundle.php index 82f7da53..5f0d1535 100644 --- a/src/Elcodi/Store/CoreBundle/StoreCoreBundle.php +++ b/src/Elcodi/Store/CoreBundle/StoreCoreBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\CoreBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreCoreExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/CurrencyBundle/StoreCurrencyBundle.php b/src/Elcodi/Store/CurrencyBundle/StoreCurrencyBundle.php index 48bc5afc..b13574c7 100644 --- a/src/Elcodi/Store/CurrencyBundle/StoreCurrencyBundle.php +++ b/src/Elcodi/Store/CurrencyBundle/StoreCurrencyBundle.php @@ -17,6 +17,8 @@ namespace Elcodi\Store\CurrencyBundle; +use Symfony\Component\Console\Application; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; /** @@ -24,4 +26,27 @@ */ class StoreCurrencyBundle extends Bundle { + /** + * Returns the bundle's container extension. + * + * @return ExtensionInterface The container extension + */ + public function getContainerExtension() + { + return null; + } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/FallbackBundle/StoreFallbackBundle.php b/src/Elcodi/Store/FallbackBundle/StoreFallbackBundle.php index 77cc5c11..88292775 100644 --- a/src/Elcodi/Store/FallbackBundle/StoreFallbackBundle.php +++ b/src/Elcodi/Store/FallbackBundle/StoreFallbackBundle.php @@ -17,6 +17,8 @@ namespace Elcodi\Store\FallbackBundle; +use Symfony\Component\Console\Application; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; /** @@ -24,4 +26,27 @@ */ class StoreFallbackBundle extends Bundle { + /** + * Returns the bundle's container extension. + * + * @return ExtensionInterface The container extension + */ + public function getContainerExtension() + { + return null; + } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/GeoBundle/StoreGeoBundle.php b/src/Elcodi/Store/GeoBundle/StoreGeoBundle.php index 3935f2af..c592b0db 100644 --- a/src/Elcodi/Store/GeoBundle/StoreGeoBundle.php +++ b/src/Elcodi/Store/GeoBundle/StoreGeoBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\GeoBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreGeoExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/LanguageBundle/StoreLanguageBundle.php b/src/Elcodi/Store/LanguageBundle/StoreLanguageBundle.php index 19163158..577d94ec 100644 --- a/src/Elcodi/Store/LanguageBundle/StoreLanguageBundle.php +++ b/src/Elcodi/Store/LanguageBundle/StoreLanguageBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\LanguageBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -34,4 +35,18 @@ public function getContainerExtension() { return null; } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/MetricBundle/StoreMetricBundle.php b/src/Elcodi/Store/MetricBundle/StoreMetricBundle.php index a34fcd3c..93261c85 100644 --- a/src/Elcodi/Store/MetricBundle/StoreMetricBundle.php +++ b/src/Elcodi/Store/MetricBundle/StoreMetricBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\MetricBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreMetricExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/OverrideBundle/StoreOverrideBundle.php b/src/Elcodi/Store/OverrideBundle/StoreOverrideBundle.php index 0c41ab7a..d094d47d 100644 --- a/src/Elcodi/Store/OverrideBundle/StoreOverrideBundle.php +++ b/src/Elcodi/Store/OverrideBundle/StoreOverrideBundle.php @@ -17,6 +17,8 @@ namespace Elcodi\Store\OverrideBundle; +use Symfony\Component\Console\Application; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; /** @@ -24,4 +26,27 @@ */ class StoreOverrideBundle extends Bundle { + /** + * Returns the bundle's container extension. + * + * @return ExtensionInterface The container extension + */ + public function getContainerExtension() + { + return null; + } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/PageBundle/StorePageBundle.php b/src/Elcodi/Store/PageBundle/StorePageBundle.php index 8e077f08..72b0a9d7 100644 --- a/src/Elcodi/Store/PageBundle/StorePageBundle.php +++ b/src/Elcodi/Store/PageBundle/StorePageBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\PageBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StorePageExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/ProductBundle/StoreProductBundle.php b/src/Elcodi/Store/ProductBundle/StoreProductBundle.php index a2dfcbbe..1528d4b4 100644 --- a/src/Elcodi/Store/ProductBundle/StoreProductBundle.php +++ b/src/Elcodi/Store/ProductBundle/StoreProductBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\ProductBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreProductExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } } diff --git a/src/Elcodi/Store/UserBundle/StoreUserBundle.php b/src/Elcodi/Store/UserBundle/StoreUserBundle.php index 8398894f..3edd10ef 100644 --- a/src/Elcodi/Store/UserBundle/StoreUserBundle.php +++ b/src/Elcodi/Store/UserBundle/StoreUserBundle.php @@ -17,6 +17,7 @@ namespace Elcodi\Store\UserBundle; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -36,4 +37,18 @@ public function getContainerExtension() { return new StoreUserExtension(); } + + /** + * Register Commands. + * + * Disabled as commands are registered as services. + * + * @param Application $application An Application instance + * + * @return null + */ + public function registerCommands(Application $application) + { + return null; + } }