Guest User

Untitled

a guest
Aug 12th, 2015
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Aquatuning Software Development - Bundle - Subscriber
  5. *
  6. * @category Aquatuning
  7. * @package Shopware\Plugins\AtsdBundle
  8. * @copyright Copyright (c) 2013, Aquatuning GmbH
  9. */
  10.  
  11. namespace Shopware\AtsdBundle\Subscriber;
  12.  
  13.  
  14.  
  15. /**
  16. * Aquatuning Software Development - Bundle - Subscriber
  17. */
  18.  
  19. class ServiceContainer implements \Enlight\Event\SubscriberInterface
  20. {
  21.  
  22. /**
  23. * Main bootstrap object.
  24. *
  25. * @var \Shopware_Components_Plugin_Bootstrap
  26. */
  27.  
  28. protected $bootstrap;
  29.  
  30.  
  31.  
  32. /**
  33. * DI container.
  34. *
  35. * @var \Shopware\Components\DependencyInjection\Container
  36. */
  37.  
  38. protected $container;
  39.  
  40.  
  41.  
  42.  
  43.  
  44. /**
  45. * ...
  46. *
  47. * @param \Shopware_Components_Plugin_Bootstrap $bootstrap
  48. * @param \Shopware\Components\DependencyInjection\Container $container
  49. *
  50. * @return \Shopware\AtsdBundle\Subscriber\ServiceContainer
  51. */
  52.  
  53. public function __construct( \Shopware_Components_Plugin_Bootstrap $bootstrap, \Shopware\Components\DependencyInjection\Container $container )
  54. {
  55. // set params
  56. $this->bootstrap = $bootstrap;
  57. $this->container = $container;
  58. }
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. /**
  66. * Return the subscribed controller events.
  67. *
  68. * @return array
  69. */
  70.  
  71. public static function getSubscribedEvents()
  72. {
  73. // return the events
  74. return array(
  75. 'Enlight_Bootstrap_InitResource_atsd_bundle.component' => 'getComponent',
  76. 'Enlight_Bootstrap_InitResource_AtsdBundle' => 'getComponent',
  77. 'Enlight_Bootstrap_AfterInitResource_shopware_storefront.list_product_service' => "afterListProductService",
  78. 'Enlight_Bootstrap_InitResource_atsd_bundle.bundle_service' => 'getService',
  79. );
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. /**
  90. * ...
  91. *
  92. * @return \Shopware\AtsdBundle\Components\AtsdBundle
  93. */
  94.  
  95. public function getComponent()
  96. {
  97. // ...
  98. return new \Shopware\AtsdBundle\Components\AtsdBundle(
  99. $this->bootstrap,
  100. $this->container
  101. );
  102. }
  103.  
  104.  
  105.  
  106.  
  107.  
  108. /**
  109. * ...
  110. *
  111. * @return void
  112. */
  113.  
  114. public function afterListProductService()
  115. {
  116. // get the services
  117. $coreService = $this->container->get( "shopware_storefront.list_product_service" );
  118. $component = $this->container->get( "atsd_bundle.component" );
  119. $bundleService = $this->container->get( "atsd_bundle.bundle_service" );
  120.  
  121. // create our own component and set the core service
  122. $service = new \Shopware\AtsdBundle\Bundle\StoreFrontBundle\ListProductService(
  123. $coreService,
  124. $bundleService,
  125. $component,
  126. $this->container
  127. );
  128.  
  129. // and replace it
  130. $this->container->set( "shopware_storefront.list_product_service", $service );
  131.  
  132. // done
  133. return;
  134. }
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141. /**
  142. * ...
  143. *
  144. * @return \Shopware\AtsdBundle\Bundle\StoreFrontBundle\BundleService
  145. */
  146.  
  147. public function getService()
  148. {
  149. // ...
  150. return new \Shopware\AtsdBundle\Bundle\StoreFrontBundle\BundleService(
  151. $this->container->get( "shopware.model_manager" ),
  152. $this->container->get( "atsd_bundle.component" ),
  153. $this->container
  154. );
  155. }
  156.  
  157.  
  158.  
  159.  
  160. }
Advertisement
Add Comment
Please, Sign In to add comment