mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
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:
parent
c7f54ef010
commit
0f215785f3
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
@ -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']
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user