You are here

public function PopupOnloadController::getPopup in Popup On Load 8

Get popup.

Return value

\Symfony\Component\HttpFoundation\Response Return response with popup settings.

1 string reference to 'PopupOnloadController::getPopup'
popup_onload.routing.yml in ./popup_onload.routing.yml
popup_onload.routing.yml

File

src/Controller/PopupOnloadController.php, line 19

Class

PopupOnloadController
Class PopupOnloadController.

Namespace

Drupal\popup_onload\Controller

Code

public function getPopup() {
  $response = new Response();
  $popups = popup_onload_get_popups_all();
  foreach ($popups as $key => $popup) {
    if (isset($popup->path->value)) {
      if (popup_onload_check_path($popup->path->value) && popup_onload_check_display_conditions($popup)) {
        $popup_settings = popup_onload_prepare_popup($popup);
        $response
          ->setContent(json_encode($popup_settings));
        drupal_static(POPUP_ONLOAD_IS_POPUP_ADDED, TRUE);
        popup_onload_save_time_cookie($popup);
        break;
      }
    }
    else {
      if (popup_onload_check_path('') && popup_onload_check_display_conditions($popup)) {
        $popup_settings = popup_onload_prepare_popup($popup);
        $response
          ->setContent(json_encode($popup_settings));
        drupal_static(POPUP_ONLOAD_IS_POPUP_ADDED, TRUE);
        popup_onload_save_time_cookie($popup);
        break;
      }
    }
  }
  return $response;
}