本文整理汇总了PHP中Illuminate\Contracts\Events\Dispatcher::fire方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::fire方法的具体用法?PHP Dispatcher::fire怎么用?PHP Dispatcher::fire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Events\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::fire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach ($this->permissionsToRegister() as $name => $description) {
$this->permissionRepository->firstOrRegister(['name' => $name], ['description' => $description]);
}
$this->events->fire(new PermissionsModified());
}
示例2: dispatchEventsFor
/**
* Dispatch all events for an entity.
*
* @param object $entity
* @param User $actor
*/
public function dispatchEventsFor($entity, User $actor = null)
{
foreach ($entity->releaseEvents() as $event) {
$event->actor = $actor;
$this->events->fire($event);
}
}
示例3: handle
/**
* handle group creation logic
*
* @param Validator $validator
* @param Dispatcher $dispatcher
* @param Group $group
* @return CommandResult
*/
public function handle(Validator $validator, Dispatcher $dispatcher, Group $group)
{
// check user permission
if (!$this->disablePermissionChecking) {
if (!$this->user->hasAnyPermission(['user.manage'])) {
return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
}
}
// validate data
$validationResult = $validator->make(array('name' => $this->name, 'permissions' => $this->permissions), Group::$rules);
if ($validationResult->fails()) {
return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
}
// prepare data to be store
$groupToBeCreated = array('name' => $this->name, 'permissions' => $this->transform($this->permissions));
// fire creating
$dispatcher->fire('group.creating', array($groupToBeCreated));
// create
$createdGroup = $group->create($groupToBeCreated);
if (!$createdGroup) {
return new CommandResult(false, "Failed to create user.", null, 400);
}
// fire created user
$dispatcher->fire('group.created', array($createdGroup));
// return response
return new CommandResult(true, "Group successfully created.", $createdGroup, 201);
}
示例4: makeValidator
/**
* Make a new validator instance for this model.
*
* @param array $attributes
* @return \Illuminate\Validation\Validator
*/
protected function makeValidator(array $attributes)
{
$rules = array_only($this->getRules(), array_keys($attributes));
$validator = $this->validator->make($attributes, $rules, $this->getMessages());
$this->events->fire(new ConfigureValidator($this, $validator));
return $validator;
}
示例5: handle
/**
* handle user deletion logic
*
* @param User $user
* @param Group $group
* @param Dispatcher $dispatcher
* @param Repository $config
* @return CommandResult
*/
public function handle(User $user, Group $group, Dispatcher $dispatcher, Repository $config)
{
// check user permission
if (!$this->disablePermissionChecking) {
if (!$this->user->hasAnyPermission(['user.delete'])) {
return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
}
if ($this->user->id == $this->id) {
return new CommandResult(false, "Cannot delete self.", null, 400);
}
}
// prepare the user model
$user = $this->createUserModel($user, $config);
// find the user
if (!($userToBeDelete = $user->find($this->id))) {
return new CommandResult(false, "User not found.", null, 404);
}
// fire deleting
$dispatcher->fire('user.deleting', array($this->args));
// begin deletion
$userToBeDelete->groups()->detach();
$userToBeDelete->delete();
// fire deleted
$dispatcher->fire('user.deleted', array($userToBeDelete));
// all good
return new CommandResult(true, "User successfully deleted.", null, 200);
}
示例6: handle
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->events->fire('command.publishvendors', $this);
$this->events->fire('command.runmigrations', $this);
$this->events->fire('command.updatecache', $this);
$this->events->fire('command.extrastuff', $this);
}
示例7: handle
/**
* Handle the command.
*
* @param CreateIncomeServiceCommand $command
* @return void
*/
public function handle(CreateIncomeServiceCommand $command)
{
$input = ['service_id' => $command->serviceId, 'service_date' => $command->serviceDate, 'created_by' => $command->userId, 'role_access' => $command->roleAccess, 'status' => $command->status];
$incomeService = $this->incomeService->save($input);
$this->dispatcher->fire(new IncomeServiceWasCreated($incomeService->id));
return $incomeService;
}
示例8: handle
/**
* Execute the command.
*
* @param ContentType $contentType
* @param Validator $validator
* @param Dispatcher $dispatcher
* @return CommandResult
*/
public function handle(ContentType $contentType, Validator $validator, Dispatcher $dispatcher)
{
// validate authorization
if (!$this->disablePermissionChecking) {
if (!$this->user->hasAnyPermission(['contentBuilder.manage'])) {
return new CommandResult(false, CommandResult::$responseForbiddenMessage, null, 403);
}
}
// validate data
$validationResult = $validator->make(array('taxonomy' => $this->taxonomy, 'content_type_id' => $this->contentTypeId), ContentTypeTaxonomy::$rules);
if ($validationResult->fails()) {
return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
}
// prepare the data to be stored
$taxonomyToBeCreated = array('taxonomy' => $this->taxonomy, 'description' => $this->description);
// fire creating event
$dispatcher->fire('contentTypeTaxonomy.creating', array($taxonomyToBeCreated));
// store
try {
$contentType = $contentType->findOrFail($this->contentTypeId);
$createdContentTypeTaxonomy = $contentType->taxonomies()->create($taxonomyToBeCreated);
} catch (\Exception $e) {
return new CommandResult(false, "Invalid Content Type.", null, 400);
}
// fire creating event
$dispatcher->fire('contentTypeTaxonomy.created', array($createdContentTypeTaxonomy));
// return
return new CommandResult(true, "Content type taxonomy successfully created.", $createdContentTypeTaxonomy, 201);
}
示例9: handle
public function handle(Navigation $navigation, Factory $validator, Dispatcher $dispatcher)
{
// check if user has permission
if (!$this->disablePermissionChecking) {
if (!$this->user->hasAnyPermission(['navigationBuilder.manage'])) {
return new CommandResult(false, "Not enough permission.", null, 403);
}
}
// validate data
$validationResult = $validator->make(array('name' => $this->name, 'data' => $this->data), Navigation::$rules);
if ($validationResult->fails()) {
return new CommandResult(false, $validationResult->getMessageBag()->first(), null, 400);
}
if (!($nav = $navigation->find($this->id))) {
return new CommandResult(false, 'Navigation does not exist.', null, 400);
}
// fire before create event
$dispatcher->fire('navigationBuilder.updating', array($nav, $this->args));
$nav->name = $this->name;
$nav->data = $this->data;
$nav->save();
// fire after create
$dispatcher->fire('navigationBuilder.updated', array($nav, $this->args));
// all good
return new CommandResult(true, "Navigation successfully updated.", $nav, 200);
}
示例10: render
/**
* {@inheritdoc}
*/
public function render(Request $request)
{
$view = $this->getView($request);
$this->events->fire(new ConfigureClientView($this, $view, $request));
$this->events->fire(new ConfigureWebApp($this, $view, $request));
return $view->render($request);
}
示例11: run
/**
* リマインダー通知ビジネスロジック
*
* @param string $message
*/
public function run($message)
{
// イベントにメッセージを設定
$this->event->message = $message;
// イベント発行
$this->dispacher->fire($this->event);
}
示例12: handle
/**
* @param Navigation $navigation
* @param Dispatcher $dispatcher
* @return CommandResult
*/
public function handle(Navigation $navigation, Dispatcher $dispatcher)
{
// check if user has permission
if (!$this->disablePermissionChecking) {
if (!$this->user->hasAnyPermission(['navigationBuilder.manage'])) {
return new CommandResult(false, "Not enough permission.", null, 403);
}
}
// fire before create event
$dispatcher->fire('navigationBuilder.beforeQuery', array($this->args));
if ($this->id && $this->id != '') {
if (!($res = $navigation->with(array())->find($this->id))) {
return new CommandResult(false, "Navigation does not exist.", null, 404);
}
} else {
if ($this->paginated) {
$res = $navigation->with(array())->paginate($this->perPage);
} else {
$res = $navigation->all();
}
}
// fire after create
$dispatcher->fire('navigationBuilder.afterQuery', array($this->args));
// all good
return new CommandResult(true, "List custom navigation command successful.", $res, 200);
}
示例13: handle
/**
* Handle the command.
*
* @param DeleteIncomeServiceMemberFundTotal $command
* @return void
*/
public function handle(DeleteIncomeServiceMemberFundTotal $command)
{
$memberFund = $this->memberFund->getByIdAndMemberId($command->incomeServiceId, $command->memberId);
$this->memberFund->deleteTotal($memberFund->id);
$incomeService = $this->dispatcher->fire(new IncomeServiceMemberFundTotalWasDeleted($command->incomeServiceId, $command->memberId, $memberFund->tithes, $memberFund->offering, $memberFund->others, $memberFund->total));
return ['memberFundTotal' => $memberFund, 'fundTotal' => $incomeService[1]];
}
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:13,代码来源:DeleteIncomeServiceMemberFundTotalHandler.php
示例14: fireEvent
/**
* Fire off an event.
*
* @param string $name
* @param mixed $payload
* @return mixed
*/
protected function fireEvent($name, $payload = null)
{
if (!isset(static::$dispatcher)) {
$this->initEventDispatcher();
}
static::$dispatcher->fire($name, $payload);
}
示例15: execute
/**
* @param CouchbaseViewQuery $viewQuery
* @param bool $jsonAsArray
*
* @return mixed
*/
public function execute(CouchbaseViewQuery $viewQuery, $jsonAsArray = false)
{
if (isset($this->dispatcher)) {
$this->dispatcher->fire(new ViewQuerying($viewQuery));
}
return $this->bucket->query($viewQuery, $jsonAsArray);
}