From 0f215785f340b912c12b993a59ff236f8a0e31af Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 25 Jul 2015 11:07:36 +1000 Subject: [PATCH] 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. --- modules/cms/classes/CmsCompoundObject.php | 60 ++--------------------- modules/cms/classes/Layout.php | 8 --- modules/cms/classes/Page.php | 14 ------ modules/cms/classes/Partial.php | 8 --- 4 files changed, 5 insertions(+), 85 deletions(-) diff --git a/modules/cms/classes/CmsCompoundObject.php b/modules/cms/classes/CmsCompoundObject.php index cb19bb005..9e1170e2f 100644 --- a/modules/cms/classes/CmsCompoundObject.php +++ b/modules/cms/classes/CmsCompoundObject.php @@ -59,12 +59,6 @@ class CmsCompoundObject extends CmsObject 'fileName' ]; - /** - * @var array These properties will be available as regular properties, - * by looking the settings and viewBag values. - */ - protected $visible = []; - protected $settingsValidationRules = []; protected $settingsValidationMessages = []; @@ -116,21 +110,12 @@ class CmsCompoundObject extends CmsObject */ public function __get($name) { - $visibleKeys = array_flip($this->visible); - if (isset($visibleKeys[$name])) { - if ( - is_array($this->settings) && - array_key_exists($name, $this->settings) - ) { - return $this->settings[$name]; - } + if (is_array($this->settings) && array_key_exists($name, $this->settings)) { + return $this->settings[$name]; + } - if ( - is_array($this->viewBag) && - array_key_exists($name, $this->viewBag) - ) { - return $this->viewBag[$name]; - } + if (is_array($this->viewBag) && array_key_exists($name, $this->viewBag)) { + return $this->viewBag[$name]; } return parent::__get($name); @@ -537,39 +522,4 @@ class CmsCompoundObject extends CmsObject $stream = $twig->tokenize($markup === false ? $this->markup : $markup, 'getTwigNodeTree'); 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); - } } diff --git a/modules/cms/classes/Layout.php b/modules/cms/classes/Layout.php index 54954d370..eeec4e785 100644 --- a/modules/cms/classes/Layout.php +++ b/modules/cms/classes/Layout.php @@ -10,14 +10,6 @@ class Layout extends CmsCompoundObject { 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() { } diff --git a/modules/cms/classes/Page.php b/modules/cms/classes/Page.php index 8a7cae76a..839547fda 100644 --- a/modules/cms/classes/Page.php +++ b/modules/cms/classes/Page.php @@ -19,20 +19,6 @@ class Page extends CmsCompoundObject */ 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 = [ 'title' => 'required', 'url' => ['required', 'regex:/^\/[a-z0-9\/\:_\-\*\[\]\+\?\|\.\^\$]*$/i'] diff --git a/modules/cms/classes/Partial.php b/modules/cms/classes/Partial.php index bb9f06584..690319e60 100644 --- a/modules/cms/classes/Partial.php +++ b/modules/cms/classes/Partial.php @@ -8,14 +8,6 @@ */ 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. * For pages the directory name is "pages", for layouts - "layouts", etc.