Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Accessing an entire object in volt

I've got an object injected into the DI:

$di->setShared('myobject', function(){
    return new \NS\Object('whatever');

Now I can access object methods/variables in volt no problem:

{{ myobject.doSomething('somevar') }}

// results in php code: 

However, if I want to pass that entire object to another function using volt, it doesn't work:

{{ anotherobject.doSomethingWithObject(myobject) }}

// results in php code -- note lack of $this

Is there another volt function I need to use to ensure the DI injected object is used? And not just a local $object instead?




{{ anotherobject.doSomethingWithObject(this.myobject) }}

Also, this should work:

{{ this.myobject.doSomething('somevar') }}

That works -- thanks!