Skip to content

Instantly share code, notes, and snippets.

@vespakoen
Created May 22, 2012 19:36
Show Gist options
  • Save vespakoen/2771139 to your computer and use it in GitHub Desktop.
Save vespakoen/2771139 to your computer and use it in GitHub Desktop.
Add asset
<?php
public function add($name, $source = null, $dependencies = array(), $attributes = array())
{
$type = (pathinfo($source, PATHINFO_EXTENSION) == 'css') ? 'style' : 'script';
return $this->$type($name, $source, $dependencies, $attributes);
}
protected function register($type, $name, $source, $dependencies, $attributes)
{
if(is_null($source))
{
$source = $name;
$name = sizeof($this->assets[$type]) + 1;
}
$dependencies = (array) $dependencies;
$attributes = (array) $attributes;
$this->assets[$type][$name] = compact('source', 'dependencies', 'attributes');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment