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

Drupal開発・運用の疑問/質問の答えはここに

無料ユーザー登録すると質問できます。

カテゴリ Core Ver. 関連モジュール タイトル降順で並び替える
テーマ 8.9.x Twig Twig で 月末日を算出する方法
テーマ 8.3x Core Twig開発用の設定
Migrate 9.x drush config Upgrade source(環境) を 変更したときにやるべきこと
言語 6.22 URLエイリアスを使った場合に、翻訳したページで同じURLエイリアスが使えないという不具合
ユーザ 7.23 PHP user_load_multiple()の復帰値
サイトの環境設定 7.38 Views Bulk Operation VBO(Views Bulk Operation)で指定したアクションが表示されない
コンテンツの管理 7,51 Views Data Export Views Data ExportでCSVデータが欠けてしまう
フォーム 8.9.x Views Views exposed filterのフォームに#default_valueを仕込む方法
Views Exposed Filter 8.4x hook_views_pre_view Views Exposed Formの複数単語入力(textfield)をフォーム上だけ複数行入力(textarea)にする方法
コンテンツの作成 7.26 CKEditor Views Viewsでティザーを一覧するとページのレイアウトが崩れることがある
ダウンロード 6.x Views Bonus Pack Viewsで表示した内容をCSVダウンロード
サイトの構築 7.22 Views Devel Viewsの設定ページが変に?
Views 8.4x hook_views_query_alter Viewsクエリに多くの条件を追加する方法
Views 8.4x hook_views_query_alter Viewsクエリの条件式にサブクエリを追加する方法
排他 7.26 lock Viewsモジュールの設定ページのような排他機能
フォーム 7.38 Views Views一覧の絞り込み検索フォームで複数フィールドを対象にしたい
言語 7.28 vim vimで全角が化けてしまう
css 7.38 Webform Webfomの送信内容確認ページで表示が崩れる
フォーム 7.15 Webform Webform - 確認ページの多言語化
Japanese mail 7.15 Webform, Mail System, Mime Mail, Japanese Mail Helper Webformから文字化けしないメール送信を行うには

ページ