ViewUI example

// Build all display options for this view.     $display_options = $this->buildDisplayOptions($form$form_state);

    // Allow the fully built options to be altered. This happens before adding     // the options to the view, so that once they are eventually added we will     // be able to get all the overrides correct.     $this->alterDisplayOptions($display_options$form$form_state);

    $this->addDisplays($view$display_options$form$form_state);

    return new ViewUI($view);
  }

  /** * Builds an array of display options for the view. * * @return array * An array whose keys are the names of each display and whose values are * arrays of options for that display. */
  protected function buildDisplayOptions($form, FormStateInterface $form_state) {
    // Display: Default
$storage = $this->getMockBuilder('Drupal\views\Entity\View')
      ->onlyMethods($interface_methods)
      ->setConstructorArgs([[], 'view'])
      ->getMock();
    $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
      ->disableOriginalConstructor()
      ->setConstructorArgs([$storage])
      ->getMock();
    $storage->set('executable', $executable);

    $view_ui = new ViewUI($storage);

    foreach ($method_args as $method => $args) {
      $method_mock = $storage->expects($this->once())
        ->method($method);
      foreach ($args as $arg) {
        $method_mock->with($this->equalTo($arg));
      }
      call_user_func_array([$view_ui$method]$args);
    }

    $storage->expects($this->once())
      
if ($view = $store->get($value)) {
      if ($entity->status()) {
        $view->enable();
      }
      else {
        $view->disable();
      }
      $view->setLock($store->getMetadata($value));
    }
    // Otherwise, decorate the existing view for use in the UI.     else {
      $view = new ViewUI($entity);
    }

    return $view;
  }

  /** * {@inheritdoc} */
  public function applies($definition$name, Route $route) {
    if (parent::applies($definition$name$route)) {
      return !empty($definition['tempstore']) && $definition['type'] === 'entity:view';
    }
Home | Imprint | This part of the site doesn't use cookies.