-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimklHideSingleValueFacet.php
55 lines (47 loc) · 1.55 KB
/
SimklHideSingleValueFacet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace SimklHideSingleValueFacet;
use Shopware\Components\Plugin;
use Shopware\Models\Shop\Shop;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
/**
* Shopware-Plugin SimklHideSingleValueFacet.
*/
class SimklHideSingleValueFacet extends Plugin
{
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
'Enlight_Controller_Action_PreDispatch' => 'registerTemplateDir',
'Enlight_Controller_Action_PreDispatch_Widgets' => 'registerTemplateDir'
];
}
/**
* adds our template dir
* @param \Enlight_Event_EventArgs $args
*/
public function registerTemplateDir(\Enlight_Event_EventArgs $args)
{
/** @var Plugin\CachedConfigReader $configReader */
$configReader = $this->container->get('shopware.plugin.cached_config_reader');
$config = $configReader->getByPluginName('SimklHideSingleValueFacet');
try {
/** @var Shop $shop */
$shop = $this->container->get('shop');
if ($shop instanceof Shop) {
$config = $configReader->getByPluginName('SimklHideSingleValueFacet', $shop);
}
} catch(ServiceNotFoundException $e) {
// shop unknown
}
if (!$config['enabled']) {
return;
}
/** @var $controller \Enlight_Controller_Action */
$controller = $args->getSubject();
$view = $controller->View();
$view->addTemplateDir(__DIR__ . '/Resources/views');
}
}