Rollback the idea of using $visible on CmsCompoundObjects

This feature should be reserved for serializing the object (in future maybe) rather than defining visible properties, these should be relaxed.
This commit is contained in:
Samuel Georges 2015-07-25 11:07:36 +10:00
parent c7f54ef010
commit 0f215785f3
4 changed files with 5 additions and 85 deletions

View File

@ -59,12 +59,6 @@ class CmsCompoundObject extends CmsObject
'fileName' 'fileName'
]; ];
/**
* @var array These properties will be available as regular properties,
* by looking the settings and viewBag values.
*/
protected $visible = [];
protected $settingsValidationRules = []; protected $settingsValidationRules = [];
protected $settingsValidationMessages = []; protected $settingsValidationMessages = [];
@ -116,21 +110,12 @@ class CmsCompoundObject extends CmsObject
*/ */
public function __get($name) public function __get($name)
{ {
$visibleKeys = array_flip($this->visible); if (is_array($this->settings) && array_key_exists($name, $this->settings)) {
if (isset($visibleKeys[$name])) { return $this->settings[$name];
if ( }
is_array($this->settings) &&
array_key_exists($name, $this->settings)
) {
return $this->settings[$name];
}
if ( if (is_array($this->viewBag) && array_key_exists($name, $this->viewBag)) {
is_array($this->viewBag) && return $this->viewBag[$name];
array_key_exists($name, $this->viewBag)
) {
return $this->viewBag[$name];
}
} }
return parent::__get($name); return parent::__get($name);
@ -537,39 +522,4 @@ class CmsCompoundObject extends CmsObject
$stream = $twig->tokenize($markup === false ? $this->markup : $markup, 'getTwigNodeTree'); $stream = $twig->tokenize($markup === false ? $this->markup : $markup, 'getTwigNodeTree');
return $twig->parse($stream); return $twig->parse($stream);
} }
//
// Visibility
//
/**
* Get the visible attributes for the object.
* @return array
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set the visible attributes for the object.
* @param array $visible
* @return void
*/
public function setVisible(array $visible)
{
$this->visible = $visible;
}
/**
* Add visible attributes for the object.
* @param array|string|null $attributes
* @return void
*/
public function addVisible($attributes = null)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();
$this->visible = array_merge($this->visible, $attributes);
}
} }

View File

@ -10,14 +10,6 @@ class Layout extends CmsCompoundObject
{ {
const FALLBACK_FILE_NAME = 'fallback'; const FALLBACK_FILE_NAME = 'fallback';
/**
* @var array These properties will be available as regular properties,
* by looking the settings and viewBag values.
*/
protected $visible = [
'description'
];
protected function parseSettings() protected function parseSettings()
{ {
} }

View File

@ -19,20 +19,6 @@ class Page extends CmsCompoundObject
*/ */
public $apiBag = []; public $apiBag = [];
/**
* @var array These properties will be available as regular properties,
* by looking the settings and viewBag values.
*/
protected $visible = [
'title',
'url',
'layout',
'description',
'meta_title',
'meta_description',
'is_hidden'
];
protected $settingsValidationRules = [ protected $settingsValidationRules = [
'title' => 'required', 'title' => 'required',
'url' => ['required', 'regex:/^\/[a-z0-9\/\:_\-\*\[\]\+\?\|\.\^\$]*$/i'] 'url' => ['required', 'regex:/^\/[a-z0-9\/\:_\-\*\[\]\+\?\|\.\^\$]*$/i']

View File

@ -8,14 +8,6 @@
*/ */
class Partial extends CmsCompoundObject class Partial extends CmsCompoundObject
{ {
/**
* @var array These properties will be available as regular properties,
* by looking the settings and viewBag values.
*/
protected $visible = [
'description'
];
/** /**
* Returns the directory name corresponding to the object type. * Returns the directory name corresponding to the object type.
* For pages the directory name is "pages", for layouts - "layouts", etc. * For pages the directory name is "pages", for layouts - "layouts", etc.