Skip to content

Commit

Permalink
Fix accessing Model\Collection instead of Model in ModuleFaqPage (see c…
Browse files Browse the repository at this point in the history
…ontao#2788)

Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes contao#2786 
| Docs PR or issue | -

`$figureBuilder->setMetadata($objFaq->getOverwriteMetadata())` was failing because `$objFaq` is a `Model\Collection` instead of a `Model`. To prevent this rather hard to spot error in the future, I adjusted how we're iterating over the results instead.

Commits
-------

ff2f8b9 iterate over FaqModels instead of operating on Model\Collection
c2934f0 Merge branch '4.11' into bugfix/module-faq-model-collection
  • Loading branch information
m-vo authored and fritzmg committed Mar 4, 2021
1 parent fdbc6b8 commit f16cbfc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions faq-bundle/src/Resources/contao/modules/ModuleFaqPage.php
Expand Up @@ -74,9 +74,9 @@ public function generate()
*/
protected function compile()
{
$objFaq = FaqModel::findPublishedByPids($this->faq_categories);
$objFaqs = FaqModel::findPublishedByPids($this->faq_categories);

if ($objFaq === null)
if ($objFaqs === null)
{
$this->Template->faq = array();

Expand All @@ -90,7 +90,7 @@ protected function compile()
$arrFaqs = array_fill_keys($this->faq_categories, array());

// Add FAQs
while ($objFaq->next())
foreach ($objFaqs as $objFaq)
{
/** @var FaqModel $objFaq */
$objTemp = (object) $objFaq->row();
Expand Down

0 comments on commit f16cbfc

Please sign in to comment.