deleteAll example

$export = $this->container->get('config.storage.export');

    // Test that the active and the export storage contain the same config.     $this->assertNotEmpty($active->listAll());
    $this->assertEquals($active->listAll()$export->listAll());
    foreach ($active->listAll() as $name) {
      $this->assertEquals($active->read($name)$export->read($name));
    }

    // Test that the export storage is read-only.     $this->expectException(\BadMethodCallException::class);
    $export->deleteAll();
  }

}
    $this->nodeWithAlias = $this->drupalCreateNode([
      'uid' => $user->id(),
      'type' => 'page',
      'path' => '/' . $this->randomMachineName(),
    ]);

    // Configure 'node' as front page.     $this->config('system.site')
      ->set('page.front', '/node/' . $node_front->id())
      ->save();

    \Drupal::cache('render')->deleteAll();
  }

  /** * Validate that breadcrumb markup get the right cache contexts. * * Checking that the breadcrumb will be printed on node canonical routes even * if it was rendered for the <front> page first. */
  public function testBreadcrumbsFrontPageCache() {
    // Hit front page first as anonymous user with 'cold' render cache.     $this->drupalGet('<front>');
    
public function deleteMultiple(array $cids) {
    foreach ($this->backends as $backend) {
      $backend->deleteMultiple($cids);
    }
  }

  /** * {@inheritdoc} */
  public function deleteAll() {
    foreach ($this->backends as $backend) {
      $backend->deleteAll();
    }
  }

  /** * {@inheritdoc} */
  public function invalidate($cid) {
    foreach ($this->backends as $backend) {
      $backend->invalidate($cid);
    }
  }

  
    $this->config('system.performance')->set('css', [
      'preprocess' => TRUE,
      'gzip' => TRUE,
    ])->save();
    $this->config('system.performance')->set('js', [
      'preprocess' => TRUE,
      'gzip' => TRUE,
    ])->save();

    // Ensure that the library discovery cache is empty before the page is     // requested and that updated asset URLs are rendered.     \Drupal::service('cache.data')->deleteAll();
    \Drupal::service('cache.page')->deleteAll();
    $this->drupalGet('<front>');
    $session = $this->getSession();
    $page = $session->getPage();

    $style_elements = $page->findAll('xpath', '//link[@href and @rel="stylesheet"]');
    $this->assertNotEmpty($style_elements);
    $href = NULL;
    foreach ($style_elements as $element) {
      $href = $element->getAttribute('href');
      $url = $this->getAbsoluteUrl($href);
      

  protected function normalize(EntityInterface $entity, Url $url) {
    // Don't use cached normalizations in tests.     $this->container->get('cache.jsonapi_normalizations')->deleteAll();

    $self_link = new Link(new CacheableMetadata()$url, 'self');
    $resource_type = $this->container->get('jsonapi.resource_type.repository')->getByTypeName(static::$resourceTypeName);
    $doc = new JsonApiDocumentTopLevel(new ResourceObjectData([ResourceObject::createFromEntity($resource_type$entity)], 1)new NullIncludedData()new LinkCollection(['self' => $self_link]));
    return $this->serializer->normalize($doc, 'api_json', [
      'resource_type' => $resource_type,
      'account' => $this->account,
    ])->getNormalization();
  }

  /** * Creates the entity to be tested. * * @return \Drupal\Core\Entity\EntityInterface * The entity to be tested. */
$this->removeFromChangelist($collection, 'rename', $rename);
    $this->addChangeList($collection, 'update', [$names['new_name']]$this->sourceNames[$collection]);
  }

  /** * {@inheritdoc} */
  public function reset() {
    $this->changelist = [StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist()];
    $this->sourceNames = $this->targetNames = [];
    // Reset the static configuration data caches.     $this->sourceCacheStorage->deleteAll();
    $this->targetCacheStorage->deleteAll();
    return $this->createChangelist();
  }

  /** * {@inheritdoc} */
  public function hasChanges() {
    foreach ($this->getAllCollectionNames() as $collection) {
      foreach (['delete', 'create', 'update', 'rename'] as $op) {
        if (!empty($this->changelist[$collection][$op])) {
          
    $files = [
      'config_test.test.biff',
      'config_test.test.bang',
      'config_test.test.pow',
    ];
    foreach ($files as $name) {
      $this->storage->write($name$data);
    }

    // Test that deleting a prefix that returns no configuration returns FALSE     // because nothing is deleted.     $this->assertFalse($this->storage->deleteAll('some_thing_that_cannot_exist'));

    $result = $this->storage->deleteAll('config_test.');
    $names = $this->storage->listAll('config_test.');
    $this->assertTrue($result);
    $this->assertSame([]$names);

    // Test renaming an object that does not exist returns FALSE.     $this->assertFalse($this->storage->rename('config_test.storage_does_not_exist', 'config_test.storage_does_not_exist_rename'));

    // Test renaming to an object that already returns FALSE.     $data = ['foo' => 'bar'];
    
$messages = $this->messenger->messagesByType(MessengerInterface::TYPE_ERROR);
    $this->assertCount(1, $messages);

    // Check getting all messages.     $messages = $this->messenger->all();
    $this->assertCount(3, $messages);
    $this->assertArrayHasKey(MessengerInterface::TYPE_STATUS, $messages);
    $this->assertArrayHasKey(MessengerInterface::TYPE_WARNING, $messages);
    $this->assertArrayHasKey(MessengerInterface::TYPE_ERROR, $messages);

    // Check deletion.     $this->messenger->deleteAll();
    $this->assertCount(0, $this->messenger->messagesByType(MessengerInterface::TYPE_STATUS));
    $this->assertCount(0, $this->messenger->messagesByType(MessengerInterface::TYPE_WARNING));
    $this->assertCount(0, $this->messenger->messagesByType(MessengerInterface::TYPE_ERROR));

  }

  /** * Tests we do add duplicates with repeat flag. * * @covers ::addStatus * @covers ::addWarning * @covers ::addError * @covers ::deleteByType */

  public function deleteMultiple(array $cids) {
    $this->consistentBackend->deleteMultiple($cids);
    $this->markAsOutdated();
  }

  /** * {@inheritdoc} */
  public function deleteAll() {
    $this->consistentBackend->deleteAll();
    $this->markAsOutdated();
  }

  /** * {@inheritdoc} */
  public function invalidate($cid) {
    $this->invalidateMultiple([$cid]);
  }

  /** * {@inheritdoc} */
/** * {@inheritdoc} */
  public function listAll($prefix = '') {
    return $this->getStorage()->listAll($prefix);
  }

  /** * {@inheritdoc} */
  public function deleteAll($prefix = '') {
    return $this->getStorage()->deleteAll($prefix);
  }

  /** * {@inheritdoc} */
  public function createCollection($collection) {
    // We return the collection directly.     // This means that the collection will not be an instance of ManagedStorage     // But this doesn't matter because the storage is retrieved from the     // manager only the first time it is accessed.     return $this->getStorage()->createCollection($collection);
  }

  protected function attemptMemoryReclaim() {
    // First, try resetting Drupal's static storage - this frequently releases     // plenty of memory to continue.     drupal_static_reset();

    // Entity storage can blow up with caches, so clear it out.     \Drupal::service('entity.memory_cache')->deleteAll();

    // @TODO: explore resetting the container.
    // Run garbage collector to further reduce memory.     gc_collect_cycles();

    return memory_get_usage();
  }

  /** * Generates a string representation for the given byte count. * * @param int $size * A size in bytes. * * @return string * A translated string representation of the size. */
$modules_list_url_absolute = Url::fromRoute('system.modules_list', [][
      'fragment' => 'module-content-moderation',
      'absolute' => TRUE,
    ])->toString();
    $this->assertSame($this->getSession()->getCurrentUrl()$modules_list_url_absolute);
    // The current user does not have the 'administer modules' permission.     $this->assertSession()->statusCodeEquals(403);

    $this->container->get('module_installer')->install(['workflow_type_test']);
    // The render cache needs to be cleared because although the cache tags are     // correctly set the render cache does not pick it up.     \Drupal::cache('render')->deleteAll();

    $this->drupalGet('admin/config/workflow/workflows');
    $this->assertSession()->pageTextNotContains('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the Content Moderation module provides a workflow type that enables workflows for content entities.');
    $this->assertSession()->linkExists('Add workflow');
    $this->assertSession()->pageTextContains('There are no workflows yet.');
  }

}
/** * {@inheritdoc} */
  public function deleteMultiple(array $cids) {
    $this->backend->deleteMultiple($cids);
  }

  /** * {@inheritdoc} */
  public function deleteAll() {
    $this->backend->deleteAll();
  }

}
// Re-throw the original exception with a helpful message.         $error_revision_id = $load_revisions ? ", revision ID: {$entity->getLoadedRevisionId()}" : '';
        throw new EntityStorageException("The entity update process failed while processing the entity type {$entity_type->id()}, ID: {$entity->id()}$error_revision_id.", $e->getCode()$e);
      }

      $sandbox['progress']++;
      $sandbox['current_id'] = $identifier;
    }

    // Reset the cache in order to free memory as we progress.     \Drupal::service('entity.memory_cache')->deleteAll();

    // Get an updated count of entities that still need to migrated to the new     // storage.     $missing = $this->database->select($table_name, 't')
      ->condition("t.$identifier_field", $sandbox['current_id'], '>')
      ->orderBy($identifier_field, 'ASC')
      ->countQuery()
      ->execute()
      ->fetchField();
    $sandbox['#finished'] = $missing ? $sandbox['progress'] / ($sandbox['progress'] + (int) $missing) : 1;
  }

  

  public function deleteMultiple(array $cids) {
    foreach ($cids as $cid) {
      $this->delete($cid);
    }
  }

  /** * {@inheritdoc} */
  public function deleteAll() {
    $this->storage()->deleteAll();
  }

  /** * {@inheritdoc} */
  public function invalidate($cid) {
    $this->invalidateByHash($this->normalizeCid($cid));
  }

  /** * Invalidate one cache item. * * @param string $cidhash * The hashed version of the original cache ID after being normalized. */
Home | Imprint | This part of the site doesn't use cookies.