src/Mmanos/Casset/Container.php
public function combine(array $assets, $type)
	{
		$paths = array();
		$lastmod = 0;
		foreach ($assets as $asset) {
			$paths[] = $asset['path'];
			$mod = File::lastModified($asset['path']);
			if ($mod > $lastmod) {
				$lastmod = $mod;
			}
		}
		
		$file = $this->cache_path . '/casset-' . md5(implode(',', $paths) . $lastmod) . '-' . $this->name;
		$file .= ('script' === $type) ? '.js' : '.css';
		
		$combine = false;
		if (!File::exists($file)) {
			$combine = true;
		}
		else if (File::lastModified($file) < $lastmod) {
			$combine = true;
		}
		
		if ($combine) {
			$content = '';
			
			foreach ($assets as $asset) {
				if (!File::exists($asset['path'])) {
					continue;
				}
				
				$c = File::get($asset['path']);
				
				if ($this->minify
					&& !(stripos($asset['source'], '.min')
						|| stripos($asset['source'], '-min')
					)
				) {
					switch ($type) {
						case 'style':
							$c = Compressors\Css::process($c);
							break;
							
						case 'script':
							$c = Compressors\Js::minify($c);
							break;
					}
				}
				
				$content .= "/* {$asset['source']} */\n$c\n\n";
			}
			
			File::put($file, $content);
		}
		
		return array(array(
			'path'       => $file,
			'attributes' => array(),
			'url'        => str_ireplace($this->public_path, '', $file),
		));
	}
public function combine(array $assets, $type)
	{
		$paths = array();
		$lastmod = 0;
		foreach ($assets as $asset) {
			$paths[] = $asset['path'];
			$mod = File::lastModified($asset['path']);
			if ($mod > $lastmod) {
				$lastmod = $mod;
			}
		}
		
		$file = $this->cache_path . '/casset-' . md5(implode(',', $paths) . $lastmod) . '-' . $this->name;
		$file .= ('script' === $type) ? '.js' : '.css';
		
		$combine = false;
		if (!File::exists($file)) {
			$combine = true;
		}
		else if (File::lastModified($file) < $lastmod) {
			$combine = true;
		}
		
		if ($combine) {
			$content = '';
			
			foreach ($assets as $asset) {
				if (!File::exists($asset['path'])) {
					continue;
				}
				
				$c = File::get($asset['path']);
				
				if ($this->minify
					&& !(stripos($asset['source'], '.min')
						|| stripos($asset['source'], '-min')
					)
				) {
					switch ($type) {
						case 'style':
							$c = Compressors\Css::process($c);
							break;
							
						case 'script':
							$c = Compressors\Js::minify($c);
							break;
					}
				}
				
				$content .= "/* {$asset['source']} */\n$c\n\n";
			}
			
			File::put($file, $content);
		}
		
		return array(array(
			'path'       => $file,
			'attributes' => array(),
			'url'        => str_ireplace($this->public_path, '', $file),
		));
	}
public function combine ( array $ assets , $ type ) { $ paths = array ( ) ; $ lastmod = 0 ; foreach ( $ assets as $ asset ) { $ paths [ ] = $ asset [ 'path' ] ; $ mod = File :: lastModified ( $ asset [ 'path' ] ) ; if ( $ mod > $ lastmod ) { $ lastmod = $ mod ; } } $ file = $ this -> cache_path . '/casset-' . md5 ( implode ( ',' , $ paths ) . $ lastmod ) . '-' . $ this -> name ; $ file .= ( 'script' === $ type ) ? '.js' : '.css' ; $ combine = false ; if ( ! File :: exists ( $ file ) ) { $ combine = true ; } else if ( File :: lastModified ( $ file ) < $ lastmod ) { $ combine = true ; } if ( $ combine ) { $ content = '' ; foreach ( $ assets as $ asset ) { if ( ! File :: exists ( $ asset [ 'path' ] ) ) { continue ; } $ c = File :: get ( $ asset [ 'path' ] ) ; if ( $ this -> minify && ! ( stripos ( $ asset [ 'source' ] , '.min' ) || stripos ( $ asset [ 'source' ] , '-min' ) ) ) { switch ( $ type ) { case 'style' : $ c = Compressors \ Css :: process ( $ c ) ; break ; case 'script' : $ c = Compressors \ Js :: minify ( $ c ) ; break ; } } $ content .= "/* {$asset['source']} */\n$c\n\n" ; } File :: put ( $ file , $ content ) ; } return array ( array ( 'path' => $ file , 'attributes' => array ( ) , 'url' => str_ireplace ( $ this -> public_path , '' , $ file ) , ) ) ; }
Combine the given array of assets. Minify, if enabled.
Returns new array containing one asset.

@param array  $assets Array of assets.
@param string $type   File type (script, style).

@return array
Combine the given array of assets . Minify if enabled . Returns new array containing one asset .