Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Aquatuning Software Development - Bundle - Subscriber
- *
- * @category Aquatuning
- * @package Shopware\Plugins\AtsdBundle
- * @copyright Copyright (c) 2013, Aquatuning GmbH
- */
- namespace Shopware\AtsdBundle\Subscriber;
- /**
- * Aquatuning Software Development - Bundle - Subscriber
- */
- class ServiceContainer implements \Enlight\Event\SubscriberInterface
- {
- /**
- * Main bootstrap object.
- *
- * @var \Shopware_Components_Plugin_Bootstrap
- */
- protected $bootstrap;
- /**
- * DI container.
- *
- * @var \Shopware\Components\DependencyInjection\Container
- */
- protected $container;
- /**
- * ...
- *
- * @param \Shopware_Components_Plugin_Bootstrap $bootstrap
- * @param \Shopware\Components\DependencyInjection\Container $container
- *
- * @return \Shopware\AtsdBundle\Subscriber\ServiceContainer
- */
- public function __construct( \Shopware_Components_Plugin_Bootstrap $bootstrap, \Shopware\Components\DependencyInjection\Container $container )
- {
- // set params
- $this->bootstrap = $bootstrap;
- $this->container = $container;
- }
- /**
- * Return the subscribed controller events.
- *
- * @return array
- */
- public static function getSubscribedEvents()
- {
- // return the events
- return array(
- 'Enlight_Bootstrap_InitResource_atsd_bundle.component' => 'getComponent',
- 'Enlight_Bootstrap_InitResource_AtsdBundle' => 'getComponent',
- 'Enlight_Bootstrap_AfterInitResource_shopware_storefront.list_product_service' => "afterListProductService",
- 'Enlight_Bootstrap_InitResource_atsd_bundle.bundle_service' => 'getService',
- );
- }
- /**
- * ...
- *
- * @return \Shopware\AtsdBundle\Components\AtsdBundle
- */
- public function getComponent()
- {
- // ...
- return new \Shopware\AtsdBundle\Components\AtsdBundle(
- $this->bootstrap,
- $this->container
- );
- }
- /**
- * ...
- *
- * @return void
- */
- public function afterListProductService()
- {
- // get the services
- $coreService = $this->container->get( "shopware_storefront.list_product_service" );
- $component = $this->container->get( "atsd_bundle.component" );
- $bundleService = $this->container->get( "atsd_bundle.bundle_service" );
- // create our own component and set the core service
- $service = new \Shopware\AtsdBundle\Bundle\StoreFrontBundle\ListProductService(
- $coreService,
- $bundleService,
- $component,
- $this->container
- );
- // and replace it
- $this->container->set( "shopware_storefront.list_product_service", $service );
- // done
- return;
- }
- /**
- * ...
- *
- * @return \Shopware\AtsdBundle\Bundle\StoreFrontBundle\BundleService
- */
- public function getService()
- {
- // ...
- return new \Shopware\AtsdBundle\Bundle\StoreFrontBundle\BundleService(
- $this->container->get( "shopware.model_manager" ),
- $this->container->get( "atsd_bundle.component" ),
- $this->container
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment