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.
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