示例#1
0
 /**
  * Resolve an instance of the given seeder class.
  *
  * @param  string $class
  *
  * @return \Illuminate\Database\Seeder
  */
 protected function resolve($class)
 {
     if (isset($this->container)) {
         $instance = $this->container->make($class);
         $instance->setContainer($this->container);
     } else {
         $instance = new $class();
     }
     if (isset($this->command)) {
         $instance->setCommand($this->command);
     }
     return $instance;
 }
示例#2
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  * @throws DependencyInstanceNotFound
  * @throws \RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $header_style = new OutputFormatterStyle('white', 'default', ['bold']);
     $output->getFormatter()->setStyle('header', $header_style);
     $response = shell_exec('rm -Rf ' . CACHE . 'blade/* 2>&1 1> /dev/null');
     $response = shell_exec('rm -Rf ' . CACHE . 'twig/* 2>&1 1> /dev/null');
     Forge::find('logger')->log('info', 'caches were cleared.');
     $output->writeln('<header>Caches cleared.</header>');
 }
示例#3
0
 /**
  * Console constructor.
  *
  * @param ConfigInterface $config
  * @param Paths           $paths
  * @param string          $version
  */
 public function __construct(ConfigInterface $config, Paths $paths, $version = \F9\Application\Application::VERSION)
 {
     $this->config = $config;
     $this->paths = $paths;
     /** @var Container $app */
     $app = Forge::find('app');
     // the parent is a hijacked copy of the illuminate console application.
     // we hijacked it mainly to override a few properties - such as the title.
     parent::__construct(forge('illuminate.container'), forge('illuminate.events'), $version);
     //$this->bootSettings();
     $this->configureEnvironment();
     // in all cases, register the framework commands
     $this->registerFrameworkCommands();
     // register the cloned artisan commands
     $this->registerArtisanCommands();
 }
示例#4
0
 /**
  * ServiceProvider constructor.
  *
  * @param Application|SilexApplication|Container $application
  */
 public function __construct($application)
 {
     $this->container = Forge::getInstance();
     $this->app = $application ?: $this->container['app'];
     $this->config = $this->app['config'];
 }
示例#5
0
 /**
  * @param                  $config
  * @param SilexApplication $app
  * @param                  $events
  * @param Forge            $container
  * @param                  $global_scope
  *
  * @return mixed
  */
 private function registerInstances($config, $app, $events, $container, $global_scope)
 {
     $app['config'] = $config;
     $app['nine.events'] = $events;
     $app['illuminate.container'] = $container;
     $container->instance('illuminate.container', $container);
     $container->instance('illuminate.events', new Dispatcher());
     $container->instance('app', $app);
     $container->add('app', function () use($app) {
         return $app;
     });
     // align the Nine Events object with the Core EventDispatcher (Symfony)
     Events::setEventDispatcher($app['dispatcher']);
     // additional $app registrations. @formatter:off
     $app['app.context'] = 'console';
     $app['container'] = $container;
     $app['global.scope'] = $global_scope;
     $app['app.factory'] = $this;
     $app['paths'] = $container['Paths'];
     //@formatter:on
     return $app;
 }
示例#6
0
 /**
  * Returns a reference to the global scope used primarily by views.
  *
  * @return Scope
  */
 function scope() : Scope
 {
     static $gs;
     $gs = $gs ?: Forge::find('global.scope');
     return $gs;
 }
 /**
  * Register all of the model classes found in the db/model folder.
  *
  * @throws CannotAddNonexistentClass
  */
 private function registerModels()
 {
     // if using eloquent then register all of the eloquent models.
     if ($this->config['database.eloquent_enabled']) {
         // register all of the model classes
         foreach ((new ClassFinder())->findClasses(path('database') . 'models') as $model) {
             Forge::set($model, function () use($model) {
                 return new $model();
             });
         }
     }
 }
示例#8
0
 /**
  * @param array $paths
  *
  * @return Application
  */
 private function makeApplication(array $paths) : Application
 {
     // this is the Illuminate Container
     $container = Forge::getInstance();
     // we'll start by loading the configuration into the Forge Container
     $container->add([Scope::class, 'context'], function () {
         return new Scope();
     });
     $container->add('environment', function () use($container) {
         return $container['GlobalScope'];
     });
     $container->singleton([GlobalScope::class, 'GlobalScope'], $global_scope = new GlobalScope($this));
     $container->singleton([Paths::class, 'Paths'], new Paths($paths));
     $container->singleton([Config::class, 'Config'], $config = Config::createFromFolder(\CONFIG));
     $container->singleton([Events::class, 'Events'], $events = Events::getInstance());
     $container->add('paths', function () use($container) {
         return $container['Paths'];
     });
     $container->add('config', function () use($container) {
         return $container['Config'];
     });
     // the reason we are here
     $app = new NineApplication($container, $config, $events, $global_scope);
     // align the Nine Events object with the Core EventDispatcher (Symfony)
     Events::setEventDispatcher($app['dispatcher']);
     $app['app.context'] = 'app';
     // register the new Application
     $container->singleton([NineApplication::class, 'Application'], $app);
     // synchronize the Application instance with the forge.
     Forge::setApplication($app);
     // additional $app registrations. @formatter:off
     $app['container'] = $container;
     $app['global.scope'] = $global_scope;
     $app['app.factory'] = $this;
     $app['flashbag'] = $app->factory(function () use($app) {
         return $app['session']->getFlashBag();
     });
     $app['paths'] = $container['Paths'];
     //@formatter:on
     return $app;
 }
示例#9
0
文件: DB.php 项目: formula9/framework
 /**
  * ** Fluently set the connection for subsequent method calls. **
  *
  * Warning: More than one connection is not supported and makes no sense.
  *
  * IE:
  *      DB::using(<connection_name>)::table...
  *      - or -
  *      DB::using(<connection_name>)->table...
  *
  * @param string $connectionName
  *
  * @return DB
  */
 public static function using($connectionName = 'default') : DB
 {
     static::$instance = static::$instance ?: new static();
     static::$connection = Forge::find('db')->connection($connectionName);
     return static::$instance;
 }
示例#10
0
 public function __construct(Illuminate\Database\Connection $connection = NULL)
 {
     static::$connection = $connection ?: Forge::find('db.connection');
     static::$schema = static::$connection->getSchemaBuilder();
     static::$instance = $this;
 }