t example


  protected function dialog($is_modal = FALSE) {
    $content = AjaxTestController::dialogContents();
    $response = new AjaxResponse();
    $title = $this->t('AJAX Dialog & contents');

    // Attach the library necessary for using the Open(Modal)DialogCommand and     // set the attachments for this Ajax response.     $content['#attached']['library'][] = 'core/drupal.dialog.ajax';

    if ($is_modal) {
      $response->addCommand(new OpenModalDialogCommand($title$content));
    }
    else {
      $selector = '#ajax-test-dialog-wrapper-1';
      $response->addCommand(new OpenDialogCommand($selector$title$content));
    }
$node = $node_storage->load($row['nid']);
    $node->value1 = $options1;
    $node->value2 = $options2;
    node_save($node);

    // Store some result for post-processing in the finished callback.     $context['results'][] = $node->title;

    // Update our progress information.     $context['sandbox']['progress']++;
    $context['sandbox']['current_node'] = $node->nid;
    $context['message'] = t('Now processing %node', ['%node' => $node->title]);
  }

  // Inform the batch engine that we are not finished,   // and provide an estimation of the completion level we reached.   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}

/** * Complete a batch process. * * Callback for batch_set(). * * This callback may be specified in a batch to perform clean-up operations, or * to analyze the results of the batch operations. * * @param $success * A boolean indicating whether the batch has completed successfully. * @param $results * The value set in $context['results'] by callback_batch_operation(). * @param $operations * If $success is FALSE, contains the operations that remained unprocessed. * @param string $elapsed * A string representing the elapsed time for the batch process, e.g., * '1 min 30 secs'. */
// Test the validation when an invalid value (in this case a user entity)     // is passed.     $account = $this->createUser();

    $typed_data = $this->typedData->create($definition$account);
    $violations = $typed_data->validate();
    $this->assertEquals(1, $violations->count(), 'Validation failed for incorrect value.');

    // Make sure the information provided by a violation is correct.     $violation = $violations[0];
    $this->assertEquals(t('The entity must be of type %type.', ['%type' => $entity_type])$violation->getMessage(), 'The message for invalid value is correct.');
    $this->assertEquals($typed_data$violation->getRoot(), 'Violation root is correct.');
    $this->assertEquals($account$violation->getInvalidValue(), 'The invalid value is set correctly in the violation.');
  }

}
/** * {@inheritdoc} */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $extensions = \Drupal::service('image.toolkit.manager')->getDefaultToolkit()->getSupportedExtensions();
    $options = array_combine(
      $extensions,
      array_map('mb_strtoupper', $extensions)
    );
    $form['extension'] = [
      '#type' => 'select',
      '#title' => $this->t('Convert to'),
      '#default_value' => $this->configuration['extension'],
      '#required' => TRUE,
      '#options' => $options,
    ];
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    
$this->entityDefinitionUpdateManager->installFieldStorageDefinition($entity_type->getRevisionMetadataKey('workspace')$entity_type->id(), 'workspaces', $this->getWorkspaceFieldDefinition());
  }

  /** * Gets the base field definition for the 'workspace' revision metadata field. * * @return \Drupal\Core\Field\BaseFieldDefinition * The base field definition. */
  protected function getWorkspaceFieldDefinition() {
    return BaseFieldDefinition::create('entity_reference')
      ->setLabel($this->t('Workspace'))
      ->setDescription($this->t('Indicates the workspace that this revision belongs to.'))
      ->setSetting('target_type', 'workspace')
      ->setInternal(TRUE)
      ->setTranslatable(FALSE)
      ->setRevisionable(TRUE);
  }

}
use StringTranslationTrait;

  /** * Menu callback for testing Twig filters in a Twig template. */
  public function testFilterRender() {
    return [
      '#theme' => 'twig_extension_test_filter',
      '#message' => 'Every animal is not a mineral.',
      '#safe_join_items' => [
        '<em>will be escaped</em>',
        $this->t('<em>will be markup</em>'),
        ['#markup' => '<strong>will be rendered</strong>'],
      ],
    ];
  }

  /** * Menu callback for testing Twig functions in a Twig template. */
  public function testFunctionRender() {
    return ['#theme' => 'twig_extension_test_function'];
  }

}
$query->condition('tv.machine_name', (array) $this->configuration['bundle'], 'IN');
    }

    return $query;
  }

  /** * {@inheritdoc} */
  public function fields() {
    $fields = [
      'tid' => $this->t('The term ID.'),
      'vid' => $this->t('Existing term VID'),
      'machine_name' => $this->t('Vocabulary machine name'),
      'name' => $this->t('The name of the term.'),
      'description' => $this->t('The term description.'),
      'weight' => $this->t('Weight'),
      'parent' => $this->t("The Drupal term IDs of the term's parents."),
      'format' => $this->t("Format of the term description."),
    ];
    return $fields;
  }

  
/** * {@inheritdoc} */
  public function summary() {
    if (count($this->configuration['bundles']) > 1) {
      $bundles = $this->configuration['bundles'];
      $last = array_pop($bundles);
      $bundles = implode(', ', $bundles);

      if (empty($this->configuration['negate'])) {
        return $this->t('@bundle_type is @bundles or @last', [
          '@bundle_type' => $this->pluginDefinition['label'],
          '@bundles' => $bundles,
          '@last' => $last,
        ]);
      }
      else {
        return $this->t('@bundle_type is not @bundles or @last', [
          '@bundle_type' => $this->pluginDefinition['label'],
          '@bundles' => $bundles,
          '@last' => $last,
        ]);
      }

  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $definition = $this->getPluginDefinition();
    $form['provider'] = [
      '#type' => 'value',
      '#value' => $definition['provider'],
    ];

    $form['admin_label'] = [
      '#type' => 'item',
      '#title' => $this->t('Block description'),
      '#plain_text' => $definition['admin_label'],
    ];
    $form['label'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Title'),
      '#maxlength' => 255,
      '#default_value' => $this->label(),
      '#required' => TRUE,
    ];
    $form['label_display'] = [
      '#type' => 'checkbox',
      
/** * {@inheritdoc} */
  public static function getType() {
    return StreamWrapperInterface::LOCAL_NORMAL;
  }

  /** * {@inheritdoc} */
  public function getName() {
    return t('Public files');
  }

  /** * {@inheritdoc} */
  public function getDescription() {
    return t('Public local files served by the webserver.');
  }

  /** * {@inheritdoc} */
return $options;
  }

  /** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $form['field_options'] = [
      '#type' => 'table',
      '#header' => [$this->t('Field')$this->t('Alias')$this->t('Raw output')],
      '#empty' => $this->t('You have no fields. Add some to your view.'),
      '#tree' => TRUE,
    ];

    $options = $this->options['field_options'];

    if ($fields = $this->view->display_handler->getOption('fields')) {
      foreach ($fields as $id => $field) {
        // Don't show the field if it has been excluded.         if (!empty($field['exclude'])) {
          continue;
        }
if (!parent::prepareRow($row)) {
      return FALSE;
    }
    $row->setSourceProperty('language', $row->getSourceProperty('td_language'));
  }

  /** * {@inheritdoc} */
  public function fields() {
    $fields = [
      'language' => $this->t('Language for this term.'),
      'name_translated' => $this->t('Term name translation.'),
      'description_translated' => $this->t('Term description translation.'),
    ];
    return parent::fields() + $fields;
  }

  /** * {@inheritdoc} */
  public function getIds() {
    $ids['language']['type'] = 'string';
    

  public function form(array $form, FormStateInterface $form_state) {
    return parent::form($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form$form_state);
    $this->messenger()->addStatus($this->t('Added text format %format.', ['%format' => $this->entity->label()]));
    $form_state->setRedirect('filter.admin_overview');

    return $this->entity;
  }

}
/** * Route entity upcasting test helper. * * @param \Drupal\language\ConfigurableLanguageInterface $configurable_language * The ConfigurableLanguage object from the route. * * @return string * Testing feedback based on (translated) entity title. */
  public function testEntity(ConfigurableLanguageInterface $configurable_language) {
    return ['#markup' => $this->t('Loaded %label.', ['%label' => $configurable_language->label()])];
  }

  /** * Returns links to the current page with different langcodes. * * Using #type 'link' causes these links to be rendered with the link * generator. */
  public function typeLinkActiveClass() {
    // We assume that 'en' and 'fr' have been configured.     $languages = $this->languageManager->getLanguages();
    
return ['update.settings'];
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('update.settings');

    $form['update_check_frequency'] = [
      '#type' => 'radios',
      '#title' => $this->t('Check for updates'),
      '#default_value' => $config->get('check.interval_days'),
      '#options' => [
        '1' => $this->t('Daily'),
        '7' => $this->t('Weekly'),
      ],
      '#description' => $this->t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
    ];

    $form['update_check_disabled'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Check for updates of uninstalled modules and themes'),
      
Home | Imprint | This part of the site doesn't use cookies.