This repository was archived by the owner on Jun 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBucoOrderDocumentsApi.php
More file actions
58 lines (47 loc) · 1.53 KB
/
Copy pathBucoOrderDocumentsApi.php
File metadata and controls
58 lines (47 loc) · 1.53 KB
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
56
57
58
<?php
namespace BucoOrderDocumentsApi;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\DeactivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;
use Shopware\Models\Plugin\Plugin;
class BucoOrderDocumentsApi extends \Shopware\Components\Plugin
{
const CACHE_LIST = [InstallContext::CACHE_TAG_ROUTER];
public function install(InstallContext $context)
{
$this->addApiAcls();
}
public function activate(ActivateContext $context)
{
$context->scheduleClearCache(self::CACHE_LIST);
}
public function deactivate(DeactivateContext $context)
{
$context->scheduleClearCache(self::CACHE_LIST);
}
public function uninstall(UninstallContext $context)
{
if(!$context->keepUserData()) {
$this->removeApiAcls();
}
}
private function addApiAcls()
{
$aclService = $this->container->get('acl');
$em = $this->container->get('models');
/** @var Plugin $pluginModel */
$pluginModel = $em->getRepository(Plugin::class)->findOneBy(['name' => $this->getName()]);
$aclService->createResource(
'BucoOrderDocuments',
['create', 'read'],
null,
$pluginModel ? $pluginModel->getId() : null
);
}
private function removeApiAcls()
{
$aclService = $this->container->get('acl');
$aclService->deleteResource('BucoOrderDocuments');
}
}