Exemplo n.º 1
0
<?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');
    });
}
Exemplo n.º 2
0
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 {
Exemplo n.º 3
0
 /**
  * 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']);
 }