Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Support using closures as DCA callbacks (see #5772)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 20, 2013
1 parent 948e8bb commit 1faa442
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Resources/contao/dca/tl_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,15 @@ public function toggleFeatured($intId, $blnVisible)
{
foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['featured']['save_callback'] as $callback)
{
$this->import($callback[0]);
$blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
if (is_array($callback))
{
$this->import($callback[0]);
$blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
}
elseif (is_callable($callback))
{
$blnVisible = $callback($blnVisible, $this);
}
}
}

Expand Down Expand Up @@ -900,8 +907,15 @@ public function toggleVisibility($intId, $blnVisible)
{
foreach ($GLOBALS['TL_DCA']['tl_news']['fields']['published']['save_callback'] as $callback)
{
$this->import($callback[0]);
$blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
if (is_array($callback))
{
$this->import($callback[0]);
$blnVisible = $this->$callback[0]->$callback[1]($blnVisible, $this);
}
elseif (is_callable($callback))
{
$blnVisible = $callback($blnVisible, $this);
}
}
}

Expand Down

0 comments on commit 1faa442

Please sign in to comment.