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


PHP event函数代码示例

本文整理汇总了PHP中event函数的典型用法代码示例。如果您正苦于以下问题:PHP event函数的具体用法?PHP event怎么用?PHP event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: handle

 /**
  * Save the site to the database, create a config and add that config to nginx.
  *
  * @param $request
  * @param $groupId
  *
  * @return bool
  */
 public function handle($request, $groupId)
 {
     $uuid = $this->site->generateUuid($request['port'] . $request['name']);
     $site = $this->createSite($request, $groupId, $uuid);
     event(new SiteWasCreated($site, $request));
     return [true, null];
 }
开发者ID:NukaCode,项目名称:dasher,代码行数:15,代码来源:Create.php

示例2: newComment

 public function newComment(Bin $bin, Requests\Bins\NewComment $request)
 {
     $comment = $bin->comments()->create(['user_id' => auth()->user()->getAuthIdentifier(), 'message' => $request->input('message')]);
     event(new UserCommentedOnBin($comment));
     session()->flash('success', 'Success! Comment added!');
     return redirect()->to($comment->getCommentUrl());
 }
开发者ID:bbashy,项目名称:LaraBin,代码行数:7,代码来源:CommentController.php

示例3: getMiddleware

 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     $path = parse_url($app->url(), PHP_URL_PATH);
     $errorDir = __DIR__ . '/../../error';
     if (!$app->isInstalled()) {
         $app->register('Flarum\\Install\\InstallServiceProvider');
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.install.routes')]));
         $pipe->pipe($path, new HandleErrors($errorDir, true));
     } elseif ($app->isUpToDate() && !$app->isDownForMaintenance()) {
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\RememberFromCookie'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithSession'));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\SetLocale'));
         event(new ConfigureMiddleware($pipe, $path, $this));
         $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.forum.routes')]));
         $pipe->pipe($path, new HandleErrors($errorDir, $app->inDebugMode()));
     } else {
         $pipe->pipe($path, function () use($errorDir) {
             return new HtmlResponse(file_get_contents($errorDir . '/503.html', 503));
         });
     }
     return $pipe;
 }
开发者ID:Albert221,项目名称:core,代码行数:29,代码来源:Server.php

示例4: play

 /**
  * Increase a song's play count as the currently authenticated user.
  *
  * @param Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function play(Request $request)
 {
     if ($interaction = Interaction::increasePlayCount($request->input('song'), $request->user())) {
         event(new SongStartedPlaying($interaction->song, $interaction->user));
     }
     return response()->json($interaction);
 }
开发者ID:tamdao,项目名称:koel,代码行数:14,代码来源:InteractionController.php

示例5: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Delete the post from database
     $this->post->delete();
     // Fire Event and Listeners
     event(new DeletedPost($this->post));
 }
开发者ID:sonusbeat,项目名称:soundcore,代码行数:12,代码来源:DeletePost.php

示例6: boot

 public static function boot()
 {
     parent::boot();
     static::created(function (EventLog $eventLog) {
         event(new NewEventLog($eventLog));
     });
 }
开发者ID:stickableapp,项目名称:stickable-api,代码行数:7,代码来源:EventLog.php

示例7: register

 /**
  * @param $user_firstname
  * @param $user_lastname
  * @param $email
  * @param $password
  * @param $user_phone
  * @return static
  */
 public static function register($user_firstname, $user_lastname, $email, $password, $user_phone)
 {
     $user = new static(compact('user_firstname', 'user_lastname', 'email', 'password', 'user_phone'));
     //  $user = Event::fire(new UserRegistred($user));
     event(new UserHasRegistred($user, $password));
     return $user;
 }
开发者ID:norja25,项目名称:16._julijs,代码行数:15,代码来源:User.php

示例8: boot

 /**
  * Override the boot method to bind model event listeners.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::saved(function (Deployment $model) {
         event(new ModelChanged($model, 'deployment'));
     });
 }
开发者ID:BlueBayTravel,项目名称:deployer,代码行数:12,代码来源:Deployment.php

示例9: handle

 /**
  * Execute the job.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Apolune\Contracts\Account\Account|null
  */
 public function handle(Request $request)
 {
     $this->account->password = bcrypt($request->get('password'));
     $this->account->save();
     event(new ChangedPassword($this->account));
     return $this->account;
 }
开发者ID:apolune,项目名称:account,代码行数:13,代码来源:ChangePassword.php

示例10: register

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $this->validator($request->all())->validate();
     event(new Registered($user = $this->create($request->all())));
     $this->guard()->login($user);
     return $this->registered($request, $user) ?: redirect($this->redirectPath());
 }
开发者ID:bryanashley,项目名称:framework,代码行数:13,代码来源:RegistersUsers.php

示例11: handle

 /**
  * Perform authentication before a request is executed.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param $grant
  *
  * @return mixed
  * @throws AccessDeniedException
  */
 public function handle($request, Closure $next, $grant = null)
 {
     $route = $this->router->getCurrentRoute();
     /**
      * FOR (Internal API requests)
      * @note GRANT(user) will always be able to access routes that are protected by: GRANT(client)
      *
      * For OAuth grants from password (i.e. Resource Owner: user)
      * @Auth will only check once, because user exists in auth afterwards
      *
      * For OAuth grants from client_credentials (i.e. Resource Owner: client)
      * @Auth will always check, because user is never exists in auth
      */
     if (!$this->auth->check(false)) {
         $this->auth->authenticate($route->getAuthenticationProviders());
         $provider = $this->auth->getProviderUsed();
         /** @var OAuth2 $provider */
         if ($provider instanceof OAuth2) {
             // check oauth grant type
             if (!is_null($grant) && $provider->getResourceOwnerType() !== $grant) {
                 throw new AccessDeniedException();
             }
         }
         // login user through Auth
         $user = $this->auth->getUser();
         if ($user instanceof User) {
             \Auth::login($user);
             event(new UserLoggedInEvent($user));
         }
     }
     return $next($request);
 }
开发者ID:someline,项目名称:starter-framework,代码行数:42,代码来源:ApiAuthMiddleware.php

示例12: save

 public static function save($data)
 {
     $code = (new Parcels())->getNextCode();
     $description = $data[0];
     event(new ActivityLog(auth()->user()->username . ' created a parcel ' . $description . ' with the code ' . $code . ' successfully via CSV Upload.'));
     return auth()->user()->parcels()->create(['weight' => 1, 'town_id' => 1, 'status_id' => 1, 'description' => $description, 'code' => $code, 'destination' => $data[1]]);
 }
开发者ID:richardkeep,项目名称:tracker,代码行数:7,代码来源:CSVUpload.php

示例13: handle

 /**
  * Handle the subscribe customer command.
  *
  * @param \CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand $command
  *
  * @return void
  */
 public function handle(VerifySubscriberCommand $command)
 {
     $subscriber = $command->subscriber;
     $subscriber->verified_at = Carbon::now();
     $subscriber->save();
     event(new SubscriberHasVerifiedEvent($subscriber));
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:14,代码来源:VerifySubscriberCommandHandler.php

示例14: handle

 /**
  * @param UploadAvatar $command
  * @return \Flarum\Core\Users\User
  * @throws \Flarum\Core\Exceptions\PermissionDeniedException
  */
 public function handle(UploadAvatar $command)
 {
     $actor = $command->actor;
     $user = $this->users->findOrFail($command->userId);
     // Make sure the current user is allowed to edit the user profile.
     // This will let admins and the user themselves pass through, and
     // throw an exception otherwise.
     if ($actor->id !== $user->id) {
         $user->assertCan($actor, 'edit');
     }
     $tmpFile = tempnam(sys_get_temp_dir(), 'avatar');
     $command->file->moveTo($tmpFile);
     $manager = new ImageManager();
     $manager->make($tmpFile)->fit(100, 100)->save();
     event(new AvatarWillBeSaved($user, $actor, $tmpFile));
     $mount = new MountManager(['source' => new Filesystem(new Local(pathinfo($tmpFile, PATHINFO_DIRNAME))), 'target' => $this->uploadDir]);
     if ($user->avatar_path && $mount->has($file = "target://{$user->avatar_path}")) {
         $mount->delete($file);
     }
     $uploadName = Str::lower(Str::quickRandom()) . '.jpg';
     $user->changeAvatarPath($uploadName);
     $mount->move("source://" . pathinfo($tmpFile, PATHINFO_BASENAME), "target://{$uploadName}");
     $user->save();
     $this->dispatchEventsFor($user);
     return $user;
 }
开发者ID:redstarxz,项目名称:flarumone,代码行数:31,代码来源:UploadAvatarHandler.php

示例15: getMiddleware

 /**
  * {@inheritdoc}
  */
 protected function getMiddleware(Application $app)
 {
     $pipe = new MiddlewarePipe();
     $path = config('hyn.laravel-flarum.paths.api');
     //        if ($app->isInstalled() && $app->isUpToDate()) {
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\ParseJsonBody'));
     $pipe->pipe($path, $app->make('Flarum\\Api\\Middleware\\FakeHttpMethods'));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\StartSession'));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\RememberFromCookie'));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithSession'));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\AuthenticateWithHeader'));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\SetLocale'));
     event(new ConfigureMiddleware($pipe, $path, $this));
     $pipe->pipe($path, $app->make('Flarum\\Http\\Middleware\\DispatchRoute', ['routes' => $app->make('flarum.api.routes')]));
     $pipe->pipe($path, $app->make('Flarum\\Api\\Middleware\\HandleErrors'));
     //        } else {
     //            $pipe->pipe($path, function () {
     //                $document = new Document;
     //                $document->setErrors([
     //                    [
     //                        'code' => 503,
     //                        'title' => 'Service Unavailable'
     //                    ]
     //                ]);
     //
     //                return new JsonApiResponse($document, 503);
     //            });
     //        }
     return $pipe;
 }
开发者ID:hyn,项目名称:laravel-flarum,代码行数:33,代码来源:Server.php


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