1 | <?php |
||
24 | class LoadCollectionRouteArticles extends AbstractFixture implements FixtureInterface, OrderedFixtureInterface |
||
25 | { |
||
26 | private $manager; |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 7 | public function load(ObjectManager $manager) |
|
32 | { |
||
33 | 7 | $this->manager = $manager; |
|
34 | 7 | $env = $this->getEnvironment(); |
|
35 | |||
36 | 7 | if ('test' !== $env) { |
|
37 | return; |
||
38 | } |
||
39 | |||
40 | 7 | $this->loadRoutes($env, $manager); |
|
41 | 7 | $this->loadArticles($env, $manager); |
|
42 | 7 | $this->setRoutesContent($env, $manager); |
|
43 | |||
44 | 7 | $manager->flush(); |
|
45 | 7 | } |
|
46 | |||
47 | 7 | public function loadRoutes($env, ObjectManager $manager) |
|
48 | { |
||
49 | $routes = [ |
||
50 | 'test' => [ |
||
51 | [ |
||
52 | 'name' => 'collection-no-template', |
||
53 | 'type' => 'collection', |
||
54 | ], |
||
55 | [ |
||
56 | 'name' => 'collection-test', |
||
57 | 'type' => 'collection', |
||
58 | 'template_name' => 'collection.html.twig', |
||
59 | ], |
||
60 | [ |
||
61 | 'name' => 'collection-content', |
||
62 | 'type' => 'collection', |
||
63 | 'articles_template_name' => 'test.html.twig', |
||
64 | ], |
||
65 | [ |
||
66 | 'name' => 'collection-with-content', |
||
67 | 'type' => 'collection', |
||
68 | 'articles_template_name' => 'test.html.twig', |
||
69 | ], |
||
70 | 7 | ], |
|
71 | ]; |
||
72 | |||
73 | 7 | $routeService = $this->container->get('swp.service.route'); |
|
74 | |||
75 | 7 | foreach ($routes[$env] as $routeData) { |
|
76 | 7 | $route = $this->container->get('swp.factory.route')->create(); |
|
77 | 7 | $route->setName($routeData['name']); |
|
78 | 7 | $route->setType($routeData['type']); |
|
79 | |||
80 | 7 | if (isset($routeData['template_name'])) { |
|
81 | 7 | $route->setTemplateName($routeData['template_name']); |
|
82 | } |
||
83 | |||
84 | 7 | if (isset($routeData['articles_template_name'])) { |
|
85 | 7 | $route->setArticlesTemplateName($routeData['articles_template_name']); |
|
86 | } |
||
87 | |||
88 | 7 | $routeService->createRoute($route); |
|
89 | |||
90 | 7 | $manager->persist($route); |
|
91 | } |
||
92 | |||
93 | 7 | $manager->flush(); |
|
94 | 7 | } |
|
95 | |||
96 | 7 | public function setRoutesContent($env, $manager) |
|
118 | |||
119 | 7 | public function loadArticles($env, $manager) |
|
185 | |||
186 | /** |
||
187 | * {@inheritdoc} |
||
188 | */ |
||
189 | 7 | public function getOrder() |
|
193 | } |
||
194 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.