Refactoring of the view bag support code

This commit is contained in:
alekseybobkov 2014-11-03 20:50:18 -08:00
parent d2547d1891
commit 802f96f10e
2 changed files with 21 additions and 0 deletions

View File

@ -43,6 +43,12 @@ class CmsCompoundObject extends CmsObject
*/
public $markup;
/**
* @var array Contains the view bag properties.
* This property is used by the page editor internally.
*/
public $viewBag = [];
protected static $fillable = [
'markup',
'settings',
@ -417,6 +423,18 @@ class CmsCompoundObject extends CmsObject
*/
protected function parseSettings()
{
$this->fillViewBagArray();
}
/*
* Copies view bag properties to the view bag array.
* This is required for the back-end editors.
*/
protected function fillViewBagArray()
{
$viewBag = $this->getViewBag();
foreach ($viewBag->getProperties() as $name=>$value)
$this->viewBag[$name] = $value;
}
/**

View File

@ -440,6 +440,9 @@ class Index extends Controller
$settings[$section] = $properties;
}
if (array_key_exists('viewBag', $_POST))
$settings['viewBag'] = $_POST['viewBag'];
return $settings;
}