本文整理汇总了PHP中Bundle::handles方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::handles方法的具体用法?PHP Bundle::handles怎么用?PHP Bundle::handles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle::handles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
<?php
/**
* Register all the classes that are used by Basset with the autoloader.
*/
Autoloader::map(array('Basset' => __DIR__ . DS . 'classes' . DS . 'basset.php', 'Basset\\Asset' => __DIR__ . DS . 'classes' . DS . 'asset.php', 'Basset\\Cache' => __DIR__ . DS . 'classes' . DS . 'cache.php', 'Basset\\Config' => __DIR__ . DS . 'classes' . DS . 'config.php', 'Basset\\Container' => __DIR__ . DS . 'classes' . DS . 'container.php', 'Basset\\Vendor\\CSSCompress' => __DIR__ . DS . 'classes' . DS . 'vendor' . DS . 'csscompress.php', 'Basset\\Vendor\\JSMin' => __DIR__ . DS . 'classes' . DS . 'vendor' . DS . 'jsmin.php', 'Basset\\Vendor\\URIRewriter' => __DIR__ . DS . 'classes' . DS . 'vendor' . DS . 'urirewriter.php', 'Basset\\Vendor\\lessc' => __DIR__ . DS . 'classes' . DS . 'vendor' . DS . 'less.php'));
if (starts_with(URI::current(), Bundle::option('basset', 'handles'))) {
/**
* In this before filter we'll grab the compiled assets for this route and return them here.
* This is what makes it possible for Basset routes to be adjusted prior to them being displayed.
*/
$handler = Bundle::handles(URI::current());
Route::filter("{$handler}::before", function () {
Config::set('session.driver', '');
return Basset::compiled();
});
/**
* After the Basset route is run we'll adjust the response object setting the appropriate content
* type for the assets.
*/
Route::filter("{$handler}::after", function ($response) {
$types = array('less' => 'text/css', 'sass' => 'text/css', 'scss' => 'text/css', 'css' => 'text/css', 'js' => 'text/javascript');
$extension = File::extension(Request::uri());
if (array_key_exists($extension, $types)) {
$response->header('Content-Type', $types[$extension]);
}
// To prevent any further output being added to any Basset routes we'll clear any events listening
// for the laravel.done event.
Event::clear('laravel.done');
});
}
示例2: function
Route::filter('mwi.admin_controller_start', function ($controller) {
$permissions = new \Permissions\Check(\Request::route(), $controller);
if (!Bundle::exists('auth')) {
return;
}
// Fix route bundle if
// its an administration route
$uri = Request::route()->uri;
$uri_parts = explode('/', $uri);
// check if is set
// check if first part is administration uri
// check if is not only the dashboard http://site.com/[admin]
if (isset($uri_parts['0']) and $uri_parts['0'] = ADM_URI and count($uri_parts) > 1) {
unset($uri_parts['0']);
$uri = implode('/', $uri_parts);
Request::route()->bundle = Bundle::handles($uri);
$controller->bundle = Request::route()->bundle;
}
$result = $permissions::can(Auth::user());
if (isset($result)) {
if (!$result->is_allowed) {
if (Request::ajax()) {
return 'not permited';
} else {
return \Response::error('401', get_object_vars($result));
}
}
} else {
if (Request::ajax()) {
return View::make('permissions::partials.ajax_not_authorized_page_details')->render();
} else {
示例3: testHandlesMethodReturnsBundleThatHandlesURI
/**
* Test Bundle::handles method.
*
* @group laravel
*/
public function testHandlesMethodReturnsBundleThatHandlesURI()
{
Bundle::register('foo', array('handles' => 'foo-bar'));
$this->assertEquals('foo', Bundle::handles('foo-bar/admin'));
unset(Bundle::$bundles['foo']);
}