/** * @inheritdoc */ public function fetch($template) { $view = Laravel\View::make($template, $this->model); Laravel\Blade::sharpen(); $responses = Laravel\Event::fire(Laravel\View::engine, array($view)); return $responses[0]; }
| */ ini_set('display_errors', 'On'); /* |-------------------------------------------------------------------------- | Laravel Configuration Loader |-------------------------------------------------------------------------- | | The Laravel configuration loader is responsible for returning an array | of configuration options for a given bundle and file. By default, we | use the files provided with Laravel; however, you are free to use | your own storage mechanism for configuration arrays. | */ Laravel\Event::listen(Laravel\Config::loader, function ($bundle, $file) { return Laravel\Config::file($bundle, $file); }); /* |-------------------------------------------------------------------------- | Register Class Aliases |-------------------------------------------------------------------------- | | Aliases allow you to use classes without always specifying their fully | namespaced path. This is convenient for working with any library that | makes a heavy use of namespace for class organization. Here we will | simply register the configured class aliases. | */ $aliases = Laravel\Config::get('application.aliases'); Laravel\Autoloader::$aliases = $aliases; /*
| trace, we can turn off the display_errors ini directive. However, you | may want to enable this option if you ever run into a dreaded white | screen of death, as it can provide some clues. | */ ini_set('display_errors', 'On'); $config_app = (require path('public') . 'config.app.php'); Laravel\Event::listen(Laravel\Config::loader, function ($bundle, $file) use($config_app) { if ($bundle !== 'application') { return Laravel\Config::file($bundle, $file); } $load = Laravel\Config::file($bundle, $file); switch ($file) { case 'application': $config = array('url' => isset($config_app['url']) ? $config_app['url'] : '', 'timezone' => $config_app['timezone'], 'key' => $config_app['key'], 'index' => !$config_app['mod_rewrite'] ? 'index.php' : '', 'mail' => $config_app['mail']); $load = $config + $load; break; case 'database': $config['connections'][$config_app['database']['driver']] = array('host' => $config_app['database']['host'], 'database' => $config_app['database']['database'], 'username' => $config_app['database']['username'], 'password' => $config_app['database']['password'], 'charset' => 'utf8', 'prefix' => '', 'driver' => $config_app['database']['driver']); $config['default'] = $config_app['database']['driver']; $load = $config + $load; break; } return $load; }); /* |-------------------------------------------------------------------------- | Register Class Aliases |-------------------------------------------------------------------------- | | Aliases allow you to use classes without always specifying their fully | namespaced path. This is convenient for working with any library that
} /** * Hook into the Laravel view loader */ Laravel\Event::override(Laravel\View::loader, function ($bundle, $view) use($loader, $ext) { // Use the custom Laravel Twig loader for Twig views... if (starts_with($view, 'twig|')) { return $loader->getPath($bundle, substr($view, 5)); } elseif (starts_with($bundle, 'twig|')) { return $loader->getPath(substr($bundle, 5), $view); } else { return View::file($bundle, $view); } }); /** * Hook into the Laravel view engine */ Laravel\Event::listen(Laravel\View::engine, function ($view) use($loader, $cache, $ext, $debug, $autoescape) { // Only handle views that have the Twig marker if (!starts_with($view->view, 'twig|')) { return false; } // Load the Laravel Twig extensions require_once 'extensions/HTML.php'; $twig = new Twig_Environment($loader, compact('cache', 'debug', 'autoescape')); // Register the Laravel Twig extensions $twig->addExtension(new Laravel_Twig_Extension()); // Render back the template contents return $twig->render(substr($view->view, 5), $view->data()); }); });
Laravel\Event::listen('laravel.started: dropbox', function () { // Register a simple autoload function spl_autoload_register(function ($class) { if (substr($class, 0, 7) === 'Dropbox') { $class = str_replace('\\', '/', $class); require_once __DIR__ . '/' . $class . '.php'; } }); $app_key = Laravel\Config::get('dropbox::config.app_key'); $app_secret = Laravel\Config::get('dropbox::config.app_secret'); $encryption_key = Laravel\Config::get('dropbox::config.encryption_key'); if (empty($app_key) || empty($app_secret)) { throw new \Dropbox\Exception('Please set your Dropbox App key & secret.'); } if (strlen($encryption_key) !== 32) { throw new \Dropbox\Exception('Expecting a 32 byte Dropbox encryption key, got ' . strlen($encryption_key)); } // Check whether to use HTTPS and set the callback URL $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http'; $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; $http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1'; $callback = $protocol . '://' . $http_host . $request_uri; // Instantiate the required Dropbox objects $encrypter = new \Dropbox\OAuth\Storage\Encrypter($encryption_key); $storage = new \Dropbox\OAuth\Storage\Session($encrypter); if ($access_token = Config::get('dropbox::config.access_token')) { $storage->set((object) $access_token, 'access_token'); } $OAuth = new \Dropbox\OAuth\Consumer\Curl($app_key, $app_secret, $storage, $callback); $dropbox = new \Dropbox\API($OAuth, Laravel\Config::get('dropbox::config.root')); IoC::instance('dropbox::session', $storage); IoC::instance('dropbox::api', $dropbox); });