在Drupal 8中查询段落类型

时间:2019-03-01 18:30:41

标签: drupal drupal-8 drupal-entities

我正在尝试查询某种类型的所有段落,但是没有任何输出。我的查询正确吗?当前正在返回一个空数组。

$query = $this->node->getQuery()
          ->condition('type', 'my_paragraph_type')
          ->execute();
        $this->logger->info('query: ' . json_encode($query));

1 个答案:

答案 0 :(得分:0)

尝试使用entityQuery('entity_type')

$pids = \Drupal::entityQuery('paragraph')
  ->condition('type', 'my_paragraph_type')
  ->execute();