Completed
Push — master ( d7020d...a4700d )
by Daniel
06:50
created

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
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Silverback\ApiComponentBundle\DataTransformer;
4
5
use Silverback\ApiComponentBundle\Entity\Content\Page\Dynamic\DynamicContent;
6
use Silverback\ApiComponentBundle\Repository\Content\Page\DynamicPageRepository;
7
8
final class DynamicContentDataTransformer extends AbstractDataTransformer
9
{
10
    /**
11
     * @param DynamicContent $object
12
     */
13
    public function transform($object, array $context = []): DynamicContent
14
    {
15
        /** @var DynamicPageRepository $repository */
16
        $repository = $this->container->get(DynamicPageRepository::class);
17
        $dynamicPage = $repository->findOneBy([
18
            'dynamicPageClass' => \get_class($object)
19
        ]);
20
        $object->setDynamicPage($dynamicPage);
21
        return $object;
22
    }
23
24
    public function supportsTransformation($data, array $context = []): bool
25
    {
26
        return $data instanceof DynamicContent;
27
    }
28
29
    public static function getSubscribedServices(): array
30
    {
31
        return [
32
            '?' . DynamicPageRepository::class
33
        ];
34
    }
35
}
36