id example

$this->assertSame(405, $response->getStatusCode());
    $document = Json::decode((string) $response->getBody());
    $this->assertSame('Deleting a resource object translation is not yet supported. See https://www.drupal.org/docs/8/modules/jsonapi/translations.', $document['errors'][0]['detail']);

    $response = $this->request('DELETE', Url::fromUri('base:/ca-fr/jsonapi/node/article/' . $this->nodes[0]->uuid())[]);
    $this->assertSame(405, $response->getStatusCode());
    $document = Json::decode((string) $response->getBody());
    $this->assertSame('Deleting a resource object translation is not yet supported. See https://www.drupal.org/docs/8/modules/jsonapi/translations.', $document['errors'][0]['detail']);

    $response = $this->request('DELETE', Url::fromUri('base:/jsonapi/node/article/' . $this->nodes[0]->uuid())[]);
    $this->assertSame(204, $response->getStatusCode());
    $this->assertNull(Node::load($this->nodes[0]->id()));
  }

}
$block = $this->drupalPlaceBlock('system_menu_block:llama', ['label' => 'Llama', 'provider' => 'system', 'region' => 'footer']);

    // Prime the page cache.     $this->verifyPageCache($url, 'MISS');

    // Verify a cache hit, but also the presence of the correct cache tags.     $expected_tags = [
      'http_response',
      'rendered',
      'block_view',
      'config:block_list',
      'config:block.block.' . $block->id(),
      'config:system.menu.llama',
      // The cache contexts associated with the (in)accessible menu links are       // bubbled.       'config:user.role.anonymous',
    ];
    $this->verifyPageCache($url, 'HIT', $expected_tags);

    // Verify that after modifying the menu, there is a cache miss.     $menu->set('label', 'Awesome llama');
    $menu->save();
    $this->verifyPageCache($url, 'MISS');

    

  protected function _testOffset() {
    $view = Views::getView('test_filter_date_between');

    // Test offset for simple operator.     $view->initHandlers();
    $view->filter['created']->operator = '>';
    $view->filter['created']->value['type'] = 'offset';
    $view->filter['created']->value['value'] = '+1 hour';
    $view->executeDisplay('default');
    $expected_result = [
      ['nid' => $this->nodes[3]->id()],
    ];
    $this->assertIdenticalResultset($view$expected_result$this->map);
    $view->destroy();

    // Test offset for between operator.     $view->initHandlers();
    $view->filter['created']->operator = 'between';
    $view->filter['created']->value['type'] = 'offset';
    $view->filter['created']->value['max'] = '+2 days';
    $view->filter['created']->value['min'] = '+1 hour';
    $view->executeDisplay('default');
    
$configuration = [
      'target_type' => 'block_content',
      'target_bundles' => ['spiffy' => 'spiffy'],
      'sort' => ['field' => '_none'],
    ];
    $this->selectionHandler = new TestSelection($configuration, '', '', $this->container->get('entity_type.manager')$this->container->get('module_handler'), \Drupal::currentUser(), \Drupal::service('entity_field.manager'), \Drupal::service('entity_type.bundle.info'), \Drupal::service('entity.repository'));

    // Setup the 3 expectation cases.     $this->expectations = [
      'both_blocks' => [
        'spiffy' => [
          $this->blockReusable->id() => $this->blockReusable->label(),
          $this->blockNonReusable->id() => $this->blockNonReusable->label(),
        ],
      ],
      'block_reusable' => ['spiffy' => [$this->blockReusable->id() => $this->blockReusable->label()]],
      'block_non_reusable' => ['spiffy' => [$this->blockNonReusable->id() => $this->blockNonReusable->label()]],
    ];
  }

  /** * Tests to make sure queries without the expected tags are not altered. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */
$form['#tree'] = TRUE;
    $form['settings'] = [];
    $subform_state = SubformState::createForSubform($form['settings']$form$form_state);
    $form['settings'] = $this->getPluginForm($entity->getPlugin())->buildConfigurationForm($form['settings']$subform_state);
    $form['visibility'] = $this->buildVisibilityInterface([]$form_state);

    // If creating a new block, calculate a safe default machine name.     $form['id'] = [
      '#type' => 'machine_name',
      '#maxlength' => 64,
      '#description' => $this->t('A unique name for this block instance. Must be alpha-numeric and underscore separated.'),
      '#default_value' => !$entity->isNew() ? $entity->id() : $this->getUniqueMachineName($entity),
      '#machine_name' => [
        'exists' => '\Drupal\block\Entity\Block::load',
        'replace_pattern' => '[^a-z0-9_.]+',
        'source' => ['settings', 'label'],
      ],
      '#required' => TRUE,
      '#disabled' => !$entity->isNew(),
    ];

    // Theme settings.     if ($theme = $entity->getTheme()) {
      
/** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    if (empty($this->derivatives)) {
      $definitions = [];
      foreach ($this->getApplicableEntityTypes() as $entity_type_id => $entity_type) {
        $definition = $base_plugin_definition;
        $definition['type'] = $entity_type_id;
        $definition['label'] = $this->t('Delete @entity_type', ['@entity_type' => $entity_type->getSingularLabel()]);
        $definition['confirm_form_route_name'] = 'entity.' . $entity_type->id() . '.delete_multiple_form';
        $definitions[$entity_type_id] = $definition;
      }
      $this->derivatives = $definitions;
    }

    return $this->derivatives;
  }

  /** * {@inheritdoc} */
  

  protected $handlerSettings;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Create content types and nodes.     $type1 = $this->drupalCreateContentType()->id();
    $type2 = $this->drupalCreateContentType()->id();
    // Add some characters that should be escaped but not double escaped.     $node1 = $this->drupalCreateNode(['type' => $type1, 'title' => 'Test first node &<>']);
    $node2 = $this->drupalCreateNode(['type' => $type1, 'title' => 'Test second node &&&']);
    $node3 = $this->drupalCreateNode(['type' => $type2, 'title' => 'Test third node <span />']);

    foreach ([$node1$node2$node3] as $node) {
      $this->nodes[$node->id()] = $node;
    }

    // Create an entity reference field.
/** * Tests the getEntity method. */
  public function testGetEntity() {
    // The view is a view of comments, their nodes and their authors, so there     // are three layers of entities.
    $account = User::create(['name' => $this->randomMachineName(), 'bundle' => 'user']);
    $account->save();

    $node = Node::create([
      'uid' => $account->id(),
      'type' => 'page',
      'title' => $this->randomString(),
    ]);
    $node->save();
    $comment = Comment::create([
      'uid' => $account->id(),
      'entity_id' => $node->id(),
      'entity_type' => 'node',
      'field_name' => 'comment',
    ]);
    $comment->save();

    
        if (isset($element['#file_value_callbacks'])) {
          foreach ($element['#file_value_callbacks'] as $callback) {
            $callback($element$input$form_state);
          }
        }

        // Load files if the FIDs have changed to confirm they exist.         if (!empty($input['fids'])) {
          $fids = [];
          foreach ($input['fids'] as $fid) {
            if ($file = File::load($fid)) {
              $fids[] = $file->id();
              if (!$file->access('download')) {
                $force_default = TRUE;
                break;
              }
              // Temporary files that belong to other users should never be               // allowed.               if ($file->isTemporary()) {
                if ($file->getOwnerId() != \Drupal::currentUser()->id()) {
                  $force_default = TRUE;
                  break;
                }
                
return;
    }
    $field_name = $items->getFieldDefinition()->getName();
    /** @var \Drupal\Core\Entity\EntityInterface $entity */
    $entity = $items->getEntity();
    $entity_type_id = $entity->getEntityTypeId();
    $id_key = $entity->getEntityType()->getKey('id');

    $query = \Drupal::entityQuery($entity_type_id)
      ->accessCheck(FALSE);

    $entity_id = $entity->id();
    // Using isset() instead of !empty() as 0 and '0' are valid ID values for     // entity types using string IDs.     if (isset($entity_id)) {
      $query->condition($id_key$entity_id, '<>');
    }

    $value_taken = (bool) $query
      ->condition($field_name$item->value)
      ->range(0, 1)
      ->count()
      ->execute();

    
'build_info' => $build_info,
      ];
      // @todo https://www.drupal.org/node/2433591 might solve it to not require       // the pager information here.       $key_data['pager'] = [
        'page' => $this->view->getCurrentPage(),
        'items_per_page' => $this->view->getItemsPerPage(),
        'offset' => $this->view->getOffset(),
      ];
      $key_data += \Drupal::service('cache_contexts_manager')->convertTokensToKeys($this->displayHandler->getCacheMetadata()->getCacheContexts())->getKeys();

      $this->resultsKey = $this->view->storage->id() . ':' . $this->displayHandler->display['id'] . ':results:' . hash('sha256', serialize($key_data));
    }

    return $this->resultsKey;
  }

  /** * Gets an array of cache tags for the current view. * * @return string[] * An array of cache tags based on the current view. */
  
/** @var \Drupal\Core\Entity\ContentEntityInterface $original_entity */
      $original_entity = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->loadRevision($entity->getLoadedRevisionId());
      if (!$entity->isDefaultTranslation() && $original_entity->hasTranslation($entity->language()->getId())) {
        $original_entity = $original_entity->getTranslation($entity->language()->getId());
      }
    }
    // For a new entity, ensure the moderation state of the original entity is     // always the default state. Despite the entity being unsaved, it may have     // previously been set to a new target state, for example previewed entities     // are retrieved from temporary storage with field values set.     else {
      $original_entity->set('moderation_state', $default->id());
    }

    /** @var \Drupal\workflows\Transition[] $transitions */
    $transitions = $this->validator->getValidTransitions($original_entity$this->currentUser);

    $transition_labels = [];
    $default_value = $items->value;
    foreach ($transitions as $transition) {
      $transition_to_state = $transition->to();
      $transition_labels[$transition_to_state->id()] = $transition_to_state->label();
      if ($default->id() === $transition_to_state->id()) {
        
->save();
      FieldConfig::create([
        'entity_type' => static::$entityTypeId,
        'field_name' => 'field_rest_test_multivalue',
        'bundle' => $this->entity->bundle(),
      ])
        ->setLabel('Test field: multi-value')
        ->setTranslatable(FALSE)
        ->save();

      // Reload entity so that it has the new field.       $reloaded_entity = $this->entityStorage->loadUnchanged($this->entity->id());
      // Some entity types are not stored, hence they cannot be reloaded.       if ($reloaded_entity !== NULL) {
        $this->entity = $reloaded_entity;

        // Set a default value on the fields.         $this->entity->set('field_rest_test', ['value' => 'All the faith they had had had had no effect on the outcome of their life.']);
        $this->entity->set('field_rest_test_multivalue', [['value' => 'One']['value' => 'Two']]);
        $this->entity->set('rest_test_validation', ['value' => 'allowed value']);
        $this->entity->save();
      }
    }
  }
case 'DELETE':
        $this->grantPermissionsToTestedRole(['delete any file']);
        break;
    }
  }

  /** * Makes the current user the file owner. */
  protected function makeCurrentUserFileOwner() {
    $account = User::load(2);
    $this->entity->setOwnerId($account->id());
    $this->entity->setOwner($account);
    $this->entity->save();
  }

  /** * {@inheritdoc} */
  protected function createEntity() {
    $this->author = User::load(1);

    $file = File::create();
    
$this->dateFormatter = $date_formatter;
    $this->redirectDestination = $redirect_destination;
  }

  /** * {@inheritdoc} */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static(
      $entity_type,
      $container->get('entity_type.manager')->getStorage($entity_type->id()),
      $container->get('date.formatter'),
      $container->get('redirect.destination')
    );
  }

  /** * {@inheritdoc} */
  public function buildHeader() {
    // Enable language column and filter if multiple languages are added.     $header = [
      
Home | Imprint | This part of the site doesn't use cookies.