/** * Returns <link> tags with the url toward all stylesheets configured in view.yml or added to the response object. * * You can use this helper to decide the location of stylesheets in pages. * By default, if you don't call this helper, symfony will automatically include stylesheets before </head>. * Calling this helper disables this behavior. * * @return string <link> tags */ function get_combined_stylesheets() { if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) { return get_stylesheets(); } $response = sfContext::getInstance()->getResponse(); sfConfig::set('symfony.asset.stylesheets_included', true); $configSfCombinePlugin['css'] = sfConfig::get('app_sfCombinePlugin_css', array()); $html = ''; $cssFiles = $include_tags = array(); foreach (array('first', '', 'last') as $position) { foreach ($response->getStylesheets($position) as $files => $options) { if (!in_array($files, $configSfCombinePlugin['css']['online']) && !in_array($files, $configSfCombinePlugin['css']['offline'])) { if (!is_array($files)) { $files = array($files); } $cssFiles = array_merge($cssFiles, $files); } else { $include_tags[] = stylesheet_tag(url_for($files)); } } } $key = _get_key($cssFiles); $include_tags[] = str_replace('.css', '', stylesheet_tag(url_for('sfCombine/css?key=' . $key))); return implode("", $include_tags); }
/** * Returns <link> tags with the url toward all stylesheets configured in view.yml or added to the response object. * * You can use this helper to decide the location of stylesheets in pages. * By default, if you don't call this helper, symfony will automatically include stylesheets before </head>. * Calling this helper disables this behavior. * * @return string <link> tags */ function get_combined_stylesheets() { if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) { return get_stylesheets(); } sfConfig::set('symfony.asset.stylesheets_included', true); $html = ''; $cssFiles = array(); $response = sfContext::getInstance()->getResponse(); foreach ($response->getStylesheets() as $files => $options) { if (!is_array($files)) { $files = array($files); } $cssFiles = array_merge($cssFiles, $files); } if (!empty($cssFiles)) { $html .= str_replace(array('.css', '.pcss'), '', stylesheet_tag(url_for('sfCombine/css?key=' . _get_key($cssFiles)))); } return $html; }