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.

Phalcon\Assets\Collection need method __toString()

Hi evryone,

I woudlike to minify all js scripts (http://docs.phalconphp.com/pl/latest/reference/assets.html) but I'dlike to add js file in views not in controllers. In my layout I use:

        {{ assets
            .collection("out")
            .addJs('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false, false)
            .addJs('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js', false, false)
        }}

but Phalcon\Assets\Collection doesn't have __toString() method so in console I have:

[Wed, 10 Dec 14 13:24:58 +0100][ERROR] Object of class Phalcon\Assets\Collection could not be converted to string | on line: 29 | in file: /home/**/appscommon_frontend.volt.php | [4096]

When I use native php, evrythink work fine



2.3k
Accepted
answer

I use the following in head section and it works

{% do assets.collection('headJs').addJs('js/jquery.min.js') %}
{% do assets.collection('headJs').addJs('js/semantic.min.js') %}
{{ assets.outputJs('headJs') }}


7.2k

magic word "do"