You are here

private function ParagraphsBrowserController::setModalHeightAndWidth in Paragraphs Browser 8

Parameters

$field_config:

1 call to ParagraphsBrowserController::setModalHeightAndWidth()
ParagraphsBrowserController::paragraphsBrowserSelect in src/Controller/ParagraphsBrowserController.php
Route callback that returns the Paragraphs Browser form within a modal.

File

src/Controller/ParagraphsBrowserController.php, line 38

Class

ParagraphsBrowserController
Class EntityBrowserController.

Namespace

Drupal\paragraphs_browser\Controller

Code

private function setModalHeightAndWidth($field_config) {
  $field_name = $field_config
    ->getName();
  $entity_type = $field_config
    ->getTargetEntityTypeId();
  $bundle = $field_config
    ->getTargetBundle();
  $settings = \Drupal::service('entity_display.repository')
    ->getFormDisplay($entity_type, $bundle, 'default');
  $modal_height = !empty($settings
    ->getComponent($field_name)) ? $settings
    ->getComponent($field_name)['settings']['modal_height'] : '';
  $modal_width = !empty($settings
    ->getComponent($field_name)) ? $settings
    ->getComponent($field_name)['settings']['modal_width'] : '';
  if ($modal_height !== "auto") {
    $modal_height = (int) $modal_height;
  }

  // Use default height and width if either of these values is empty
  $this->modal_height = !empty($modal_height) ? $modal_height : 'auto';
  $this->modal_width = !empty($modal_width) ? $modal_width : '80%';
}