Commit ff99906c authored by catch's avatar catch
Browse files

Issue #3212354 by guilhermevp, Chi: AggregatorFeedBlock::build must always return array

(cherry picked from commit ebf0c951)
parent 4b40396f
...@@ -127,37 +127,38 @@ public function blockSubmit($form, FormStateInterface $form_state) { ...@@ -127,37 +127,38 @@ public function blockSubmit($form, FormStateInterface $form_state) {
*/ */
public function build() { public function build() {
// Load the selected feed. // Load the selected feed.
if ($feed = $this->feedStorage->load($this->configuration['feed'])) { if (!$feed = $this->feedStorage->load($this->configuration['feed'])) {
$result = $this->itemStorage->getQuery() return [];
->accessCheck(TRUE) }
->condition('fid', $feed->id()) $result = $this->itemStorage->getQuery()
->range(0, $this->configuration['block_count']) ->accessCheck(TRUE)
->sort('timestamp', 'DESC') ->condition('fid', $feed->id())
->sort('iid', 'DESC') ->range(0, $this->configuration['block_count'])
->execute(); ->sort('timestamp', 'DESC')
->sort('iid', 'DESC')
if ($result) { ->execute();
// Only display the block if there are items to show.
$items = $this->itemStorage->loadMultiple($result); if ($result) {
// Only display the block if there are items to show.
$build['list'] = [ $items = $this->itemStorage->loadMultiple($result);
'#theme' => 'item_list',
'#items' => [], $build['list'] = [
]; '#theme' => 'item_list',
foreach ($items as $item) { '#items' => [],
$build['list']['#items'][$item->id()] = [ ];
'#type' => 'link', foreach ($items as $item) {
'#url' => $item->toUrl(), $build['list']['#items'][$item->id()] = [
'#title' => $item->label(), '#type' => 'link',
]; '#url' => $item->toUrl(),
} '#title' => $item->label(),
$build['more_link'] = [
'#type' => 'more_link',
'#url' => $feed->toUrl(),
'#attributes' => ['title' => $this->t("View this feed's recent news.")],
]; ];
return $build;
} }
$build['more_link'] = [
'#type' => 'more_link',
'#url' => $feed->toUrl(),
'#attributes' => ['title' => $this->t("View this feed's recent news.")],
];
return $build;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment