-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPluginManager.php
57 lines (50 loc) · 1.65 KB
/
PluginManager.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
56
57
<?php
/*
* This file is part of Auth0 for EC-CUBE
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Auth0;
use Doctrine\ORM\EntityManagerInterface;
use Eccube\Plugin\AbstractPluginManager;
use Plugin\Auth0\Entity\Config;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
class PluginManager extends AbstractPluginManager
{
/**
* @param array $meta
* @param ContainerInterface $container
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function enable(array $meta, ContainerInterface $container): void
{
/** @var EntityManagerInterface $entityManager */
$entityManager = $container->get('doctrine.orm.entity_manager');
$Config = $entityManager->getRepository(Config::class)->find(Config::ID);
if (!$Config) {
$Config = new Config();
$entityManager->persist($Config);
$entityManager->flush();
}
}
public function update(array $meta, ContainerInterface $container): void
{
/** @var EntityManagerInterface $entityManager */
$entityManager = $container->get('doctrine.orm.entity_manager');
$Config = $entityManager->getRepository(Config::class)->find(Config::ID);
if (!$Config) {
$Config = new Config();
$entityManager->persist($Config);
$entityManager->flush();
}
}
}