-
Notifications
You must be signed in to change notification settings - Fork 5
/
FroshMailCatcher.php
51 lines (45 loc) · 1.26 KB
/
FroshMailCatcher.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
<?php
namespace FroshMailCatcher;
use Doctrine\ORM\Tools\SchemaTool;
use FroshMailCatcher\Models\Attachment;
use FroshMailCatcher\Models\Mails;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UpdateContext;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Class FroshMailCatcher
*/
class FroshMailCatcher extends Plugin
{
/**
* @param InstallContext $context
*/
public function install(InstallContext $context)
{
$this->updateDatabase();
}
/**
* @param UpdateContext $context
*/
public function update(UpdateContext $context)
{
$this->updateDatabase();
}
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->setParameter('frosh_mail_catcher.plugin_dir', $this->getPath());
}
private function updateDatabase()
{
$tool = new SchemaTool($this->container->get('models'));
$tool->updateSchema([
$this->container->get('models')->getClassMetadata(Mails::class),
$this->container->get('models')->getClassMetadata(Attachment::class),
], true);
}
}