Skip to content

Instantly share code, notes, and snippets.

@mattattui
Created September 13, 2012 11:50
Show Gist options
  • Select an option

  • Save mattattui/3713822 to your computer and use it in GitHub Desktop.

Select an option

Save mattattui/3713822 to your computer and use it in GitHub Desktop.

Revisions

  1. mattattui created this gist Sep 13, 2012.
    4 changes: 4 additions & 0 deletions app.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    app:
    # ...
    resource_version: <?php echo date_create()->format('YmdHis');

    34 changes: 34 additions & 0 deletions glxAssetHelper.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    <?php
    function include_stylesheets_versioned()
    {
    $response = sfContext::getInstance()->getResponse();
    sfConfig::set('symfony.asset.stylesheets_included', true);

    $html = '';
    foreach ($response->getStylesheets() as $file => $options) {
    if ((strpos($file, '?') === false) && (stripos($file, 'http') !== 0) ) {
    $file .= '?v='.sfConfig::get('app_resource_version');
    }
    $html .= stylesheet_tag($file, $options);
    }

    echo $html;
    }


    function include_javascripts_versioned()
    {
    $response = sfContext::getInstance()->getResponse();
    sfConfig::set('symfony.asset.javascripts_included', true);

    $html = '';
    foreach ($response->getJavascripts() as $file => $options) {
    if ((strpos($file, '?') === false) && (stripos($file, 'http') !== 0) ) {
    $file .= '?v='.sfConfig::get('app_resource_version');
    }

    $html .= javascript_include_tag($file, $options);
    }

    echo $html;
    }