PHP Classes

File: src/functions/asset/helpers.php

Recommend this page to a friend!
  Packages of Ogbemudia Osayawe   Legato PHP Asset Management   src/functions/asset/helpers.php   Download  
File: src/functions/asset/helpers.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Legato PHP Asset Management
Get versioned URLs for CSS, JavaScript and images
Author: By
Last change:
Date: 8 years ago
Size: 463 bytes
 

 

Contents

Class file image Download
<?php

if(!file_exists('asset')){

    /**
     * Get versioned url for assets
     *
     * @param $path
     * @param $query
     * @return string
     */
    function asset($path, $query = null)
    {
        $version = is_null($query) ? "%s?%s" : "%s?$query=%s";
        $random = md5('random');

        $strategy = new \Legato\Framework\src\asset\StaticVersionStrategy(
            $random, $version
        );

        return $strategy->url($path);
    }
}