本文整理汇总了PHP中Assets::require_valid_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Assets::require_valid_type方法的具体用法?PHP Assets::require_valid_type怎么用?PHP Assets::require_valid_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assets
的用法示例。
在下文中一共展示了Assets::require_valid_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_require_valid_type
public function test_require_valid_type()
{
$this->assertTrue(Assets::require_valid_type('js'));
$this->assertTrue(Assets::require_valid_type('css'));
$this->setExpectedException('Kohana_Exception');
$this->assertTrue(Assets::require_valid_type('php'));
}
示例2: __construct
/**
* Set up environment
*
* @param string $type
* @param string $name
*/
public function __construct($type, $name = 'all')
{
// Check type
Assets::require_valid_type($type);
// Set type and name
$this->_type = $type;
$this->_name = $name;
// Set asset file and web file
$this->_destination_file = Assets::file_path($type, $name . '.' . $type);
$this->_destination_web = Assets::web_path($type, $name . '.' . $type);
}
示例3: __construct
/**
* Set up the environment
*
* @param string $type
* @param string $file
* @param string $options
* @param string $destination_path
* @param bool $copy
* @param string $folder
*/
function __construct($type, $file, array $options = array(), $destination_path = NULL, $copy = TRUE, $folder = NULL)
{
// Set processor to use
$this->_processor = Arr::get($options, 'processor', Arr::get(Kohana::$config->load('asset-merger')->get('processor'), $type));
// Set condition
$this->_condition = Arr::get($options, 'condition');
$this->_folder = $folder;
// Set weight
if (!empty($options['weight'])) {
$this->_weight = $options['weight'];
}
// Set load paths
if (!empty($options['load_paths'])) {
$this->_load_paths = $options['load_paths'][$type];
} elseif ($load_paths = Kohana::$config->load('asset-merger')->get('load_paths')) {
$this->_load_paths = Arr::get($load_paths, $type);
}
// Set media
if (!empty($options['media'])) {
$this->_media = $options['media'];
}
// Set type and file
$this->_type = $type;
$this->_file = $file;
$this->_copy = $copy;
// Check if the type is a valid type
Assets::require_valid_type($type);
if (Valid::url($file)) {
// No remote files allowed
throw new Kohana_Exception('The asset :file must be local file', array(':file' => $file));
}
// Look for the specified file in each load path
foreach ((array) $this->_load_paths as $path) {
$path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if (is_file($path . $file)) {
// Set the destination and source file
$this->_destination_file = Assets::file_path($type, $file, $destination_path, $this->_folder);
$this->_source_file = $path . $file;
// Don't continue
break;
}
}
if (!$this->source_file()) {
// File not found
throw new Kohana_Exception('Asset :file of type :type not found inside :paths', array(':file' => $file, ':type' => $type, ':paths' => join(', ', (array) Arr::get(Kohana::$config->load('asset-merger')->get('load_paths'), $type))));
}
if (!is_dir(dirname($this->destination_file())) and $this->copy()) {
// Create directory for destination file
mkdir(dirname($this->destination_file()), 0777, TRUE);
}
// Get the file parts
$fileparts = explode('.', basename($file));
// Extension index
$extension_index = array_search($this->type(), $fileparts);
// Set engines
$this->_engines = array_reverse(array_slice($fileparts, $extension_index + 1));
// Set the web destination
$this->_destination_web = Assets::web_path($type, $file, $destination_path, $this->_folder);
}
示例4: __construct
/**
* Set up environment
*
* @param string $type
* @param string $name
*/
public function __construct($type, $name = 'all', $destination_path = NULL, $copy = TRUE, $folder)
{
// Check type
Assets::require_valid_type($type);
// Set type and name
$this->_type = $type;
$this->_name = $name;
$this->_copy = $copy;
$this->_folder = $folder;
$this->_destination_path = $destination_path;
}
示例5: __construct
/**
* Set up the environment
*
* @param string $type
* @param string $file
* @param array $options
*/
function __construct($type, $file, array $options = array())
{
// Set processor to use
$this->_processor = Arr::get($options, 'processor', Kohana::$config->load('asset-merger.processor.' . $type));
// Set condition
$this->_condition = Arr::get($options, 'condition');
// Set type and file
$this->_type = $type;
$this->_file = $file;
// Check if the type is a valid type
Assets::require_valid_type($type);
if (Valid::url($file)) {
// No remote files allowed
throw new Kohana_Exception('The asset :file must be local file', array(':file' => $file));
}
// Look for the specified file in each load path
foreach ((array) Kohana::$config->load('asset-merger.load_paths.' . $type) as $path) {
if (is_file($path . $file)) {
// Set the destination and source file
$this->_destination_file = Assets::file_path($type, $file);
$this->_source_file = $path . $file;
// Don't continue
break;
}
}
if (!$this->source_file()) {
// File not found
throw new Kohana_Exception('Asset :file of type :type not found inside :paths', array(':file' => $file, ':type' => $type, ':paths' => join(', ', (array) Kohana::$config->load('asset-merger.load_paths.' . $type))));
}
if (!is_dir(dirname($this->destination_file()))) {
// Create directory for destination file
mkdir(dirname($this->destination_file()), 0777, TRUE);
}
// Get the file parts
$fileparts = explode('.', basename($file));
// Extension index
$extension_index = array_search($this->type(), $fileparts);
// Set engines
$this->_engines = array_reverse(array_slice($fileparts, $extension_index + 1));
// Set the web destination
$this->_destination_web = Assets::web_path($type, $file);
}