Is it possible to get a value from view.yml in an action

老子叫甜甜 提交于 2019-12-12 08:59:27

问题


I'm wondering if it's possible to get the name of a stylesheet from view.yml in an action, ideally using something as simple as:

sfConfig::get('......');

I'd like to access the existing declaration in view.yml instead of hardcoding it or duplicating it somewhere like app.yml.

Thanks.


回答1:


If you want to access the current Module's Config, you can use:

sfViewConfigHandler::getConfiguration(array(dirname(__DIR__) . '/config/view.yml'));

It should return something like this:

Array
(
[indexSuccess] => Array
    (
        [javascripts] => Array
            (
                [0] => mission-control.js
            )

        [stylesheets] => Array
            (
                [0] => control-box.css
                [1] => question.css
            )

    )

[newSuccess] => Array
    (
        [javascripts] => Array
            (
                [0] => box-checker.js
                [1] => topic.js
            )

        [stylesheets] => Array
            (
                [0] => question.css
                [1] => topic.css
            )

    )

[searchSuccess] => Array
    (
        [javascripts] => Array
            (
                [0] => topic.js
            )

        [stylesheets] => Array
            (
                [0] => topic.css
            )

    )

[showSuccess] => Array
    (
        [javascripts] => Array
            (
                [0] => mission-control.js
            )

        [stylesheets] => Array
            (
                [0] => control-box.css
                [1] => question.css
            )

    )

[editSuccess] => Array
    (
        [javascripts] => Array
            (
                [0] => box-checker.js
                [1] => topic.js
            )

        [stylesheets] => Array
            (
                [0] => question.css
                [1] => topic.css
            )

    )

[all] => Array
    (
        [stylesheets] => Array
            (
            )

        [javascripts] => Array
            (
            )

    )

)


来源:https://stackoverflow.com/questions/6192769/is-it-possible-to-get-a-value-from-view-yml-in-an-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!