/**
  * Register the service provider.
  */
 public function register()
 {
     //include our view composers, and routes to avoid issues with catch-all routes defined by users
     include __DIR__ . '/../../viewComposers.php';
     include __DIR__ . '/../../routes.php';
     //the admin validator
     $this->app['admin_validator'] = $this->app->share(function ($app) {
         //get the original validator class so we can set it back after creating our own
         $originalValidator = LValidator::make(array(), array());
         $originalValidatorClass = get_class($originalValidator);
         //temporarily override the core resolver
         LValidator::resolver(function ($translator, $data, $rules, $messages) use($app) {
             $validator = new Validator($translator, $data, $rules, $messages);
             $validator->setUrlInstance($app->make('url'));
             return $validator;
         });
         //grab our validator instance
         $validator = LValidator::make(array(), array());
         //set the validator resolver back to the original validator
         LValidator::resolver(function ($translator, $data, $rules, $messages) use($originalValidatorClass) {
             return new $originalValidatorClass($translator, $data, $rules, $messages);
         });
         //return our validator instance
         return $validator;
     });
     $arr = (include __DIR__ . '/../../config/administrator.php');
     //set up the shared instances
     $this->app['admin_config_factory'] = $this->app->share(function ($app) use($arr) {
         return new ConfigFactory($app->make('admin_validator'), LValidator::make(array(), array()), $arr);
     });
     $this->app['admin_field_factory'] = $this->app->share(function ($app) {
         return new FieldFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_datatable'] = $this->app->share(function ($app) use($arr) {
         $dataTable = new DataTable($app->make('itemconfig'), $app->make('admin_column_factory'), $app->make('admin_field_factory'));
         $dataTable->setRowsPerPage($app->make('session.store'), $arr['global_rows_per_page']);
         return $dataTable;
     });
     $this->app['admin_column_factory'] = $this->app->share(function ($app) {
         return new ColumnFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_action_factory'] = $this->app->share(function ($app) {
         return new ActionFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_menu'] = $this->app->share(function ($app) {
         return new Menu($app->make('config'), $app->make('admin_config_factory'));
     });
 }
Ejemplo n.º 2
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //the admin validator
     $this->app['admin_validator'] = $this->app->share(function ($app) {
         //get the original validator class so we can set it back after creating our own
         $originalValidator = LValidator::make(array(), array());
         $originalValidatorClass = get_class($originalValidator);
         //temporarily override the core resolver
         LValidator::resolver(function ($translator, $data, $rules, $messages) use($app) {
             $validator = new Validator($translator, $data, $rules, $messages);
             $validator->setUrlInstance($app->make('url'));
             return $validator;
         });
         //grab our validator instance
         $validator = LValidator::make(array(), array());
         //set the validator resolver back to the original validator
         LValidator::resolver(function ($translator, $data, $rules, $messages) use($originalValidatorClass) {
             return new $originalValidatorClass($translator, $data, $rules, $messages);
         });
         //return our validator instance
         return $validator;
     });
     //set up the shared instances
     $this->app['admin_config_factory'] = $this->app->share(function ($app) {
         return new ConfigFactory($app->make('admin_validator'), LValidator::make(array(), array()), Config::get('administrator::administrator'));
     });
     $this->app['admin_field_factory'] = $this->app->share(function ($app) {
         return new FieldFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_datatable'] = $this->app->share(function ($app) {
         $dataTable = new DataTable($app->make('itemconfig'), $app->make('admin_column_factory'), $app->make('admin_field_factory'));
         $dataTable->setRowsPerPage($app->make('session.store'), Config::get('administrator::administrator.global_rows_per_page'));
         return $dataTable;
     });
     $this->app['admin_column_factory'] = $this->app->share(function ($app) {
         return new ColumnFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_action_factory'] = $this->app->share(function ($app) {
         return new ActionFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
     });
     $this->app['admin_menu'] = $this->app->share(function ($app) {
         return new Menu($app->make('config'), $app->make('admin_config_factory'));
     });
 }
	/**
	 * Bootstrap the application events.
	 *
	 * @return void
	 */
	public function boot()
	{
		$this->package('frozennode/administrator');

		//set the locale
		$this->setLocale();

		//the admin validator
		$this->app['admin_validator'] = $this->app->share(function($app)
		{
			//get the original validator class so we can set it back after creating our own
			$originalValidator = LValidator::make(array(), array());
			$originalValidatorClass = get_class($originalValidator);

			//temporarily override the core resolver
			LValidator::resolver(function($translator, $data, $rules, $messages) use ($app)
			{
				$validator = new Validator($translator, $data, $rules, $messages);
				$validator->setUrlInstance($app->make('url'));
				return $validator;
			});

			//grab our validator instance
			$validator = LValidator::make(array(), array());

			//set the validator resolver back to the original validator
			LValidator::resolver(function($translator, $data, $rules, $messages) use ($originalValidatorClass)
			{
				return new $originalValidatorClass($translator, $data, $rules, $messages);
			});

			//return our validator instance
			return $validator;
		});

		//set up the shared instances
		$this->app['admin_config_factory'] = $this->app->share(function($app)
		{
			return new ConfigFactory($app->make('admin_validator'), Config::get('administrator::administrator'));
		});

		$this->app['admin_field_factory'] = $this->app->share(function($app)
		{
			return new FieldFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
		});

		$this->app['admin_datatable'] = $this->app->share(function($app)
		{
			$dataTable = new DataTable($app->make('itemconfig'), $app->make('admin_column_factory'), $app->make('admin_field_factory'));
			$dataTable->setRowsPerPage($app->make('session'), Config::get('administrator::administrator.global_rows_per_page'));

			return $dataTable;
		});

		$this->app['admin_column_factory'] = $this->app->share(function($app)
		{
			return new ColumnFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
		});

		$this->app['admin_action_factory'] = $this->app->share(function($app)
		{
			return new ActionFactory($app->make('admin_validator'), $app->make('itemconfig'), $app->make('db'));
		});

		$this->app['admin_menu'] = $this->app->share(function($app)
		{
			return new Menu($app->make('config'), $app->make('admin_config_factory'));
		});

		//include our filters, view composers, and routes
		include __DIR__.'/../../filters.php';
		include __DIR__.'/../../viewComposers.php';
		include __DIR__.'/../../routes.php';

		$this->app['events']->fire('administrator.ready');
	}