EntityをPropertyで探す(クエリする)方法

カテゴリ コンテンツの管理 コアバージョン 8.4x 関連モジュール Entity

ノードを探す

$nodes = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->loadByProperties([
    'title' => $this->input->getTitle()
    'field_xxxxx' => '12345',
  ]);

親タームをLoadする

$parents = \Drupal::entityManager()
  ->getStorage('taxonomy_term')
  ->loadParents($child->id());

子termを取得する

$terms = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term')
  ->loadTree('vocabulary_id', $parent, 1);

ファイルを探す

$file = \Drupal::service('entity_type.manager')
  ->getStorage('file')
  ->loadByProperties([
    'status' => FILE_STATUS_PERMANENT,
    'uri' => $uri,
  ]);

OTHER FAQ