本文整理汇总了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']);
}
示例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')));
}
示例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');
});
}
示例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;
}
示例5: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
Model::setConnectionResolver($this->app['db']);
Model::setEventDispatcher($this->app['events']);
}
示例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);
}
}
示例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;
}
示例8: configureEventDispatcher
/**
* Configure the dispatcher.
*
* @return void
*/
private function configureEventDispatcher()
{
$dispatcher = new Dispatcher(app());
Model::setEventDispatcher($dispatcher);
app()->instance(DispatcherContract::class, $dispatcher);
}
示例9: bootEloquent
/**
* Prepare the Eloquent ORM for use.
*
* @return void
*/
public function bootEloquent()
{
Eloquent\Model::setConnectionResolver($this->manager);
Eloquent\Model::setEventDispatcher($this->config['events']);
}
示例10: setUpBeforeClass
/**
* Bootstrap Eloquent.
*
* @return void
*/
public static function setUpBeforeClass()
{
Eloquent::setConnectionResolver(new DatabaseIntegrationTestConnectionResolver());
Eloquent::setEventDispatcher(new Illuminate\Events\Dispatcher());
}
示例11: setUpBeforeClass
/**
* Bootstrap Eloquent.
*
* @return void
*/
public static function setUpBeforeClass()
{
Eloquent::setConnectionResolver(new ConnectionResolver());
Eloquent::setEventDispatcher(new Dispatcher());
}