1111use Drupal \Core \PageCache \ResponsePolicy \KillSwitch ;
1212use Drupal \Core \Render \RendererInterface ;
1313use Drupal \Core \Session \AccountInterface ;
14+ use Drupal \Core \State \StateInterface ;
1415use Drupal \Core \Url ;
1516use Drupal \oit \Plugin \BlockUuidQuery ;
1617use Drupal \oit \Plugin \ServiceHealth ;
1718use Drupal \shortcode_svg \Plugin \ShortcodeIcon ;
1819use Drupal \views \Views ;
1920use Symfony \Component \DependencyInjection \ContainerInterface ;
21+ use Symfony \Component \HttpFoundation \JsonResponse ;
2022use Symfony \Component \HttpFoundation \RedirectResponse ;
2123use Symfony \Component \HttpFoundation \RequestStack ;
2224
@@ -102,6 +104,13 @@ class OitController extends ControllerBase {
102104 */
103105 protected $ shortcodeSvgIcon ;
104106
107+ /**
108+ * The state service.
109+ *
110+ * @var \Drupal\Core\State\StateInterface
111+ */
112+ protected $ state ;
113+
105114 /**
106115 * Constructs request stuff.
107116 *
@@ -127,6 +136,8 @@ class OitController extends ControllerBase {
127136 * Load entity.
128137 * @param \Drupal\shortcode_svg\Plugin\ShortcodeIcon $shortcode_svg_icon
129138 * Call shortcode svg icon.
139+ * @param \Drupal\Core\State\StateInterface $state
140+ * The state service.
130141 */
131142 public function __construct (
132143 AccountInterface $ account ,
@@ -140,6 +151,7 @@ public function __construct(
140151 ServiceHealth $ service_health ,
141152 EntityTypeManagerInterface $ entity_type_manager ,
142153 ShortcodeIcon $ shortcode_svg_icon ,
154+ StateInterface $ state ,
143155 ) {
144156 $ this ->account = $ account ;
145157 $ this ->requestStack = $ request_stack ->getCurrentRequest ();
@@ -152,6 +164,7 @@ public function __construct(
152164 $ this ->serviceHealth = $ service_health ;
153165 $ this ->entityTypeManager = $ entity_type_manager ;
154166 $ this ->shortcodeSvgIcon = $ shortcode_svg_icon ;
167+ $ this ->state = $ state ;
155168 }
156169
157170 /**
@@ -169,7 +182,8 @@ public static function create(ContainerInterface $container): self {
169182 $ container ->get ('renderer ' ),
170183 $ container ->get ('oit.servicehealth ' ),
171184 $ container ->get ('entity_type.manager ' ),
172- $ container ->get ('shortcode_svg.icon ' )
185+ $ container ->get ('shortcode_svg.icon ' ),
186+ $ container ->get ('state ' )
173187 );
174188 }
175189
@@ -291,7 +305,37 @@ public function oitSamlLogin() {
291305 }
292306
293307 /**
294- * Routes for zap.
308+ * Routes for cron json.
309+ */
310+ public function oitCronJson () {
311+ // Get state 'oit_dashboard_delete'.
312+ $ dashboard_delete = $ this ->state ->get ('oit_dashboard_delete ' );
313+ if ($ dashboard_delete == NULL || $ dashboard_delete == '' || $ dashboard_delete == '[] ' ) {
314+ $ dash_delete = FALSE ;
315+ }
316+ else {
317+ $ dash_delete = TRUE ;
318+ }
319+
320+ $ dashboard_add = $ this ->state ->get ('oit_dashboard_add ' );
321+
322+ if ($ dashboard_add == NULL || $ dashboard_add == '' || $ dashboard_add == '[] ' ) {
323+ $ dash_add = FALSE ;
324+ }
325+ else {
326+ $ dash_add = TRUE ;
327+ }
328+
329+ $ response = new JsonResponse (['dashboard_delete ' => $ dash_delete , 'dashboard_add ' => $ dash_add ]);
330+
331+ // Disable page caching for this response.
332+ $ this ->killSwitch ->trigger ();
333+
334+ return $ response ;
335+ }
336+
337+ /**
338+ * Routes for denied.
295339 */
296340 public function oitDenied () {
297341 $ content = $ this ->deniedContent ();
0 commit comments