1 | <?php |
||
13 | class AdminNode extends BaseAdmin |
||
14 | { |
||
15 | protected $baseRouteName = 'alpixel_admin_cms_node'; |
||
16 | protected $baseRoutePattern = 'node'; |
||
17 | protected $classnameLabel = 'pages'; |
||
18 | |||
19 | protected $datagridValues = [ |
||
20 | '_page' => 1, |
||
21 | '_sort_order' => 'DESC', |
||
22 | '_sort_by' => 'dateUpdated', |
||
23 | ]; |
||
24 | |||
25 | protected function configureRoutes(RouteCollection $collection) |
||
26 | { |
||
27 | $collection->clearExcept(['list', 'batch', 'delete']); |
||
28 | $collection->add('forwardEdit'); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | protected function configureDatagridFilters(DatagridMapper $datagridMapper) |
||
37 | { |
||
38 | $container = $this->getConfigurationPool()->getContainer(); |
||
39 | $entityManager = $container->get('doctrine.orm.default_entity_manager'); |
||
40 | $datagridMapper |
||
41 | ->add('locale', 'doctrine_orm_callback', [ |
||
42 | 'label' => 'Langue', |
||
43 | 'callback' => function (ProxyQuery $queryBuilder, $alias, $field, $value) { |
||
44 | if (!$value['value']) { |
||
45 | return false; |
||
46 | } |
||
47 | $queryBuilder |
||
48 | ->andWhere($alias.'.locale = :locale') |
||
49 | ->setParameter('locale', $value['value']); |
||
50 | |||
51 | return true; |
||
52 | }, |
||
53 | ], |
||
54 | 'choice', |
||
55 | [ |
||
56 | 'choices' => $this->getRealLocales(), |
||
57 | ]) |
||
58 | ->add('title', null, [ |
||
59 | 'label' => 'Page', |
||
60 | ]) |
||
61 | ->add('published', null, [ |
||
62 | 'label' => 'Publié', |
||
63 | ]) |
||
64 | ->add('node', 'doctrine_orm_callback', [ |
||
65 | 'label' => 'Type de contenu', |
||
66 | 'callback' => function (ProxyQuery $queryBuilder, $alias, $field, $value) use ($entityManager) { |
||
67 | if (!$value['value']) { |
||
68 | return false; |
||
69 | } |
||
70 | // We can't query the type from the AlpixelCMSBundle:Node repository (InheritanceType) because of that |
||
71 | // we try to get the repository in AppBundle with the value which is the class name of entity. :pig: |
||
72 | try { |
||
73 | $repository = $entityManager->getRepository(sprintf('AppBundle:%s', ucfirst($value['value']))); |
||
74 | } catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) { |
||
75 | return false; |
||
76 | } |
||
77 | $data = $repository->findAll(); |
||
78 | if (empty($data)) { |
||
79 | return false; |
||
80 | } |
||
81 | $queryBuilder |
||
82 | ->andWhere($alias.'.id IN (:ids)') |
||
83 | ->setParameter('ids', $data); |
||
84 | |||
85 | return true; |
||
86 | }, |
||
87 | ], |
||
88 | 'choice', |
||
89 | [ |
||
90 | 'choices' => $this->getCMSEntityTypes(), |
||
91 | ] |
||
92 | ); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper |
||
97 | * |
||
98 | * @return void |
||
99 | */ |
||
100 | protected function configureListFields(ListMapper $listMapper) |
||
101 | { |
||
102 | $listMapper |
||
103 | ->add('id') |
||
104 | ->add('locale', null, [ |
||
105 | 'label' => 'Langue', |
||
106 | ]) |
||
107 | ->add('title', null, [ |
||
108 | 'label' => 'Page', |
||
109 | ]) |
||
110 | ->add('type', null, [ |
||
111 | 'label' => 'Type', |
||
112 | 'template' => 'AlpixelCMSBundle:admin:fields/list__field_type.html.twig', |
||
113 | ]) |
||
114 | ->add('dateCreated', null, [ |
||
115 | 'label' => 'Date de création', |
||
116 | ]) |
||
117 | ->add('dateUpdated', null, [ |
||
118 | 'label' => 'Date d\'édition', |
||
119 | ]) |
||
120 | ->add('published', null, [ |
||
121 | 'label' => 'Publié', |
||
122 | ]) |
||
123 | ->add('_action', 'actions', [ |
||
124 | 'actions' => [ |
||
125 | 'see' => ['template' => 'AlpixelCMSBundle:admin:fields/list__action_see.html.twig'], |
||
126 | 'edit' => ['template' => 'AlpixelCMSBundle:admin:fields/list__action_edit.html.twig'], |
||
127 | 'delete' => ['template' => 'AlpixelCMSBundle:admin:fields/list__action_delete.html.twig'], |
||
128 | ], |
||
129 | ]); |
||
130 | } |
||
131 | |||
132 | public function buildBreadcrumbs($action, MenuItemInterface $menu = null) |
||
150 | |||
151 | public function createQuery($context = 'list') |
||
152 | { |
||
153 | $container = $this->getConfigurationPool()->getContainer(); |
||
199 | } |
||
200 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.