当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::setEventDispatcher方法代码示例

本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::setEventDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::setEventDispatcher方法的具体用法?PHP Model::setEventDispatcher怎么用?PHP Model::setEventDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::setEventDispatcher方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 protected function __construct()
 {
     $this->app = new Container();
     // Register mock instances with IoC container
     $config = $this->getConfig();
     $this->app->singleton('config', function () use($config) {
         return $config;
     });
     list($connector, $manager) = $this->getDatabase();
     $this->app->singleton('db.factory', function () use($connector) {
         return $connector;
     });
     $this->app->singleton('db', function () use($manager) {
         return $manager;
     });
     $auth = $this->getAuth();
     $this->app->singleton('auth', function () use($auth) {
         return $auth;
     });
     $dispatcher = new Dispatcher($this->app);
     $this->app->singleton('events', function () use($dispatcher) {
         return $dispatcher;
     });
     Model::setConnectionResolver($this->app['db']);
     Model::setEventDispatcher($this->app['events']);
 }
开发者ID:nstapelbroek,项目名称:culpa-laravel-5,代码行数:26,代码来源:AppFactory.php

示例2: bootModels

 /**
  * @param $resolver
  */
 protected function bootModels($resolver)
 {
     Model::clearBootedModels();
     Model::setEventDispatcher($this->app['illuminate.events']);
     Model::setConnectionResolver($resolver);
     $this->app['dispatcher']->dispatch(NineEvents::MODELS_BOOTED, new EloquentEvent($this->container->get('db')));
 }
开发者ID:formula9,项目名称:framework,代码行数:10,代码来源:EloquentServiceProvider.php

示例3: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('flarum.db', function () {
         $factory = new ConnectionFactory($this->app);
         $connection = $factory->make($this->app->make('flarum.config')['database']);
         $connection->setEventDispatcher($this->app->make('Illuminate\\Contracts\\Events\\Dispatcher'));
         $connection->setFetchMode(PDO::FETCH_CLASS);
         return $connection;
     });
     $this->app->alias('flarum.db', 'Illuminate\\Database\\ConnectionInterface');
     $this->app->singleton('Illuminate\\Database\\ConnectionResolverInterface', function () {
         $resolver = new ConnectionResolver(['flarum' => $this->app->make('flarum.db')]);
         $resolver->setDefaultConnection('flarum');
         return $resolver;
     });
     $this->app->alias('Illuminate\\Database\\ConnectionResolverInterface', 'db');
     if (Core::isInstalled()) {
         $this->app->booting(function () {
             $resolver = $this->app->make('Illuminate\\Database\\ConnectionResolverInterface');
             Model::setConnectionResolver($resolver);
             Model::setEventDispatcher($this->app->make('events'));
         });
     }
     $this->app->singleton('Flarum\\Migrations\\MigrationRepositoryInterface', function ($app) {
         return new DatabaseMigrationRepository($app['db'], 'migrations');
     });
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:32,代码来源:DatabaseServiceProvider.php

示例4: setUp

 /**
  * Setup the test environment.
  *
  * @return void
  */
 protected function setUp()
 {
     if (!$this->app) {
         $this->refreshApplication();
     }
     $this->setUpTraits();
     foreach ($this->afterApplicationCreatedCallbacks as $callback) {
         call_user_func($callback);
     }
     Facade::clearResolvedInstances();
     Model::setEventDispatcher($this->app['events']);
     $this->setUpHasRun = true;
 }
开发者ID:notadd,项目名称:framework,代码行数:18,代码来源:TestCase.php

示例5: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     Model::setConnectionResolver($this->app['db']);
     Model::setEventDispatcher($this->app['events']);
 }
开发者ID:nix9,项目名称:laracasts,代码行数:10,代码来源:DatabaseServiceProvider.php

示例6: bootEloquent

 /**
  * Bootstrap Eloquent so it is ready for usage.
  *
  * @return void
  */
 public function bootEloquent()
 {
     Eloquent::setConnectionResolver($this->manager);
     // If we have an event dispatcher instance, we will go ahead and register it
     // with the Eloquent ORM, allowing for model callbacks while creating and
     // updating "model" instances; however, if it not necessary to operate.
     if ($dispatcher = $this->getEventDispatcher()) {
         Eloquent::setEventDispatcher($dispatcher);
     }
 }
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:15,代码来源:Manager.php

示例7: withoutModelEvents

 /**
  * Mock the model event dispatcher so all Eloquent events are silenced.
  *
  * @return $this
  */
 protected function withoutModelEvents()
 {
     $mock = Mockery::mock('Illuminate\\Contracts\\Events\\Dispatcher');
     $mock->shouldReceive('fire')->andReturnUsing(function ($called) {
         $this->firedModelEvents[] = $called;
     });
     $mock->shouldReceive('until')->andReturnUsing(function ($called) {
         $this->firedModelEvents[] = $called;
         return true;
     });
     $mock->shouldReceive('listen')->andReturnUsing(function ($event, $listener, $priority) {
         //
     });
     Model::setEventDispatcher($mock);
     return $this;
 }
开发者ID:bryanashley,项目名称:framework,代码行数:21,代码来源:MocksApplicationServices.php

示例8: configureEventDispatcher

 /**
  * Configure the dispatcher.
  *
  * @return void
  */
 private function configureEventDispatcher()
 {
     $dispatcher = new Dispatcher(app());
     Model::setEventDispatcher($dispatcher);
     app()->instance(DispatcherContract::class, $dispatcher);
 }
开发者ID:thirteen,项目名称:testbench,代码行数:11,代码来源:MocksApplicationServices.php

示例9: bootEloquent

 /**
  * Prepare the Eloquent ORM for use.
  *
  * @return void
  */
 public function bootEloquent()
 {
     Eloquent\Model::setConnectionResolver($this->manager);
     Eloquent\Model::setEventDispatcher($this->config['events']);
 }
开发者ID:brucewu16899,项目名称:laravel-admin-panel,代码行数:10,代码来源:Capsule.php

示例10: setUpBeforeClass

 /**
  * Bootstrap Eloquent.
  *
  * @return void
  */
 public static function setUpBeforeClass()
 {
     Eloquent::setConnectionResolver(new DatabaseIntegrationTestConnectionResolver());
     Eloquent::setEventDispatcher(new Illuminate\Events\Dispatcher());
 }
开发者ID:dannyweeks,项目名称:eloquent-uuid,代码行数:10,代码来源:EloquentUuidTest.php

示例11: setUpBeforeClass

 /**
  * Bootstrap Eloquent.
  *
  * @return void
  */
 public static function setUpBeforeClass()
 {
     Eloquent::setConnectionResolver(new ConnectionResolver());
     Eloquent::setEventDispatcher(new Dispatcher());
 }
开发者ID:klaude,项目名称:eloquent-preferences,代码行数:10,代码来源:HasPreferenceTest.php


注:本文中的Illuminate\Database\Eloquent\Model::setEventDispatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。