• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: handle

 /**
  * Handle the creation of the Field in the Database
  * @param $command
  * @return static
  */
 public function handle($command)
 {
     $command->namespace = EntityModel::find($command->entity_id)->namespace;
     $field = FieldModel::create((array) $command);
     event(new FieldWasCreated($field));
     return $field;
 }
开发者ID:hechoenlaravel,项目名称:jarvis-foundation,代码行数:12,代码来源:CreateFieldCommandHandler.php


示例17: handle

 /**
  * @param EditTag $command
  * @return \Flarum\Tags\Tag
  * @throws \Flarum\Core\Exception\PermissionDeniedException
  */
 public function handle(EditTag $command)
 {
     $actor = $command->actor;
     $data = $command->data;
     $tag = $this->tags->findOrFail($command->tagId, $actor);
     $this->assertCan($actor, 'edit', $tag);
     $attributes = array_get($data, 'attributes', []);
     if (isset($attributes['name'])) {
         $tag->name = $attributes['name'];
     }
     if (isset($attributes['slug'])) {
         $tag->slug = $attributes['slug'];
     }
     if (isset($attributes['description'])) {
         $tag->description = $attributes['description'];
     }
     if (isset($attributes['color'])) {
         $tag->color = $attributes['color'];
     }
     if (isset($attributes['isHidden'])) {
         $tag->is_hidden = (bool) $attributes['isHidden'];
     }
     if (isset($attributes['isRestricted'])) {
         $tag->is_restricted = (bool) $attributes['isRestricted'];
     }
     event(new TagWillBeSaved($tag, $actor, $data));
     $this->validator->assertValid($tag->getDirty());
     $tag->save();
     return $tag;
 }
开发者ID:flarum,项目名称:flarum-ext-tags,代码行数:35,代码来源:EditTagHandler.php


示例18: addProductDescription

 /**
  * Creates new product description with given options.
  *
  * @param array  $options
  *
  * @return Description
  * @throws ModelNotFoundException
  */
 public function addProductDescription($productId, $options = [])
 {
     $product = $this->getProduct($productId);
     $description = $product->descriptions()->save(new Description(['body' => $options['body']]));
     event(new Events\DescriptionWasCreated($description));
     return $description->fresh();
 }
开发者ID:stevenmaguire,项目名称:bydreco-service,代码行数:15,代码来源:ProductService.php


示例19: handle

 /**
  * Handle the update component group command.
  *
  * @param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand $command
  *
  * @return \CachetHQ\Cachet\Models\ComponentGroup
  */
 public function handle(UpdateComponentGroupCommand $command)
 {
     $group = $command->group;
     $group->update($this->filter($command));
     event(new ComponentGroupWasUpdatedEvent($group));
     return $group;
 }
开发者ID:mohitsethi,项目名称:Cachet,代码行数:14,代码来源:UpdateComponentGroupCommandHandler.php


示例20: handle

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP event_access_tool函数代码示例发布时间:2022-05-15
下一篇:
PHP eve函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap