Test Failed
Push — develop ( 92c10d...ff12cf )
by Daniel
05:05
created

DynamicContentModifier::getSubscribedServices()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
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 Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic\DynamicContent;
6
use Silverback\ApiComponentBundle\Repository\Content\Page\DynamicPageRepository;
7
8
class DynamicContentModifier extends AbstractModifier
9
{
10
    /**
11
     * @param DynamicContent $page
12
     * @param array $context
13
     * @param null|string $format
14
     * @return object|void
15
     */
16
    public function process($page, array $context = array(), ?string $format = null)
17
    {
18
        /** @var DynamicPageRepository $repository */
19
        $repository = $this->container->get(DynamicPageRepository::class);
20
        $dynamicPage = $repository->findOneBy([
21
            'dynamicPageClass' => \get_class($page)
22
        ]);
23
        $page->setDynamicPage($dynamicPage);
24
    }
25
26
    public function supportsData($data): bool
27
    {
28
        return $data instanceof DynamicContent;
29
    }
30
31
    public static function getSubscribedServices(): array
32
    {
33
        return [
34
            '?' . DynamicPageRepository::class
35
        ];
36
    }
37
}
38