I'm having some trouble trying to write a plugin for CraftCMS (a CMS based on YII Framework). I'm trying to create a simple fieldtype that I'm going to use inside a matrix block. So far the public funciton getInputHtml of my fieldtype class, contains only a
var_dump($this->element)
And it shows me, as expected:
object(Craft\MatrixBlockModel)#1121 (25) {
["elementType":protected]=>
string(11) "MatrixBlock" [.......]
The problem is that, as I try to change the previous
var_dump($this->element)
with a
var_dump($this->element->getOwner())
(or any other method/property of the MatrixBlockModel class), I obtain:
"Call to a member function getOwner() on a non-object"
The only think I thought is that it could have something to do with the magic method __call() overwritten in a class from which MatrixBlockModel inherit (actually, a parent of a parent of a parent...). But, trying to have a look to its code, it do not seem so.
It likely is something with __call as you suggest. What happens if you do:
$var = $this->element;
var_dump($var);
var_dump($var->getOwner());
I have a hunch that if you assign it to a temporary variable that might solve the issue.