File: /home/accemeff/vendor/craftcms/cms/src/behaviors/ContentBehavior.php.template
<?php // v{VERSION}
/**
* @link http://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license http://craftcms.com/license
*/
namespace craft\behaviors;
use yii\base\Behavior;
/**
* Content behavior
*
* This class provides attributes for all the unique custom field handles.
*/
class ContentBehavior extends Behavior
{
// Static
// =========================================================================
/**
* @var string[] List of supported field handles.
*/
public static $fieldHandles = [
/* HANDLES */
];
// Properties
// =========================================================================
/* PROPERTIES */
/**
* @var array Additional custom field values we don’t know about yet.
*/
private $_customFieldValues = [];
// Magic Property Methods
// =========================================================================
/**
* @inheritdoc
*/
public function __isset($name)
{
if (isset(self::$fieldHandles[$name])) {
return true;
}
return parent::__isset($name);
}
/**
* @inheritdoc
*/
public function __get($name)
{
if (isset(self::$fieldHandles[$name])) {
return $this->_customFieldValues[$name] ?? null;
}
return parent::__get($name);
}
/**
* @inheritdoc
*/
public function __set($name, $value)
{
if (isset(self::$fieldHandles[$name])) {
$this->_customFieldValues[$name] = $value;
return;
}
parent::__set($name, $value);
}
/**
* @inheritdoc
*/
public function canGetProperty($name, $checkVars = true)
{
if ($checkVars && isset(self::$fieldHandles[$name])) {
return true;
}
return parent::canGetProperty($name, $checkVars);
}
/**
* @inheritdoc
*/
public function canSetProperty($name, $checkVars = true)
{
if ($checkVars && isset(self::$fieldHandles[$name])) {
return true;
}
return parent::canSetProperty($name, $checkVars);
}
}