Benjamin Cremer
shopware AG
Feedback @benjamincremer
SwagPromotion
├── Resources
│ ├── snippets
│ ├── views
│ └── services.xml
├── Services
├── Controllers
├── Models
├── plugin.xml
├── phpunit.xml.dist
└── SwagPromotion.php
$this->container->get('SwagMyService.SomeService');
class Shopware_Plugins_Frontend_SwagMyService_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
$this->subscribeEvent(
'Enlight_Bootstrap_InitResource_SwagMyService.SomeService',
'onInitSomeService'
);
return true;
}
public function onInitSomeService(Enlight_Event_EventArgs $args)
{
return new SomeService(
$this->container->get('database_connection')
);
}
}
<service id="SwagMyService.SomeService" class="SwagMyService\SomeService">
<argument type="service" id="database_service"/>
</service>
$this->container->get('validator.email');
class Shopware_Plugins_Frontend_SwagMyMailValidator_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
$this->subscribeEvent(
'Enlight_Bootstrap_InitResource_validator.email',
'onValidatorInit'
);
return true;
}
public function onValidatorInit(Enlight_Event_EventArgs $args)
{
return new MyEmailValidator();
}
}
<service id="SwagMail.MyMailValidator"
decorates="validator.email"
class="SwagMail\MyEmailValidator">
<argument type="service" id="SwagRedis.RedisProductService.inner"/>
</service>
$this->container->get('shopware_storefront.list_product_service');
class Shopware_Plugins_Frontend_SwagRedis_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
$this->subscribeEvent(
'Enlight_Bootstrap_AfterInitResource_shopware_storefront.list_product_service',
'decorateService'
);
return true;
}
public function decorateService()
{
$coreService = $this->container->get('shopware_storefront.list_product_service');
$redisService = new RedisProductService($coreService);
$this->container->set('shopware_storefront.list_product_service', $redisService);
}
}
<service id="SwagRedis.RedisProductService"
decorates="shopware_storefront.list_product_service"
class="SwagRedis\RedisProductService">
<argument type="service" id="SwagRedis.RedisProductService.inner"/>
</service>
CLI Commands
ConditionHandler
PasswordEncoder
class Shopware_Plugins_Frontend_SwagExample_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
public function install()
{
$this->subscribeEvent(
'Shopware_SearchBundleDBAL_Collect_Condition_Handlers',
'collectConditionHandlers'
);
return true;
}
public function collectConditionHandlers()
{
return new ArrayCollection(array(
new FooConditionHandler();
new BarConditionHandler();
));
}
}
<service id="SwagExample.FooConditionHandler" class="SwagExample\FooConditionHandler">
<tag name="condition_handler_dbal" />
</service>
<service id="SwagExample.BarConditionHandler" class="SwagExample\BarConditionHandler">
<tag name="condition_handler_dbal" />
</service>
<service id="theme_backend_registration" class="Shopware\Components\Theme\EventListener\BackendTheme">
<argument type="service" id="database_connection" />
<tag name="shopware.event_listener" method="registerBackendTheme" event="Enlight_Controller_Front_RouteShutdown" />
</service>
Please leave feedback
joind.in/talk/f71d8
talks.benjamin-cremer.de/scd2016_plugin
@benjamincremer