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


PHP Events\Dispatcher类代码示例

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


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

示例1: listen

 public function listen(Dispatcher $events)
 {
     $events->subscribe('S12g\\ImageAttachments\\Listeners\\AddClientAssets');
     $events->listen(RegisterApiRoutes::class, function (RegisterApiRoutes $event) {
         $event->post('/s12g/image_attachments', 's12g.imageattachments.upload', 'S12g\\ImageAttachments\\UploadAction');
     });
 }
开发者ID:stoensin,项目名称:flarumone,代码行数:7,代码来源:Extension.php

示例2: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  */
 public function subscribe($events)
 {
     $events->listen(\App\Events\Frontend\Auth\UserLoggedIn::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onLoggedIn');
     $events->listen(\App\Events\Frontend\Auth\UserLoggedOut::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onLoggedOut');
     $events->listen(\App\Events\Frontend\Auth\UserRegistered::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onRegistered');
     $events->listen(\App\Events\Frontend\Auth\UserConfirmed::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onConfirmed');
 }
开发者ID:blomdahldaniel,项目名称:laravel-5-boilerplate,代码行数:12,代码来源:UserEventListener.php

示例3: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Events\Dispatcher $events
  * @return void
  */
 public function subscribe($events)
 {
     Recipe::observe('App\\Observers\\RecipeModelObserver');
     $events->listen('App\\Events\\Recipe\\RecipeCreated', 'App\\Listeners\\RecipeEventListener@onRecipeCreated');
     $events->listen('App\\Events\\Recipe\\RecipeUpdated', 'App\\Listeners\\RecipeEventListener@onRecipeUpdated');
     $events->listen('App\\Events\\Recipe\\RecipeDeleted', 'App\\Listeners\\RecipeEventListener@onRecipeDeleted');
 }
开发者ID:artissant,项目名称:stock,代码行数:13,代码来源:RecipeEventListener.php

示例4: subscribe

 /**
  * Listen to the events.
  *
  * @param  \Illuminate\Events\Dispatcher  $dispatcher
  * @return void
  */
 public function subscribe(Dispatcher $dispatcher)
 {
     $dispatcher->listen('cartalyst.cart.added', __CLASS__ . '@onItemAdded');
     $dispatcher->listen('cartalyst.cart.updated', __CLASS__ . '@onItemUpdated');
     $dispatcher->listen('cartalyst.cart.removed', __CLASS__ . '@onItemRemoved');
     $dispatcher->listen('cartalyst.cart.cleared', __CLASS__ . '@onCartCleared');
 }
开发者ID:Denniskevin,项目名称:demo-cart,代码行数:13,代码来源:CartEventHandler.php

示例5: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  $events
  * @return array
  */
 public function subscribe(Dispatcher $events)
 {
     $class = get_called_class();
     foreach ($this->getEvents() as $event) {
         $method = $this->getMethodName($event);
         if (!method_exists($this, $method)) {
             continue;
         }
         $events->listen($event, $class . '@' . $method);
     }
     // --- Alternative (später Benchmark machen und dann entscheiden ---
     //		$methods = $this->cache(md5($class.'events'), function(){
     //			return array_filter(get_class_methods($this), function($method){
     //				return preg_match("/^on/u", $method) ? $method : null;
     //			});
     //		});
     //
     //		// Get all Event Handling Methods
     //
     //		$qvents = $this->getQualifiedEvents();
     //
     //		foreach($methods as $method)
     //		{
     //			if ( ! array_key_exists($method, $qvents) ) continue;
     //
     //			$events->listen($qvents[$method], $class . '@' . $method);
     //		}
     // --- Second Alternative ---
     //		foreach( $this->getQualifiedEvents() as $method => $event )
     //		{
     //			if ( ! method_exists($this, $method) ) continue;
     //
     //			$events->listen($event, $class . '@' . $method);
     //		}
 }
开发者ID:wegnermedia,项目名称:melon,代码行数:41,代码来源:EventSubscriber.php

示例6: postInstall

 public function postInstall(Request $request, Installer $installer, Dispatcher $dispatcher)
 {
     $output = new BufferedOutput();
     $installer->setFieldValues($request->all());
     $versions = $installer->getVersions();
     foreach ($versions as $version) {
         $tasks = $installer->getTasksForVersion($version);
         foreach ($tasks as $task) {
             $output->writeln('<span class="text-info">Running ' . $task->getTitle() . ' Task...</span>');
             try {
                 $task->setInput($installer->getFieldValues());
                 $task->run($output);
             } catch (TaskRunException $e) {
                 $output->writeln('<span class="text-danger">' . $e->getMessage() . '</span>');
                 return new JsonResponse(['output' => $output, 'status' => 'error'], 200);
             }
             $output->writeln('<span class="text-info">Task ' . $task->getTitle() . ' Completed!</span>');
         }
     }
     $dispatcher->fire(new AfterInstallEvent($installer, $output));
     $installer->saveCompleted();
     $output->writeln('<span class="text-success">Installation Completed!</span>');
     $output = array_filter(explode("\n", $output->fetch()));
     return new JsonResponse(['output' => $output, 'status' => 'success'], 200);
 }
开发者ID:illuminate3,项目名称:larastaller,代码行数:25,代码来源:InstallController.php

示例7: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  * @return array
  */
 public function subscribe($events)
 {
     $events->listen('auth.logout', 'App\\Handlers\\Events\\CartHandler@customer_logout');
     $events->listen('auth.login', 'App\\Handlers\\Events\\CartHandler@customer_login');
     $events->listen('App\\Events\\Cart\\Shipment\\CollectMethods', 'App\\Handlers\\Events\\CartHandler@shipment_methods');
     $events->listen('App\\Events\\Cart\\Payment\\CollectMethods', 'App\\Handlers\\Events\\CartHandler@payment_methods');
 }
开发者ID:BryceHappy,项目名称:lavender,代码行数:13,代码来源:CartHandler.php

示例8: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Events\Dispatcher $events
  * @return void
  */
 public function subscribe($events)
 {
     Ingredient::observe('App\\Observers\\IngredientModelObserver');
     $events->listen('App\\Events\\Ingredient\\IngredientCreated', 'App\\Listeners\\IngredientEventListener@onIngredientCreated');
     $events->listen('App\\Events\\Ingredient\\IngredientUpdated', 'App\\Listeners\\IngredientEventListener@onIngredientUpdated');
     $events->listen('App\\Events\\Ingredient\\IngredientDeleted', 'App\\Listeners\\IngredientEventListener@onIngredientDeleted');
 }
开发者ID:artissant,项目名称:stock,代码行数:13,代码来源:IngredientEventListener.php

示例9: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher $events
  */
 public function subscribe($events)
 {
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserCreatedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserCreatedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserUpdatedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserUpdatedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserDeletedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserDeletedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\NewUserRegisteredEvent', 'cms\\App\\Listeners\\UsersEventsListener@newUserRegisteredEvent');
 }
开发者ID:cvepdb-cms,项目名称:module-users,代码行数:12,代码来源:UsersEventsListener.php

示例10: handle

 /**
  * Handle the command.
  *
  * @param InviteModel $invites
  * @param Request $request
  * @param Dispatcher $events
  * @return array
  */
 public function handle(InviteModel $invites, Request $request, Dispatcher $events)
 {
     $user['ip_address'] = $request->ip();
     // Slack configurations
     $slackTeam = config('anomaly.extension.slack_inviter::slack.team');
     $slackToken = config('anomaly.extension.slack_inviter::slack.token');
     $slackChannels = config('anomaly.extension.slack_inviter::slack.channels');
     if (!$slackToken) {
         throw new \Exception("Slack API has not been configured. Missing 'anomaly.extension.slack_inviter::slack.auth_token'");
     }
     $slackInviteUrl = 'https://' . $slackTeam . '.slack.com/api/users.admin.invite?t=' . time();
     $fields = array('email' => $user['email'] = $this->builder->getFormValue('email'), 'first_name' => urlencode($user['name'] = $this->builder->getFormValue('name')), 'channels' => $slackChannels, 'token' => $slackToken, 'set_active' => true, '_attempts' => '1');
     // Open the connection.
     $ch = curl_init();
     // set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $slackInviteUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
     // Execute the request.
     $reply = json_decode(curl_exec($ch), true);
     if ($reply['ok'] == false) {
         $user['error'] = $reply['error'];
     } else {
         $user['successful'] = true;
     }
     // Close the connection.
     curl_close($ch);
     $events->fire(new SlackInviteWasSent($invites->create($user)));
     return $reply;
 }
开发者ID:anomalylabs,项目名称:slack_inviter-extension,代码行数:39,代码来源:SendInvite.php

示例11: __construct

 /**
  * @param CommentForm  $commentForm
  * @param Dispatcher   $events
  */
 public function __construct(CommentForm $commentForm, Dispatcher $events)
 {
     $this->beforeFilter('auth', ['only' => ['update', 'trash', 'approve']]);
     $this->commentForm = $commentForm;
     $events->subscribe('FIIP\\Comments\\CommentEventHandler');
     Comments::setDispatcher($events);
 }
开发者ID:adriancatalinsv,项目名称:fiip,代码行数:11,代码来源:CommentsController.php

示例12: Dispatcher

 function __construct()
 {
     parent::__construct();
     // Get CI instance to obtain DB settings
     $ci =& get_instance();
     $this->addConnection(array('driver' => 'mysql', 'host' => $ci->db->hostname, 'database' => $ci->db->database, 'username' => $ci->db->username, 'password' => $ci->db->password, 'charset' => $ci->db->char_set, 'collation' => $ci->db->dbcollat, 'prefix' => $ci->db->dbprefix));
     // Listen to Model related events (saving, saved, updating, updated, creating, created etc).
     $this->setEventDispatcher(new Dispatcher(new Container()));
     // For CI Profiler (debugging utility)
     $events = new Dispatcher();
     $events->listen('illuminate.query', function ($query, $bindings, $time, $name) {
         // Format binding data for sql insertion
         foreach ($bindings as $i => $binding) {
             if ($binding instanceof \DateTime) {
                 $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
             } else {
                 if (is_string($binding)) {
                     $bindings[$i] = "'{$binding}'";
                 }
             }
         }
         // Insert bindings into query
         $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
         $query = vsprintf($query, $bindings);
         // Add it into CodeIgniter
         $ci =& get_instance();
         $ci->db->query_times[] = $time;
         $ci->db->queries[] = $query;
     });
     $this->setEventDispatcher($events);
     $this->setAsGlobal();
     $this->bootEloquent();
 }
开发者ID:salmander,项目名称:ci-on-wings,代码行数:33,代码来源:Capsule.php

示例13: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  * @return array
  */
 public function subscribe($events)
 {
     $events->listen('App\\Form\\Customer\\Register', 'App\\Handlers\\Forms\\Customer\\AuthHandler@register', 10);
     $events->listen('App\\Form\\Customer\\Login', 'App\\Handlers\\Forms\\Customer\\AuthHandler@login', 10);
     $events->listen('App\\Form\\Customer\\ForgotPassword', 'App\\Handlers\\Forms\\Customer\\AuthHandler@forgot_password', 10);
     $events->listen('App\\Form\\Customer\\ResetPassword', 'App\\Handlers\\Forms\\Customer\\AuthHandler@reset_password', 10);
 }
开发者ID:BryceHappy,项目名称:lavender,代码行数:13,代码来源:AuthHandler.php

示例14: subscribe

 /**
  * Register the listeners for the subscriber.
  *
  * @param  Illuminate\Events\Dispatcher  $events
  */
 public function subscribe(\Illuminate\Events\Dispatcher $events)
 {
     $class = 'Nasqueron\\Notifications\\Listeners\\NotificationListener';
     $events->listen('Nasqueron\\Notifications\\Events\\DockerHubPayloadEvent', "{$class}@onDockerHubPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\GitHubPayloadEvent', "{$class}@onGitHubPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\JenkinsPayloadEvent', "{$class}@onJenkinsPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\PhabricatorPayloadEvent', "{$class}@onPhabricatorPayload");
 }
开发者ID:nasqueron,项目名称:notifications,代码行数:13,代码来源:NotificationListener.php

示例15: sync

 /**
  * Send Laravel's Session Id to server via ZMQ
  * before client's websocket connection
  * 
  * @return void
  */
 public function sync($message)
 {
     $socket = $this->getSocket();
     $message = json_encode($message);
     // Fire events
     $this->events->fire('sid.sync', [$socket, $message]);
 }
开发者ID:redbaron76,项目名称:larapush,代码行数:13,代码来源:Larapush.php


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