/** * Register the Module Service Provider. * * @param array $properties * * @return void * * @throws \Nova\Module\FileMissingException */ protected function registerServiceProvider($properties) { $namespace = $this->resolveNamespace($properties); $file = $this->getPath() . $namespace . DS . 'Providers' . DS . $namespace . 'ServiceProvider.php'; // Calculate the name of Service Provider, including the namespace. $serviceProvider = $this->getNamespace() . "\\{$namespace}\\Providers\\{$namespace}ServiceProvider"; if (class_exists($serviceProvider)) { $this->app->register($serviceProvider); } }
private static function _loadConfig() { if (!self::$_config) { Application::getInstance()->config->load('NoticeAdapter'); self::$_config = Application::getInstance()->config->get('NoticeAdapter'); } }
/** * Register the load events for the given provider. * * @param \Foundation\Application $app * @param string $provider * @param array $events * @return void */ protected function registerLoadEvents(Application $app, $provider, array $events) { if (count($events) < 1) { return; } $app->make('events')->listen($events, function () use($app, $provider) { $app->register($provider); }); }
function __construct() { if (self::$_allowInstance) { Application::getInstance()->config->load('ShellConfig'); $this->_config = Application::getInstance()->config->get('ShellConfig'); } else { Exception::throwException(101, ['FindConfig']); } }
function __construct() { Application::getInstance()->config->load('ShellConfig'); $config = Application::getInstance()->config->get('ShellConfig'); if (!empty($config) && isset($config['shell_cmd']) && !empty($config['shell_cmd'])) { $this->_shellCmd = $config['shell_cmd']; } else { Exception::throwException(10007); } }
public function handle(array $params = null) { $tokenName = Application::getInstance()->config->get('App.cookie_prefix') . Application::getInstance()->config->get('App.token_cookie_name'); $token = Input::cookie($tokenName); if (!empty($token)) { $result = Account::where('ucenter_token', $token)->limit(1)->get(); if (!empty($result)) { $result = $result[0]; if (time() < $result->token_expired) { Request::addParameter('currentAccount', $result); } } } }
/** * Prepare the database connection instance. * * @param \Database\Connection $connection * @return \Database\Connection */ protected function prepare(Connection $connection) { $connection->setFetchMode($this->app['config']['database.fetch']); if ($this->app->bound('events')) { $connection->setEventDispatcher($this->app['events']); } $app = $this->app; $connection->setCacheManager(function () use($app) { return $app['cache']; }); $connection->setPaginator(function () use($app) { return $app['paginator']; }); $connection->setReconnector(function ($connection) { $this->reconnect($connection->getName()); }); return $connection; }
define('STORAGE_PATH', APPDIR . 'Storage' . DS); //-------------------------------------------------------------------------- // Set The Framework Version //-------------------------------------------------------------------------- define('VERSION', Application::VERSION); //-------------------------------------------------------------------------- // Load Global Configuration //-------------------------------------------------------------------------- $path = APPDIR . 'Config.php'; if (is_readable($path)) { require $path; } //-------------------------------------------------------------------------- // Create New Application //-------------------------------------------------------------------------- $app = new Application(); $app->instance('app', $app); //-------------------------------------------------------------------------- // Detect The Application Environment //-------------------------------------------------------------------------- $env = $app->detectEnvironment(array('local' => array('darkstar'))); //-------------------------------------------------------------------------- // Bind Paths //-------------------------------------------------------------------------- $paths = array('base' => ROOTDIR, 'app' => APPDIR, 'public' => PUBLICDIR, 'storage' => STORAGE_PATH); $app->bindInstallPaths($paths); //-------------------------------------------------------------------------- // Load The Framework Facades //-------------------------------------------------------------------------- Facade::clearResolvedInstances(); Facade::setFacadeApplication($app);
<?php use Foundation\Application; use HTTP\Kernel; use HTTP\Request; use Routing\Router; require __DIR__ . '/../vendor/autoload.php'; $application = new Application(); $application->share('i want to see the dashboard', function () { echo '<h1>Dashboard</h1>'; }); $router = new Router(); $router->add('/', 'i want to see the dashboard'); $kernel = new Kernel($router, $application); $request = Request::create('/', 'GET'); $response = $kernel->handle($request); $response->send();
<?php use Foundation\Application; use HTTP\Kernel; use HTTP\Request; use HTTP\Session; use Routing\Router; require __DIR__ . '/../vendor/autoload.php'; $application = new Application(); $application->share('HTTP\\Session', function () { return new Session(); }); $application->share('i want to save to the session', function (Session $session) { $session->name = 'Reno Jackson'; $session->quotes = 'We\'re gonna be rich'; }); $application->share('i want to read the session', function (Session $session) { dump($session); }); $application->share('i want to flash to the session', function (Session $session) { // $session->flash->city = 'Nijmegen'; }); $application->share('i want to read the session flash', function (Session $session) { dump($session->flash); }); $router = new Router(); $router->add('/', 'i want to save to the session'); $router->add('/read', 'i want to read the session'); $router->add('/add/flash', 'i want to flash to the session'); $router->add('/read/flash', 'i want to read the session flash'); $kernel = new Kernel($router, $application);