/** * Get assets code by type from an holder * * @param string $extension * @param string $name */ public static function code($extension = null, $name = null) { $assets = static::get($extension, $name); // let packtacular handle css and less files if ($extension == 'css') { foreach (static::holder($name)->get('_packtacular') as $key => $pack) { if (!array_key_exists('less', $pack)) { $pack['less'] = array(); } if (!array_key_exists('css', $pack)) { $pack['css'] = array(); } $files = array_merge($pack['css'], $pack['less']); if (!empty($files)) { CCArr::push(Packtacular::handle($files, basename(static::holder($name)->path) . '/' . $name . '/', $key . '_{time}.css'), $assets); } } } elseif ($extension == 'js') { foreach (static::holder($name)->get('_packtacular') as $key => $pack) { if (!array_key_exists('js', $pack)) { $pack['js'] = array(); } if (!empty($pack['js'])) { CCArr::push(Packtacular::handle($pack['js'], basename(static::holder($name)->path) . '/' . $name . '/', $key . '_{time}.js'), $assets); } } } $buffer = ""; foreach ($assets as $item) { $buffer .= call_user_func('CCAsset::' . $extension, $item, $name); } return $buffer; }
/** * test array push * * @expectedException InvalidArgumentException */ public function testArrayPushException() { $not_an_array = null; // push CCArr::push('Batz', $not_an_array); }