@@ -56,143 +56,4 @@ public function getDerivativeDefinitions($basePluginDefinition) {
5656 return parent ::getDerivativeDefinitions ($ basePluginDefinition );
5757 }
5858
59- /**
60- * Helper function to return the contextual filter argument if any exist.
61- *
62- * @param array $arguments
63- * The array of available arguments.
64- * @param $id
65- * The plugin derivative id.
66- *
67- * @return array
68- * The contextual filter argument if applicable.
69- */
70- protected function getContextualArguments (array $ arguments , $ id ) {
71- if (!empty ($ arguments )) {
72- return [
73- 'contextualFilter ' => [
74- 'type ' => StringHelper::camelCase ($ id , 'contextual ' , 'filter ' , 'input ' ),
75- ],
76- ];
77- }
78-
79- return [];
80- }
81-
82- /**
83- * Helper function to retrieve the sort arguments if any are exposed.
84- *
85- * @param \Drupal\views\Plugin\views\display\DisplayPluginInterface $display
86- * The display plugin.
87- * @param $id
88- * The plugin derivative id.
89- *
90- * @return array
91- * The sort arguments if any exposed sorts are available.
92- */
93- protected function getSortArguments (DisplayPluginInterface $ display , $ id ) {
94- $ sorts = array_filter ($ display ->getOption ('sorts ' ) ?: [], function ($ sort ) {
95- return $ sort ['exposed ' ];
96- });
97- return $ sorts ? [
98- 'sortDirection ' => [
99- 'type ' => 'ViewSortDirection ' ,
100- 'default ' => 'asc ' ,
101- ],
102- 'sortBy ' => [
103- 'type ' => StringHelper::camelCase ($ id , 'sort ' , 'by ' ),
104- ],
105- ] : [];
106- }
107-
108- /**
109- * Helper function to return the filter argument if applicable.
110- *
111- * @param \Drupal\views\Plugin\views\display\DisplayPluginInterface $display
112- * The display plugin.
113- * @param $id
114- * The plugin derivative id.
115- *
116- * @return array
117- * The filter argument if any exposed filters are available.
118- */
119- protected function getFilterArguments (DisplayPluginInterface $ display , $ id ) {
120- $ filters = array_filter ($ display ->getOption ('filters ' ) ?: [], function ($ filter ) {
121- return array_key_exists ('exposed ' , $ filter ) && $ filter ['exposed ' ];
122- });
123-
124- return !empty ($ filters ) ? [
125- 'filter ' => [
126- 'type ' => $ display ->getGraphQLFilterInputName (),
127- ],
128- ] : [];
129- }
130-
131- /**
132- * Helper function to retrieve the pager arguments if the display is paged.
133- *
134- * @param \Drupal\views\Plugin\views\display\DisplayPluginInterface $display
135- * The display plugin.
136- *
137- * @return array
138- * An array of pager arguments if the view display is paged.
139- */
140- protected function getPagerArguments (DisplayPluginInterface $ display ) {
141- return $ this ->isPaged ($ display ) ? [
142- 'page ' => ['type ' => 'Int ' , 'default ' => $ this ->getPagerOffset ($ display )],
143- 'pageSize ' => ['type ' => 'Int ' , 'default ' => $ this ->getPagerLimit ($ display )],
144- ] : [];
145- }
146-
147- /**
148- * Helper function to retrieve the types that the view can be attached to.
149- *
150- * @param \Drupal\views\Plugin\views\display\DisplayPluginInterface $display
151- * The display plugin.
152- * @param array $arguments
153- * An array containing information about the available arguments.
154- * @return array
155- * An array of additional types the view can be embedded in.
156- */
157- protected function getTypes (DisplayPluginInterface $ display , array $ arguments ) {
158- $ types = ['Root ' ];
159-
160- if (($ entity_type = $ display ->getOption ('entity_type ' ))) {
161- $ types = array_merge ($ types , [StringHelper::camelCase ($ entity_type )]);
162-
163- if (($ bundles = $ display ->getOption ('bundles ' ))) {
164- $ types = array_merge ($ types , array_map (function ($ bundle ) use ($ entity_type ) {
165- return StringHelper::camelCase ($ entity_type , $ bundle );
166- }, $ bundles ));
167- }
168- }
169-
170- if (empty ($ arguments )) {
171- return $ types ;
172- }
173-
174- foreach ($ arguments as $ argument ) {
175- // Depending on whether bundles are known, we expose the view field
176- // either on the interface (e.g. Node) or on the type (e.g. NodePage)
177- // level. Here we specify types managed by other graphql_* modules,
178- // yet we don't define these modules as dependencies. If types are not
179- // in the schema, the resulting GraphQL field will be attached to
180- // nowhere, so it won't go into the schema.
181- if (empty ($ argument ['bundles ' ]) && empty ($ argument ['entity_type ' ])) {
182- continue ;
183- }
184-
185- if (empty ($ argument ['bundles ' ])) {
186- $ types = array_merge ($ types , [StringHelper::camelCase ($ argument ['entity_type ' ])]);
187- }
188- else {
189- $ types = array_merge ($ types , array_map (function ($ bundle ) use ($ argument ) {
190- return StringHelper::camelCase ($ argument ['entity_type ' ], $ bundle );
191- }, array_keys ($ argument ['bundles ' ])));
192- }
193- }
194-
195- return $ types ;
196- }
197-
19859}
0 commit comments