Returns original setter functionality

To protected things like $this->page->title = "foo";
Template -> Bracket
This commit is contained in:
Samuel Georges 2016-03-05 10:49:01 +11:00
parent aaff88b8c2
commit 07132ffbd6
2 changed files with 20 additions and 4 deletions

View File

@ -446,7 +446,7 @@ class CmsObject extends Extendable implements ArrayAccess
return $result;
}
/**
* Returns the absolute file path.
* @param $theme Specifies a theme the file belongs to.
@ -488,6 +488,23 @@ class CmsObject extends Extendable implements ArrayAccess
return false;
}
/**
* Sets an attribute on the object.
* @param string $key
* @return bool
*/
public function __set($key, $value)
{
$methodName = 'set'.ucfirst($key);
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
// Do not allow setting protected properties
elseif (!property_exists($this, $key)) {
$this->$key = $value;
}
}
/**
* Determine if the given attribute exists.
* @param mixed $offset
@ -558,8 +575,7 @@ class CmsObject extends Extendable implements ArrayAccess
return call_user_func_array(array($query, $method), $parameters);
}
$className = get_class($this);
throw new \BadMethodCallException("Call to undefined method {$className}::{$method}()");
return parent::__call($method, $parameters);
}
/**

View File

@ -27,7 +27,7 @@ use October\Rain\Exception\AjaxException;
use October\Rain\Exception\SystemException;
use October\Rain\Exception\ValidationException;
use October\Rain\Exception\ApplicationException;
use October\Rain\Parse\Template as TextParser;
use October\Rain\Parse\Bracket as TextParser;
use Illuminate\Http\RedirectResponse;
/**