Completed
Push — develop ( e72854...0832ef )
by Daniel
06:46
created

RouteAwareModifier::getSubscribedServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\DataModifier;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Silverback\ApiComponentBundle\Entity\Route\RouteAwareInterface;
7
use Silverback\ApiComponentBundle\Factory\RouteFactory;
8
9
class RouteAwareModifier extends AbstractModifier
10
{
11
    /**
12
     * @param RouteAwareInterface $object
13
     * @param array $context
14
     * @param null|string $format
15
     * @return object|void
16
     */
17
    public function process($object, array $context = array(), ?string $format = null)
18
    {
19
        /** @var RouteFactory $routeFactory */
20
        $routeFactory = $this->container->get(RouteFactory::class);
21
        /** @var EntityManagerInterface $em */
22
        $em = $this->container->get(EntityManagerInterface::class);
23
        $routeFactory->createPageRoute($object, $em);
24
        $em->flush();
25
    }
26
27
    public function supportsData($data): bool
28
    {
29
        return $data instanceof RouteAwareInterface;
30
    }
31
32
    public static function getSubscribedServices(): array
33
    {
34
        return [
35
            '?' . RouteFactory::class,
36
            '?' . EntityManagerInterface::class
37
        ];
38
    }
39
}
40