Exemplo n.º 1
0
function aliasIn($ns)
{
    $overridenPlarx = \Bundle::option('vane', 'ignorePlarx');
    $ns = trim($ns, '\\');
    foreach ($overridenPlarx as $class) {
        \Autoloader::alias("Vane\\{$class}", "{$ns}\\{$class}");
    }
    Plarx::supersede($ns, $overridenPlarx);
}
Exemplo n.º 2
0
<?php

namespace Vane;

\Bundle::$bundles['vane']['ignorePlarx'] = array('Str', 'HLEx', 'Log', 'Event', 'Validator');
if (!\Bundle::exists('plarx')) {
    throw new Error('Vane requires Plarx bundle installed.');
} else {
    \Bundle::start('plarx');
    \Px\Plarx::supersede(__NAMESPACE__, \Bundle::option('vane', 'ignorePlarx'));
}
if (!\Bundle::exists('squall')) {
    throw new Error('Vane requires Squall bundle installed.');
} else {
    \Bundle::start('squall');
    \Squall\initEx(__NAMESPACE__);
}
\Autoloader::namespaces(array(__NAMESPACE__ => __DIR__ . DS . 'classes'));
require_once __DIR__ . DS . 'core.php';
overrideHTMLki('vane::', __NAMESPACE__);
// vane::auth[:[!]perm[:[!]perm.2[...]]] [|filter:2 [|...]]
//
// This filter will always deny access for non-authorized users even if guest
// permissions allow for given features - this is so because protected controllers
// rely on current user being logged in.
\Route::filter('vane::auth', function ($feature_1 = null) {
    $features = is_array($feature_1) ? $feature_1 : func_get_args();
    $block = is_object(end($features)) ? array_pop($features) : null;
    $user = \Auth::user();
    if ($user and !$user instanceof UserInterface) {
        $msg = "When using vane::auth filter object returned by Auth::user()" . " (" . get_class($user) . " here) must implement Vane\\UserInterface." . " This is not so - returned 403 for user {$user->id}.";
Exemplo n.º 3
0
 /**
  * Return the URL to the asset route container.
  * 
  * @param  string  $route
  * @return string
  */
 public static function show($route)
 {
     $methods = array('css' => 'style', 'js' => 'script');
     // If the container is set to development mode then Basset will show all the assets that have been added
     // up until now. This may be a problem if assets are added after the template view is rendered, however
     // this is acceptable. Assets should be added as early as possible during the application logic.
     $container = static::$routes[Bundle::option('basset', 'handles') . '/' . $route];
     if ($container->config->get('development')) {
         $response = '<!-- BASSET NOTICE: Some assets may not be displayed depending on where they were set during the application flow. -->';
         return $response . PHP_EOL . $container->compile();
     }
     return HTML::$methods[File::extension($route)](URL::to_asset(Bundle::option('basset', 'handles') . '/' . $route));
 }
Exemplo n.º 4
0
     * 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');
    });
}
/**
 * If the current URI is not being handled by Basset then all registered Basset routes will be
 * compiled once Laravel has finished doing its thing.
 */
if (!starts_with(URI::current(), Bundle::option('basset', 'handles'))) {
    Event::listen('laravel.done', function () {
        Basset::compile();
    });
}
Exemplo n.º 5
0
<?php

if (Bundle::option('textpub', 'auto')) {
    $paths = TextPub::option('paths') ?: Bundle::option('textpub', 'handles');
    if (!$paths) {
        throw new Exception("Text Publisher (textpub) requires 'paths' or/and" . " 'handles' options but none are set.");
    }
    TextPub::register('' . Router::$bundle, $paths);
}
Exemplo n.º 6
0
 static function bundleURL()
 {
     $handles = \Bundle::option(Request::$route->bundle, 'handles');
     $handles = trim($handles, '/');
     return $handles === '' ? '/' : "/{$handles}/";
 }
Exemplo n.º 7
0
 /**
  * Test the Bundle::get method.
  *
  * @group laravel
  */
 public function testOptionMethodReturnsBundleOption()
 {
     $this->assertFalse(Bundle::option('dashboard', 'auto'));
     $this->assertEquals('dashboard', Bundle::option('dashboard', 'location'));
 }