public function buildPopupContent($node = FALSE) {
    $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';

    if ($node) {
      // Check special cases (0 or 1 available location).
      $locations = ClassBranchesForm::getBranchesList($node);
      $locations = $locations['branch'] + $locations['camp'];
      if (!$locations) {
        // Show 'Class unavailable' popup.
        return new InvokeCommand('#class-expired-modal', 'modal', ['show']);
      }
      elseif (count($locations) == 1) {
        // Automatically select the only available location.
        $nid = array_keys($locations)[0];
        $event_params = [
          'location' => $nid,
          'only' => TRUE,
        ];
        $params = ['location-changed', [$event_params]];
        return new InvokeCommand('body', 'trigger', $params);
      }
      $form = \Drupal::formBuilder()->getForm(ClassBranchesForm::class, $node, $destination);
    }
    else {
      $form = \Drupal::formBuilder()->getForm(BranchesForm::class, $destination);
    }

    $config = \Drupal::config('openy_popups.settings');
    $img_src = '';
    if ($config->get('img')) {
      $file = File::load($config->get('img'));
      $img_src = ImageStyle::load('locations_popup')->buildUrl($file->getFileUri());
    }

    return [
      '#theme' => 'openy_popup',
      '#image' => $img_src,
      '#description' => $config->get('description'),
      '#form' => $form,
    ];
  }
public function buildPopupContent($node = FALSE) {
    $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';

    if ($node) {
      // Check special cases (0 or 1 available location).
      $locations = ClassBranchesForm::getBranchesList($node);
      $locations = $locations['branch'] + $locations['camp'];
      if (!$locations) {
        // Show 'Class unavailable' popup.
        return new InvokeCommand('#class-expired-modal', 'modal', ['show']);
      }
      elseif (count($locations) == 1) {
        // Automatically select the only available location.
        $nid = array_keys($locations)[0];
        $event_params = [
          'location' => $nid,
          'only' => TRUE,
        ];
        $params = ['location-changed', [$event_params]];
        return new InvokeCommand('body', 'trigger', $params);
      }
      $form = \Drupal::formBuilder()->getForm(ClassBranchesForm::class, $node, $destination);
    }
    else {
      $form = \Drupal::formBuilder()->getForm(BranchesForm::class, $destination);
    }

    $config = \Drupal::config('openy_popups.settings');
    $img_src = '';
    if ($config->get('img')) {
      $file = File::load($config->get('img'));
      $img_src = ImageStyle::load('locations_popup')->buildUrl($file->getFileUri());
    }

    return [
      '#theme' => 'openy_popup',
      '#image' => $img_src,
      '#description' => $config->get('description'),
      '#form' => $form,
    ];
  }
public function buildPopupContent ( $ node = FALSE ) { $ destination = isset ( $ _REQUEST [ 'destination' ] ) ? $ _REQUEST [ 'destination' ] : '' ; if ( $ node ) { // Check special cases (0 or 1 available location). $ locations = ClassBranchesForm :: getBranchesList ( $ node ) ; $ locations = $ locations [ 'branch' ] + $ locations [ 'camp' ] ; if ( ! $ locations ) { // Show 'Class unavailable' popup. return new InvokeCommand ( '#class-expired-modal' , 'modal' , [ 'show' ] ) ; } elseif ( count ( $ locations ) == 1 ) { // Automatically select the only available location. $ nid = array_keys ( $ locations ) [ 0 ] ; $ event_params = [ 'location' => $ nid , 'only' => TRUE , ] ; $ params = [ 'location-changed' , [ $ event_params ] ] ; return new InvokeCommand ( 'body' , 'trigger' , $ params ) ; } $ form = \ Drupal :: formBuilder ( ) -> getForm ( ClassBranchesForm :: class , $ node , $ destination ) ; } else { $ form = \ Drupal :: formBuilder ( ) -> getForm ( BranchesForm :: class , $ destination ) ; } $ config = \ Drupal :: config ( 'openy_popups.settings' ) ; $ img_src = '' ; if ( $ config -> get ( 'img' ) ) { $ file = File :: load ( $ config -> get ( 'img' ) ) ; $ img_src = ImageStyle :: load ( 'locations_popup' ) -> buildUrl ( $ file -> getFileUri ( ) ) ; } return [ '#theme' => 'openy_popup' , '#image' => $ img_src , '#description' => $ config -> get ( 'description' ) , '#form' => $ form , ] ; }
Popup Content.
Popup Content .