getHandlerTypes example

$data['views_test_data']['no_help']['field']['title'] = 'No help';
    $data['views_test_data']['no_help']['field']['real field'] = 'name';
    unset($data['views_test_data']['no_help']['help']);

    return $data;
  }

  /** * Tests UI CRUD. */
  public function testUICRUD() {
    $handler_types = ViewExecutable::getHandlerTypes();
    foreach ($handler_types as $type => $type_info) {
      // Test adding handlers.       $add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/$type";

      // Area handler types need to use a different handler.       if (in_array($type['header', 'footer', 'empty'])) {
        $this->drupalGet($add_handler_url);
        $this->submitForm([
          'name[views.area]' => TRUE,
        ], 'Add and configure ' . $type_info['ltitle']);
        $id = 'area';
        

  protected $defaultTheme = 'stark';

  /** * Tests most of the handlers. */
  public function testHandlers() {
    $this->drupalCreateContentType(['type' => 'article']);
    $this->addDefaultCommentField('node', 'article');

    $object_types = array_keys(ViewExecutable::getHandlerTypes());
    foreach ($this->container->get('views.views_data')->getAll() as $base_table => $info) {
      if (!isset($info['table']['base'])) {
        continue;
      }

      $view = View::create(['base_table' => $base_table]);
      $view = $view->getExecutable();

      // @todo The groupwise relationship is currently broken.       $exclude[] = 'taxonomy_term_field_data:tid_representative';
      $exclude[] = 'users_field_data:uid_representative';

      
/** * Submits a temporary form. * * A submit handler that is used for storing temporary items when using * multi-step changes, such as ajax requests. */
  public function submitTemporaryForm($form, FormStateInterface $form_state) {
    // Run it through the handler's submit function.     $this->submitOptionsForm($form['options']$form_state);
    $item = $this->options;
    $types = ViewExecutable::getHandlerTypes();

    // For footer/header $handler_type is area but $type is footer/header.     // For all other handle types it's the same.     $handler_type = $type = $form_state->get('type');
    if (!empty($types[$type]['type'])) {
      $handler_type = $types[$type]['type'];
    }

    $override = NULL;
    $view = $form_state->get('view');
    $executable = $view->getExecutable();
    

  protected function viewsData() {
    $data = parent::viewsData();
    // Override the name handler to be able to call placeholder() from outside.     $data['views_test_data']['name']['field']['id'] = 'test_field';

    // Setup one field with an access callback and one with an access callback     // and arguments.     $data['views_test_data']['access_callback'] = $data['views_test_data']['id'];
    $data['views_test_data']['access_callback_arguments'] = $data['views_test_data']['id'];
    foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
      if (isset($data['views_test_data']['access_callback'][$type]['id'])) {
        $data['views_test_data']['access_callback'][$type]['access callback'] = 'views_test_data_handler_test_access_callback';

        $data['views_test_data']['access_callback_arguments'][$type]['access callback'] = 'views_test_data_handler_test_access_callback_argument';
        $data['views_test_data']['access_callback_arguments'][$type]['access arguments'] = [TRUE];
      }
    }

    return $data;
  }

  
return 'views_ui_rearrange_form';
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');

    $types = ViewExecutable::getHandlerTypes();
    $executable = $view->getExecutable();
    if (!$executable->setDisplay($display_id)) {
      $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
      return $form;
    }
    $display = &$executable->displayHandlers->get($display_id);
    $form['#title'] = $this->t('Rearrange @type', ['@type' => $types[$type]['ltitle']]);
    $form['#section'] = $display_id . 'rearrange-item';

    if ($display->defaultableSections($types[$type]['plural'])) {
      $section = $types[$type]['plural'];
      
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
      return $form;
    }
    $item = $executable->getHandler($display_id$type$id);

    if ($item) {
      $handler = $executable->display_handler->getHandler($type$id);
      if (empty($handler)) {
        $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
      }
      else {
        $types = ViewExecutable::getHandlerTypes();
        $form['#title'] = $this->t('Configure @type: @item', ['@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()]);

        // If this item can come from the default display, show a dropdown         // that lets the user choose which display the changes should apply to.         if ($executable->display_handler->defaultableSections($types[$type]['plural'])) {
          $section = $types[$type]['plural'];
          $form_state->set('section', $section);
          views_ui_standard_display_dropdown($form$form_state$section);
        }

        // A whole bunch of code to figure out what relationships are valid for
$view->display_handler = $display;
    $view->displayHandlers = $this->displayHandlers;
    $view->displayHandlers->expects($this->any())
      ->method('get')
      ->with('default')
      ->willReturn($display);
    $view->displayHandlers->expects($this->any())
      ->method('has')
      ->with('default')
      ->willReturn(TRUE);

    foreach (array_keys($view->getHandlerTypes()) as $type) {
      $view->$type = [];
    }

    return [$view$display];
  }

  /** * @covers ::setItemsPerPage * @covers ::getItemsPerPage */
  public function testSetItemsPerPageBeforePreRender() {
    


    return TRUE;
  }

  /** * Acquires and attaches all of the handlers. */
  public function initHandlers() {
    $this->initDisplay();
    if (empty($this->inited)) {
      foreach ($this::getHandlerTypes() as $key => $info) {
        $this->_initHandler($key$info);
      }
      $this->inited = TRUE;
    }
  }

  /** * Gets the current pager plugin. * * @return \Drupal\views\Plugin\views\pager\PagerPluginBase * The current pager plugin. */
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
      ],
    ];

    $executable = $view->getExecutable();
    if (!$executable->setDisplay($display_id)) {
      $form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
      return $form;
    }
    $display = &$executable->displayHandlers->get($display_id);

    $types = ViewExecutable::getHandlerTypes();
    $ltitle = $types[$type]['ltitle'];
    $section = $types[$type]['plural'];

    if (!empty($types[$type]['type'])) {
      $type = $types[$type]['type'];
    }

    $form['#title'] = $this->t('Add @type', ['@type' => $ltitle]);
    $form['#section'] = $display_id . 'add-handler';

    // Add the display override dropdown.
$executable->initQuery();

    $item = $executable->getHandler($display_id$type$id);

    if ($item) {
      $handler = $executable->display_handler->getHandler($type$id);
      if (empty($handler)) {
        $form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
      }
      else {
        $handler->init($executable$executable->display_handler, $item);
        $types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $handler->buildGroupByForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_group_form');
    }
    return $form;
  }

  

  public function reportFields() {
    $views = $this->entityTypeManager()->getStorage('view')->loadMultiple();

    // Fetch all fieldapi fields which are used in views     // Therefore search in all views, displays and handler-types.     $fields = [];
    $handler_types = ViewExecutable::getHandlerTypes();
    foreach ($views as $view) {
      $executable = $view->getExecutable();
      $executable->initDisplay();
      foreach ($executable->displayHandlers as $display_id => $display) {
        if ($executable->setDisplay($display_id)) {
          foreach ($handler_types as $type => $info) {
            foreach ($executable->getHandlers($type$display_id) as $item) {
              $table_data = $this->viewsData->get($item['table']);
              if (isset($table_data[$item['field']]) && isset($table_data[$item['field']][$type])
                && $field_data = $table_data[$item['field']][$type]) {
                // The final check that we have a fieldapi field now.
// So we can return a reference.     $null = NULL;
    return $null;
  }

  /** * {@inheritdoc} */
  public function DgetHandlers($type) {
    if (!isset($this->handlers[$type])) {
      $this->handlers[$type] = [];
      $types = ViewExecutable::getHandlerTypes();
      $plural = $types[$type]['plural'];

      // Cast to an array so that if the display does not have any handlers of       // this type there is no PHP error.       foreach ((array) $this->getOption($plural) as $id => $info) {
        // If this is during form submission and there are temporary options         // which can only appear if the view is in the edit cache, use those         // options instead. This is used for AJAX multi-step stuff.         if ($this->view->getRequest()->request->get('form_id') && isset($this->view->temporary_options[$type][$id])) {
          $info = $this->view->temporary_options[$type][$id];
        }

        

  protected function processHandlers(array $all_views, callable $process) {
    foreach ($all_views as $view) {
      foreach (array_keys($view->get('display')) as $display_id) {
        $display = &$view->getDisplay($display_id);
        foreach (Views::getHandlerTypes() as $handler_type) {
          $handler_type = $handler_type['plural'];
          if (!isset($display['display_options'][$handler_type])) {
            continue;
          }
          foreach ($display['display_options'][$handler_type] as $id => &$handler_config) {
            $process($handler_config$view);
            if ($handler_config === NULL) {
              unset($display['display_options'][$handler_type][$id]);
            }
          }
        }
      }
public function testInitMethods() {
    $view = Views::getView('test_destroy');
    $view->initDisplay();

    $this->assertInstanceOf(DefaultDisplay::class$view->display_handler);
    $this->assertInstanceOf(DefaultDisplay::class$view->displayHandlers->get('default'));

    $view->destroy();
    $view->initHandlers();

    // Check for all handler types.     $handler_types = array_keys(ViewExecutable::getHandlerTypes());
    foreach ($handler_types as $type) {
      // The views_test integration doesn't have relationships.       if ($type == 'relationship') {
        continue;
      }
      $this->assertGreaterThan(0, count($view->$type)new FormattableMarkup('Make sure a %type instance got instantiated.', ['%type' => $type]));
    }

    // initHandlers() should create display handlers automatically as well.     $this->assertInstanceOf(DefaultDisplay::class$view->display_handler);
    $this->assertInstanceOf(DefaultDisplay::class$view->displayHandlers->get('default'));

    
return $option_build;
  }

  /** * Add information about a section to a display. */
  public function getFormBucket(ViewUI $view$type$display) {
    $executable = $view->getExecutable();
    $executable->setDisplay($display['id']);
    $executable->initStyle();

    $types = $executable->getHandlerTypes();

    $build = [
      '#theme_wrappers' => ['views_ui_display_tab_bucket'],
    ];

    $build['#overridden'] = FALSE;
    $build['#defaulted'] = FALSE;

    $build['#name'] = $type;
    $build['#title'] = $types[$type]['title'];

    
Home | Imprint | This part of the site doesn't use cookies.