DigitalState /
Cms
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Controller; |
||
| 4 | |||
| 5 | use App\Service\DataService; |
||
| 6 | use App\Service\FileService; |
||
| 7 | use App\Service\TextService; |
||
| 8 | use stdClass; |
||
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use Symfony\Component\HttpFoundation\RequestStack; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\RequestStack was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 11 | |||
| 12 | use ApiPlatform\Core\Annotation\ApiResource; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Core\Annotation\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
||
|
0 ignored issues
–
show
The type
Sensio\Bundle\FrameworkE...le\Configuration\Method was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
||
|
0 ignored issues
–
show
The type
Sensio\Bundle\FrameworkE...\Configuration\Security was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use Symfony\Component\Routing\Annotation\Route; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Routing\Annotation\Route was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | |||
| 17 | /** |
||
| 18 | * Class ContentController |
||
| 19 | * |
||
| 20 | * @ApiResource |
||
| 21 | */ |
||
| 22 | final class ContentController |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var \Symfony\Component\HttpFoundation\RequestStack |
||
| 26 | */ |
||
| 27 | private $requestStack; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var \App\Service\DataService |
||
| 31 | */ |
||
| 32 | private $dataService; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var \App\Service\FileService |
||
| 36 | */ |
||
| 37 | private $fileService; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var \App\Service\TextService |
||
| 41 | */ |
||
| 42 | private $textService; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Constructor |
||
| 46 | * |
||
| 47 | * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack |
||
| 48 | * @param \App\Service\DataService $dataService |
||
| 49 | * @param \App\Service\FileService $fileService |
||
| 50 | * @param \App\Service\TextService $textService |
||
| 51 | */ |
||
| 52 | public function __construct(RequestStack $requestStack, DataService $dataService, FileService $fileService, TextService $textService) |
||
| 53 | { |
||
| 54 | $this->requestStack = $requestStack; |
||
| 55 | $this->dataService = $dataService; |
||
| 56 | $this->fileService = $fileService; |
||
| 57 | $this->textService = $textService; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Content |
||
| 62 | * |
||
| 63 | * @Route(path="/content", methods={"GET"}) |
||
| 64 | * @Security("is_granted('BROWSE', 'content')") |
||
| 65 | */ |
||
| 66 | public function get() |
||
| 67 | { |
||
| 68 | $request = $this->requestStack->getCurrentRequest(); |
||
| 69 | $types = ['data', 'file', 'text']; |
||
| 70 | $content = new StdClass; |
||
| 71 | |||
| 72 | foreach ($types as $type) { |
||
| 73 | $slugs = $request->query->get($type.'s', []); |
||
| 74 | |||
| 75 | if ($slugs) { |
||
| 76 | $collection = $type.'s'; |
||
| 77 | $service = $type.'Service'; |
||
| 78 | $content->$collection = new stdClass; |
||
| 79 | $entities = $this->$service->getRepository()->findBy(['slug' => $slugs]); |
||
| 80 | |||
| 81 | foreach ($slugs as $slug) { |
||
| 82 | $content->$collection->$slug = null; |
||
| 83 | |||
| 84 | foreach ($entities as $entity) { |
||
| 85 | if ($entity->getSlug() !== $slug) { |
||
| 86 | continue; |
||
| 87 | } |
||
| 88 | |||
| 89 | $content->$collection->$slug = new stdClass; |
||
| 90 | |||
| 91 | switch ($type) { |
||
| 92 | case 'data': |
||
| 93 | $content->$collection->$slug = $entity->getData(); |
||
| 94 | break; |
||
| 95 | |||
| 96 | case 'file': |
||
| 97 | $content->$collection->$slug->type = $entity->getType(); |
||
| 98 | $content->$collection->$slug->presentation = $entity->getPresentation(); |
||
| 99 | break; |
||
| 100 | |||
| 101 | case 'text': |
||
| 102 | $content->$collection->$slug = $entity->getValue(); |
||
| 103 | break; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | return new JsonResponse($content); |
||
| 111 | } |
||
| 112 | } |
||
| 113 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths