condition example

->execute();

    parent::add($file$module$type$id$count);
  }

  /** * {@inheritdoc} */
  public function delete(FileInterface $file$module$type = NULL, $id = NULL, $count = 1) {
    // Delete rows that have an exact or less value to prevent empty rows.     $query = $this->connection->delete($this->tableName)
      ->condition('module', $module)
      ->condition('fid', $file->id());
    if ($type && $id) {
      $query
        ->condition('type', $type)
        ->condition('id', $id);
    }
    if ($count) {
      $query->condition('count', $count, '<=');
    }
    $result = $query->execute();

    
->sort('revision_id', 'DESC')
      ->execute();
    $this->assertEquals($expected_revision_ids$revision_ids, 'Revision ids found');

    $expected_non_rev_field_revision_ids = [
      3 => 1,
      1 => 1,
    ];
    $non_rev_field_revision_ids = $this->mulRev->getQuery()
      ->accessCheck(FALSE)
      ->allRevisions()
      ->condition('non_rev_field', 'Huron')
      ->sort('revision_id', 'DESC')
      ->execute();
    $this->assertEquals($expected_non_rev_field_revision_ids$non_rev_field_revision_ids, 'Revision ids found');
  }

  /** * Tests non-revisionable fields on revisionable entities. */
  public function testNonRevisionableField() {
    $user1 = $this->createUser();
    $user2 = $this->createUser();

    

  protected function loadContentModerationStateRevision(ContentEntityInterface $entity) {
    $moderation_info = \Drupal::service('content_moderation.moderation_information');
    $content_moderation_storage = \Drupal::entityTypeManager()->getStorage('content_moderation_state');

    $revisions = $content_moderation_storage->getQuery()
      ->accessCheck(FALSE)
      ->condition('content_entity_type_id', $entity->getEntityTypeId())
      ->condition('content_entity_id', $entity->id())
      // Ensure the correct revision is loaded in scenarios where a revision is       // being reverted.       ->condition('content_entity_revision_id', $entity->isNewRevision() ? $entity->getLoadedRevisionId() : $entity->getRevisionId())
      ->condition('workflow', $moderation_info->getWorkflowForEntity($entity)->id())
      ->condition('langcode', $entity->language()->getId())
      ->allRevisions()
      ->sort('revision_id', 'DESC')
      ->execute();
    if (empty($revisions)) {
      return NULL;
    }

  protected function addSubQueryJoin($tids): void {
    $connection = $this->query->getConnection();
    $operator = is_array($tids) ? 'IN' : '=';
    // Create the depth 0 subquery.     $subquery = $connection->select('taxonomy_index', 'tn');
    $subquery->addField('tn', 'nid');
    $subquery->condition('tn.tid', $tids$operator);

    if ($this->options['depth'] !== 0) {
      // Set $left_field and $right_field depending on whether we are traversing       // up or down the hierarchy.       if ($this->options['depth'] > 0) {
        $left_field = 'parent_target_id';
        $right_field = 'entity_id';
      }
      else {
        $left_field = 'entity_id';
        $right_field = 'parent_target_id';
      }

  public function exists($entity_id, array $element) {
    // Do not allow to add internal 'default' view mode.     if ($entity_id == 'default') {
      return TRUE;
    }
    /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
    $storage = $this->entityTypeManager->getStorage($this->entity->getEntityTypeId());
    return (bool) $storage
      ->getQuery()
      ->condition('id', $element['#field_prefix'] . $entity_id)
      ->execute();
  }

  /** * {@inheritdoc} */
  public function save(array $form, FormStateInterface $form_state) {
    $this->messenger()->addStatus($this->t('Saved the %label @entity-type.', ['%label' => $this->entity->label(), '@entity-type' => $this->entityType->getSingularLabel()]));
    $this->entity->save();
    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
    $form_state->setRedirectUrl($this->entity->toUrl('collection'));
  }


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

    // Delete 'site_frontpage' in order to test the migration of a non-existing     // front page link.     $this->sourceDatabase->delete('variable')
      ->condition('name', 'site_frontpage')
      ->execute();

    $migrations = [
      'd6_system_cron',
      'd6_system_date',
      'd6_system_file',
      'system_image_gd',
      'system_image',
      'system_logging',
      'system_maintenance',
      'd6_system_performance',
      

  protected function loadPathAliasByConditions($conditions) {
    $storage = \Drupal::entityTypeManager()->getStorage('path_alias');
    $query = $storage->getQuery()->accessCheck(FALSE);
    foreach ($conditions as $field => $value) {
      $query->condition($field$value);
    }
    $entities = $storage->loadMultiple($query->execute());

    return $entities ? reset($entities) : NULL;
  }

  /** * Asserts that a path alias exists in the storage. * * @param string $alias * The path alias. * @param string|null $langcode * (optional) The language code of the path alias. * @param string|null $path * (optional) The system path of the path alias. * @param string|null $message * (optional) A message to display with the assertion. */
/** * {@inheritdoc} */
  protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = parent::buildEntityQuery($match$match_operator);

    // Adding the 'taxonomy_term_access' tag is sadly insufficient for terms:     // core requires us to also know about the concept of 'published' and     // 'unpublished'.     if (!$this->currentUser->hasPermission('administer taxonomy')) {
      $query->condition('status', 1);
    }
    return $query;
  }

  /** * {@inheritdoc} */
  public function createNewEntity($entity_type_id$bundle$label$uid) {
    $term = parent::createNewEntity($entity_type_id$bundle$label$uid);

    // In order to create a referenceable term, it needs to published.
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    // Remove the file_directory_path to test site_path setting.     // @see \Drupal\Tests\file\Kernel\Migrate\d6\FileMigrationTestTrait::prepareMigration()     Database::getConnection('default', 'migrate')
      ->delete('variable')
      ->condition('name', 'file_directory_path')
      ->execute();

    $this->setUpMigratedFiles();
  }

  /** * Asserts a file entity. * * @param int $fid * The file ID. * @param string $name * The expected file name. * @param int $size * The expected file size. * @param string $uri * The expected file URI. * @param string $type * The expected MIME type. * @param int $uid * The expected file owner ID. * * @internal */
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->storage = new DatabaseStorage($this->container->get('database'), 'config');
    $this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid');
  }

  protected function read($name) {
    $data = Database::getConnection()->select('config', 'c')->fields('c', ['data'])->condition('name', $name)->execute()->fetchField();
    return unserialize($data);
  }

  protected function insert($name$data) {
    Database::getConnection()->insert('config')->fields(['name' => $name, 'data' => $data])->execute();
  }

  protected function update($name$data) {
    Database::getConnection()->update('config')->fields(['data' => $data])->condition('name', $name)->execute();
  }

  
'operator' => NULL,
    ];
    $this->changed = TRUE;

    return $this;
  }

  /** * {@inheritdoc} */
  public function isNull($field) {
    return $this->condition($field, NULL, 'IS NULL');
  }

  /** * {@inheritdoc} */
  public function isNotNull($field) {
    return $this->condition($field, NULL, 'IS NOT NULL');
  }

  /** * {@inheritdoc} */
  // a database field are updated.   if (!isset($sandbox['progress'])) {
    // This must be the first run. Initialize the sandbox.     $sandbox['progress'] = 0;
    $sandbox['current_pk'] = 0;
    $sandbox['max'] = Database::getConnection()->query('SELECT COUNT([my_primary_key]) FROM {my_table}')->fetchField();
  }

  // Update in chunks of 20.   $records = Database::getConnection()->select('my_table', 'm')
    ->fields('m', ['my_primary_key', 'other_field'])
    ->condition('my_primary_key', $sandbox['current_pk'], '>')
    ->range(0, 20)
    ->orderBy('my_primary_key', 'ASC')
    ->execute();
  foreach ($records as $record) {
    // Here, you would make an update something related to this record. In this     // example, some text is added to the other field.     Database::getConnection()->update('my_table')
      ->fields(['other_field' => $record->other_field . '-suffix'])
      ->condition('my_primary_key', $record->my_primary_key)
      ->execute();

    

    ];
  }

  /** * Tests basic conditionals on SELECT statements. */
  public function testSimpleSelectConditional() {
    $query = $this->connection->select('test');
    $name_field = $query->addField('test', 'name');
    $age_field = $query->addField('test', 'age', 'age');
    $query->condition('age', 27);
    $result = $query->execute();

    // Check that the aliases are being created the way we want.     $this->assertEquals('name', $name_field, 'Name field alias is correct.');
    $this->assertEquals('age', $age_field, 'Age field alias is correct.');

    // Ensure that we got the right record.     $record = $result->fetch();
    $this->assertEquals('George', $record->{$name_field}, 'Fetched name is correct.');
    $this->assertEquals(27, $record->{$age_field}, 'Fetched age is correct.');
  }

  
$ids[] = $item->target_id;
    }

    // @todo Better way to do this? AND handle the NULL/0 parent?     // Querying the terms again so that the same access checks are run when     // getParents() is called as in Drupal version prior to 8.3.     $loaded_parents = [];

    if ($ids) {
      $query = \Drupal::entityQuery('taxonomy_term')
        ->accessCheck(TRUE)
        ->condition('tid', $ids, 'IN');

      $loaded_parents = static::loadMultiple($query->execute());
    }

    return $parents + $loaded_parents;
  }

  /** * {@inheritdoc} */
  public function loadAllParents($tid) {
    

  public function reuseCallback(array $form, FormStateInterface $form_state) {
    $entity_type = $this->entityTypeManager->getDefinition($this->entityTypeId);
    $field_name = $form_state->getTriggeringElement()['#name'];
    // Get settings from existing configuration.     $default_options = $this->getExistingFieldDefaults($field_name);
    $fields = $this->entityTypeManager->getStorage('field_config')->getQuery()
      ->accessCheck()
      ->condition('entity_type', $this->entityTypeId)
      ->condition('field_name', $field_name)
      ->execute();
    $field = $fields ? $this->entityTypeManager->getStorage('field_config')->load(reset($fields)) : NULL;
    // Have a default label in case a field storage doesn't have any fields.     $existing_storage_label = $field ? $field->label() : $field_name;
    try {
      $field = $this->entityTypeManager->getStorage('field_config')->create([
        ...$default_options['field_config'] ?? [],
        'field_name' => $field_name,
        'entity_type' => $this->entityTypeId,
        'bundle' => $this->bundle,
        
Home | Imprint | This part of the site doesn't use cookies.