本文整理汇总了PHP中Illuminate\Contracts\Bus\Dispatcher类的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher类的具体用法?PHP Dispatcher怎么用?PHP Dispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dispatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: store
/**
* @param Requests\SignUpRequest $request
* @param CommandDispatcher $commandDispatcher
*
* @return
*/
public function store(Requests\SignUpRequest $request, CommandDispatcher $commandDispatcher)
{
$commandDispatcher->dispatchFrom(RegisterUser::class, $request);
\Auth::login(User::where('username', $request['username'])->first());
Flash::overlay('Welcome!!');
return Redirect::home();
}
开发者ID:sabahtalateh,项目名称:laracast,代码行数:13,代码来源:RegistrationController.php
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle(Dispatcher $dispatcher)
{
$id = \App\Domain\ValueObject\UUID::make();
$title = new \App\Domain\ValueObject\String\NonBlank($this->argument("title"));
$author = new \App\Domain\ValueObject\String\NonBlank($this->argument("github_username"));
$post = \App\Domain\ValueObject\Post::make($id, $title, $author);
$dispatcher->dispatch(new \App\Commands\CreatePost($post));
$this->info("Post {$id} created.");
}
开发者ID:railto,项目名称:phpdublin.com,代码行数:14,代码来源:CreatePost.php
示例3: boot
public function boot(Dispatcher $dispatcher)
{
$dispatcher->mapUsing(function ($command) {
$command = str_replace('Commands\\', 'Commands\\Handlers\\', get_class($command));
return trim($command, '\\') . 'Handler@handle';
});
$this->registerMiddleware($this->app['router']);
$this->registerModuleResourceNamespaces();
$this->setLocalesConfigurations();
}
开发者ID:mikemand,项目名称:Core,代码行数:10,代码来源:CoreServiceProvider.php
示例4: authenticated
/**
* Respond with JavaScript to inform the Flarum app about the user's
* authentication status.
*
* An array of identification attributes must be passed as the first
* argument. These are checked against existing user accounts; if a match is
* found, then the user is authenticated and logged into that account via
* cookie. The Flarum app will then simply refresh the page.
*
* If no matching account is found, then an AuthToken will be generated to
* store the identification attributes. This token, along with an optional
* array of suggestions, will be passed into the Flarum app's sign up modal.
* This results in the user not having to choose a password. When they
* complete their registration, the identification attributes will be
* set on their new user account.
*
* @param array $identification
* @param array $suggestions
* @return HtmlResponse
*/
protected function authenticated(array $identification, array $suggestions = [])
{
$user = User::where($identification)->first();
// If a user with these attributes already exists, then we will log them
// in by generating an access token. Otherwise, we will generate a
// unique token for these attributes and add it to the response, along
// with the suggested account information.
if ($user) {
$accessToken = $this->bus->dispatch(new GenerateAccessToken($user->id));
$payload = ['authenticated' => true];
} else {
$token = AuthToken::generate($identification);
$token->save();
$payload = array_merge($identification, $suggestions, ['token' => $token->id]);
}
$content = sprintf('<script>
window.opener.app.authenticationComplete(%s);
window.close();
</script>', json_encode($payload));
$response = new HtmlResponse($content);
if (isset($accessToken)) {
// Extend the token's expiry to 2 weeks so that we can set a
// remember cookie
$accessToken::unguard();
$accessToken->update(['expires_at' => new DateTime('+2 weeks')]);
$response = $this->withRememberCookie($response, $accessToken->id);
}
return $response;
}
开发者ID:redstarxz,项目名称:flarumone,代码行数:49,代码来源:AuthenticatorTrait.php
示例5: handle
/**
* @param StartDiscussion $command
* @return mixed
* @throws Exception
*/
public function handle(StartDiscussion $command)
{
$actor = $command->actor;
$data = $command->data;
$this->assertCan($actor, 'startDiscussion');
// Create a new Discussion entity, persist it, and dispatch domain
// events. Before persistence, though, fire an event to give plugins
// an opportunity to alter the discussion entity based on data in the
// command they may have passed through in the controller.
$discussion = Discussion::start(array_get($data, 'attributes.title'), $actor);
$this->events->fire(new DiscussionWillBeSaved($discussion, $actor, $data));
$this->validator->assertValid($discussion->getAttributes());
$discussion->save();
// Now that the discussion has been created, we can add the first post.
// We will do this by running the PostReply command.
try {
$post = $this->bus->dispatch(new PostReply($discussion->id, $actor, $data));
} catch (Exception $e) {
$discussion->delete();
throw $e;
}
// Before we dispatch events, refresh our discussion instance's
// attributes as posting the reply will have changed some of them (e.g.
// last_time.)
$discussion->setRawAttributes($post->discussion->getAttributes(), true);
$discussion->setStartPost($post);
$discussion->setLastPost($post);
$this->dispatchEventsFor($discussion, $actor);
$discussion->save();
return $discussion;
}
开发者ID:sijad,项目名称:core,代码行数:36,代码来源:StartDiscussionHandler.php
示例6: failed
/**
* Call the failed method on the job instance.
*
* @param array $data
* @return void
*/
public function failed(array $data)
{
$handler = $this->dispatcher->resolveHandler($command = unserialize($data['command']));
if (method_exists($handler, 'failed')) {
call_user_func([$handler, 'failed'], $command);
}
}
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:13,代码来源:CallQueuedHandler.php
示例7: data
/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$id = array_get($request->getQueryParams(), 'id');
$actor = $request->getAttribute('actor');
$data = array_get($request->getParsedBody(), 'data');
return $this->bus->dispatch(new EditLink($id, $actor, $data));
}
开发者ID:sijad,项目名称:flarum-ext-links,代码行数:10,代码来源:UpdateLinkController.php
示例8: delete
/**
* {@inheritdoc}
*/
protected function delete(Request $request)
{
$id = $request->get('id');
$actor = $request->actor;
$input = $request->all();
$this->bus->dispatch(new DeleteDiscussion($id, $actor, $input));
}
开发者ID:redstarxz,项目名称:flarumone,代码行数:10,代码来源:DeleteAction.php
示例9: delete
/**
* {@inheritdoc}
*/
protected function delete(ServerRequestInterface $request)
{
$id = array_get($request->getQueryParams(), 'id');
$actor = $request->getAttribute('actor');
$input = $request->getParsedBody();
$this->bus->dispatch(new DeleteDiscussion($id, $actor, $input));
}
开发者ID:flarum,项目名称:core,代码行数:10,代码来源:DeleteDiscussionController.php
示例10: data
/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$id = array_get($request->getQueryParams(), 'id');
$actor = $request->getAttribute('actor');
$file = array_get($request->getUploadedFiles(), 'avatar');
return $this->bus->dispatch(new UploadAvatar($id, $file, $actor));
}
开发者ID:clops,项目名称:core,代码行数:10,代码来源:UploadAvatarController.php
示例11: destroy
/**
* Unfallow a User
*
* @param $userIdToUnfallow
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($userIdToUnfallow, Request $request)
{
$request->replace(array_add($request->all(), 'userId', Auth::id()));
$this->dispatcher->dispatchFrom(UnfallowUser::class, $request);
Flash::success('You have now unfallowed this user');
return Redirect::back();
}
开发者ID:sabahtalateh,项目名称:laracast,代码行数:14,代码来源:FallowersController.php
示例12: data
/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = $request->getAttribute('actor');
$discussionId = array_get($request->getQueryParams(), 'id');
$data = array_get($request->getParsedBody(), 'data', []);
$discussion = $this->bus->dispatch(new EditDiscussion($discussionId, $actor, $data));
// TODO: Refactor the ReadDiscussion (state) command into EditDiscussion?
// That's what extensions will do anyway.
if ($readNumber = array_get($data, 'attributes.readNumber')) {
$state = $this->bus->dispatch(new ReadDiscussion($discussionId, $actor, $readNumber));
$discussion = $state->discussion;
}
if ($posts = $discussion->getModifiedPosts()) {
$discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
foreach ($discussionPosts as &$id) {
foreach ($posts as $post) {
if ($id == $post->id) {
$id = $post;
$post->discussion = $post->discussion_id;
$post->user = $post->user_id;
}
}
}
$discussion->setRelation('posts', $discussionPosts);
$this->include = array_merge($this->include, ['posts', 'posts.discussion', 'posts.user']);
}
return $discussion;
}
开发者ID:RudolfFussek,项目名称:core,代码行数:31,代码来源:UpdateDiscussionController.php
示例13: data
/**
* Get the data to be serialized and assigned to the response document.
*
* @param ServerRequestInterface $request
* @param Document $document
* @return mixed
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$postId = array_get($request->getQueryParams(), 'post');
$actor = $request->getAttribute('actor');
$file = array_get($request->getParsedBody(), 'image');
return $this->bus->dispatch(new UploadImage($postId, base64_decode($file), $actor));
}
开发者ID:Flarum-Chinese,项目名称:flarum-ext-image-upload,代码行数:14,代码来源:UploadImageController.php
示例14: data
/**
* Get the data to be serialized and assigned to the response document.
*
* @param ServerRequestInterface $request
* @param Document $document
* @return mixed
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$title = Arr::get($request->getParsedBody(), 'title');
$start_post_id = Arr::get($request->getParsedBody(), 'start_post_id');
$end_post_id = Arr::get($request->getParsedBody(), 'end_post_id');
$actor = $request->getAttribute('actor');
return $this->bus->dispatch(new SplitDiscussion($title, $start_post_id, $end_post_id, $actor));
}
开发者ID:flagrow,项目名称:flarum-ext-split,代码行数:15,代码来源:SplitController.php
示例15: call
/**
* Handle the queued job.
*
* @param \Illuminate\Contracts\Queue\Job $job
* @param array $data
* @return void
*/
public function call(Job $job, array $data)
{
$command = $this->setJobInstanceIfNecessary($job, unserialize($data['command']));
$this->dispatcher->dispatchNow($command);
if (!$job->isDeletedOrReleased()) {
$job->delete();
}
}
开发者ID:janhartigan,项目名称:framework,代码行数:15,代码来源:CallQueuedHandler.php
示例16: execute
public function execute($files)
{
if (empty($this->dir)) {
throw new UploadSettingsException();
}
$this->dispatcher->pipeThrough(['EscapeWork\\LaravelSteroids\\Upload\\NormalizeJob', 'EscapeWork\\LaravelSteroids\\Upload\\ValidateJob', 'EscapeWork\\LaravelSteroids\\Upload\\MoveJob']);
$dispatched = $this->dispatch(new UploadJob($files, $this->dir));
$this->dispatcher->pipeThrough([]);
return $dispatched;
}
开发者ID:ngangchill,项目名称:LaravelSteroids,代码行数:10,代码来源:Upload.php
示例17: handle
/**
* @param Request $request
* @param array $routeParams
* @return \Psr\Http\Message\ResponseInterface
*/
public function handle(Request $request, array $routeParams = [])
{
try {
$token = array_get($routeParams, 'token');
$user = $this->bus->dispatch(new ConfirmEmail($token));
} catch (InvalidConfirmationTokenException $e) {
return new HtmlResponse('Invalid confirmation token');
}
$token = $this->bus->dispatch(new GenerateAccessToken($user->id));
return $this->withRememberCookie($this->redirectTo('/'), $token->id);
}
开发者ID:redstarxz,项目名称:flarumone,代码行数:16,代码来源:ConfirmEmailAction.php
示例18: handle
/**
* @param Request $request
* @return \Psr\Http\Message\ResponseInterface
*/
public function handle(Request $request)
{
try {
$token = array_get($request->getQueryParams(), 'token');
$user = $this->bus->dispatch(new ConfirmEmail($token));
} catch (InvalidConfirmationTokenException $e) {
return new HtmlResponse('Invalid confirmation token');
}
$token = $this->bus->dispatch(new GenerateAccessToken($user->id));
return $this->withRememberCookie(new RedirectResponse($this->app->url()), $token->id);
}
开发者ID:ygbhf,项目名称:flarum-full,代码行数:15,代码来源:ConfirmEmailController.php
示例19: create
/**
* Create a discussion according to input from the API request.
*
* @param JsonApiRequest $request
* @return \Flarum\Core\Discussions\Discussion
*/
protected function create(JsonApiRequest $request)
{
$actor = $request->actor;
$discussion = $this->bus->dispatch(new StartDiscussion($actor, $request->get('data')));
// After creating the discussion, we assume that the user has seen all
// of the posts in the discussion; thus, we will mark the discussion
// as read if they are logged in.
if ($actor->exists) {
$this->bus->dispatch(new ReadDiscussion($discussion->id, $actor, 1));
}
return $discussion;
}
开发者ID:redstarxz,项目名称:flarumone,代码行数:18,代码来源:CreateAction.php
示例20: data
/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = $request->getAttribute('actor');
$discussion = $this->bus->dispatch(new StartDiscussion($actor, array_get($request->getParsedBody(), 'data')));
// After creating the discussion, we assume that the user has seen all
// of the posts in the discussion; thus, we will mark the discussion
// as read if they are logged in.
if ($actor->exists) {
$this->bus->dispatch(new ReadDiscussion($discussion->id, $actor, 1));
}
return $discussion;
}
开发者ID:ygbhf,项目名称:flarum-full,代码行数:15,代码来源:CreateDiscussionController.php
注:本文中的Illuminate\Contracts\Bus\Dispatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论