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


PHP Event::listen方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Event::listen方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::listen方法的具体用法?PHP Event::listen怎么用?PHP Event::listen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\Event的用法示例。


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

示例1: boot

 public function boot()
 {
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('Genius.Base', 'pages', ['contacts' => ['label' => 'genius.contacts::lang.settings.menu_label', 'icon' => 'icon-envelope-o', 'url' => Backend::url('genius/contacts/settings/update/1'), 'order' => 20]]);
         $manager->addSideMenuItems('Genius.Base', 'admin', ['contacts' => ['label' => 'genius.contacts::lang.contacts.menu_label', 'icon' => 'icon-envelope-o', 'url' => Backend::url('genius/contacts/contacts'), 'order' => 20]]);
     });
 }
开发者ID:estudiogenius,项目名称:oc-genius-contacts,代码行数:7,代码来源:Plugin.php

示例2: register_event_listener

 private function register_event_listener()
 {
     $watch =& $this;
     Event::listen('watcher:reload', function () use($watch) {
         touch($watch->watcher_reload_file);
     });
 }
开发者ID:zulfajuniadi,项目名称:laravel-watch,代码行数:7,代码来源:WatchServiceProvider.php

示例3: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../config/profiler.php', 'profiler');
     if (!$this->app->bound('hash')) {
         $hash = $this->app->share(function () {
             return new BcryptHasher();
         });
         $this->app->bind('hash', $hash);
     }
     $config = $this->app->make('config');
     $enable = $config->get('app.debug');
     $enable = boolval($enable);
     $profilerRequest = $this->isProfilerCall();
     /** @var Logger $logger */
     $logger = $this->app->make('log');
     try {
         $profiler = ProfilerFactory::build($this->buildConfiguration($enable, $profilerRequest));
     } catch (\Exception $e) {
         $logger->error('Fail to build profiler error: ' . $e->getMessage(), [' message : ' => $e->getMessage(), ' file : ' => $e->getFile(), ' line : ' => $e->getLine(), ' trace : ' => $e->getTraceAsString()]);
         $profiler = new NullProfiler();
     }
     if ($enable) {
         if (!$profilerRequest) {
             $logger->getMonolog()->pushHandler($profiler->getLogger());
         }
         $this->registerCors();
         $this->registerRoutes();
     }
     $this->registerProfiler($profiler);
     $profiler->initiate();
     $profiler->getContext()->sendDebugIds();
     Event::listen('kernel.handled', function () use($profiler) {
         $profiler->terminate();
     });
 }
开发者ID:ndrx-io,项目名称:profiler-laravel,代码行数:40,代码来源:LaravelProfilerServiceProvider.php

示例4: __construct

 /**
  * EventsDataSource constructor.
  */
 public function __construct()
 {
     $this->points = [];
     Event::listen('*', function () {
         $this->points[] = ['memory' => memory_get_usage(true), 'time' => microtime(true)];
     });
 }
开发者ID:lahaxearnaud,项目名称:clockwork,代码行数:10,代码来源:MemoryDataSource.php

示例5: __construct

 public function __construct()
 {
     $this->middleware('jwt.auth');
     Event::listen('tymon.jwt.valid', function ($user) {
         $this->user = $user;
     });
 }
开发者ID:Rep2,项目名称:QUIZ,代码行数:7,代码来源:QuizController.php

示例6: registerListeners

 /**
  *
  */
 protected function registerListeners()
 {
     EventFacade::listen('*', function ($param) {
         $this->data[] = ['name' => EventFacade::firing(), 'param' => $param, 'time' => microtime(true)];
         $this->stream();
     });
 }
开发者ID:ndrx-io,项目名称:profiler-laravel,代码行数:10,代码来源:Event.php

示例7: listen

 protected function listen(DataProvider $provider)
 {
     Event::listen(DataProvider::EVENT_FETCH_ROW, function (DataRow $row, DataProvider $provider) use($provider) {
         if ($provider !== $provider) {
             return;
         }
         $this->rows_processed++;
         foreach ($this->fields as $field) {
             $name = $field->getName();
             $operation = $this->getFieldOperation($name);
             switch ($operation) {
                 case self::OPERTATION_SUM:
                     $this->src[$name] += $row->getCellValue($field);
                     break;
                 case self::OPERATION_COUNT:
                     $this->src[$name] = $this->rows_processed;
                     break;
                 case self::OPERATION_AVG:
                     if (empty($this->src["{$name}_sum"])) {
                         $this->src["{$name}_sum"] = 0;
                     }
                     $this->src["{$name}_sum"] += $row->getCellValue($field);
                     $this->src[$name] = round($this->src["{$name}_sum"] / $this->rows_processed, 2);
                     break;
                 default:
                     throw new Exception("TotalsRow:Unknown aggregation operation.");
             }
         }
     });
 }
开发者ID:creativify,项目名称:Grids,代码行数:30,代码来源:TotalsRow.php

示例8: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Event::listen('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
         $user = $event->getSaml2User();
         /*$userData = [
               'id' => $user->getUserId(),
               'attributes' => $user->getAttributes(),
               'assertion' => $user->getRawSamlAssertion()
           ];*/
         $laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
         if ($laravelUser != null) {
             Auth::login($laravelUser);
         } else {
             //if first user then create it and login
             $count = \App\User::all()->count();
             if ($count == 0) {
                 $data = array();
                 $data['lastname'] = "";
                 $data['firstname'] = "";
                 $data['username'] = $user->getUserId();
                 $data['role'] = "admin";
                 $user = \App\User::create($data);
                 \Auth::login($user);
                 return \Redirect::to('/');
             } else {
                 abort(401);
             }
         }
         //if it does not exist create it and go on  or show an error message
     });
 }
开发者ID:ghyster,项目名称:dns-angular,代码行数:38,代码来源:EventServiceProvider.php

示例9: boot

 public function boot()
 {
     Event::listen('illuminate.query', function ($query, $params, $time, $conn) {
         Log::info($query);
     });
     $this->app['router']->post('datagridview', '\\mkdesignn\\datagridview\\DataGridViewController@postIndex');
 }
开发者ID:mkdesignn,项目名称:datagridview,代码行数:7,代码来源:MkDatagridviewServiceProvider.php

示例10: register

 /**
  * Register the service provider.
  */
 public function register()
 {
     App::bind('toolbox.commands.controllers', function () {
         return new \Impleri\Toolbox\Commands\ControllersCommand();
     });
     App::bind('toolbox.commands.models', function () {
         return new \Impleri\Toolbox\Commands\ModelsCommand();
     });
     App::bind('toolbox.commands.routes', function () {
         return new \Impleri\Toolbox\Commands\RoutesCommand();
     });
     App::bind('toolbox.commands.schema', function () {
         return new \Impleri\Toolbox\Commands\SchemaCommand();
     });
     App::bind('toolbox.commands.views', function () {
         return new \Impleri\Toolbox\Commands\ViewsCommand();
     });
     App::bind('toolbox.commands.build', function () {
         return new \Impleri\Toolbox\Commands\BuildCommand();
     });
     $this->commands($this->provides());
     // Subscribe our own commands to toolbox.compile
     Event::listen('toolbox.build', function ($app) {
         $app->call('toolbox:routes');
         $app->call('toolbox:controllers');
         $app->call('toolbox:models');
         $app->call('toolbox:schema');
         $app->call('toolbox:views');
     });
 }
开发者ID:impleri,项目名称:laravel-toolbox,代码行数:33,代码来源:ToolboxServiceProvider.php

示例11: boot

 /**
  * Register the application's event listeners.
  *
  * @return void
  */
 public function boot()
 {
     $add_hook = function ($type, $name, $listeners) {
         $listeners = is_array($listeners) ? $listeners : [$listeners];
         array_walk($listeners, function ($listener) use($type, $name) {
             $fn = 'add_' . $type;
             // `add_action` or `add_filter`
             $fn($name, function () use($listener) {
                 $listener_instance = app()->make($listener);
                 return call_user_func_array([$listener_instance, 'handle'], func_get_args());
             }, 10, 10);
         });
     };
     foreach ($this->listens() as $event => $listeners) {
         $listeners = is_array($listeners) ? $listeners : [$listeners];
         foreach ($listeners as $listener) {
             Event::listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         Event::subscribe($subscriber);
     }
     foreach ($this->action as $action => $listeners) {
         $add_hook('action', $action, $listeners);
     }
     foreach ($this->filter as $filter => $listeners) {
         $add_hook('filter', $filter, $listeners);
     }
 }
开发者ID:laraish,项目名称:framework,代码行数:34,代码来源:EventServiceProvider.php

示例12: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // 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);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
开发者ID:oscaragcp,项目名称:sql-logging,代码行数:32,代码来源:SqlLoggingServiceProvider.php

示例13: __construct

 public function __construct()
 {
     parent::__construct();
     Route::get('partners', array('before' => 'auth', array($this, 'view')));
     Event::listen('construct_left_menu', array($this, 'left_menu_item'));
     $this->layout = Template::mainLayout();
 }
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:7,代码来源:partners.php

示例14: run

 /**
  * Main processing loop
  *
  * @throws \ZMQPollException
  */
 public function run()
 {
     $poll = new \ZMQPoll();
     $readable = $writable = [];
     foreach ($this->listen as $socket) {
         $poll->add($socket, \ZMQ::POLL_IN);
     }
     $processing = true;
     Event::listen('zeroevents.service.stop', function () use(&$processing) {
         $processing = false;
     });
     while ($processing) {
         try {
             $poll->poll($readable, $writable, $this->pollTimeout);
             foreach ($readable as $socket) {
                 $socket->pullAndFire();
             }
         } catch (\ZMQPollException $ex) {
             if ($ex->getCode() == 4) {
                 //  4 == EINTR, interrupted system call
                 usleep(1);
                 //  Don't just continue, otherwise the ticks function won't be processed
                 continue;
             }
             throw $ex;
         }
         if (!$readable) {
             Event::fire('zeroevents.service.idle', $this);
         }
     }
 }
开发者ID:ptrofimov,项目名称:zeroevents,代码行数:36,代码来源:EventService.php

示例15: execute

 /**
  * Method for evaluating the PHP's code. 
  *
  * @param string $code - PHP's code that we want to evaluate
  * @return string
  */
 public function execute($code = '')
 {
     // if argument is given then we override code that has been set on the constructor.
     if (strlen($code) > 0) {
         $this->code = $code;
     }
     $me = $this;
     // listen to the laravel query event
     Event::listen('illuminate.query', function ($query, $bindings, $time, $name) use($me) {
         $me->addQuery($query, $bindings, $time, $name);
     });
     // start output buffering
     ob_start();
     // OK, this is the time...
     $start = microtime(TRUE);
     $retval = @eval($this->code);
     $end = microtime(TRUE);
     $this->execTime = $end - $start;
     // if the eval() return FALSE then it could be syntax error.
     if ($retval === FALSE) {
         throw new Exception("I can not evaluate your code, it could be syntax error or " . "you're drunk. Please check your code or make some coffee.");
     }
     // collect memory usage
     $this->memory = array('current' => memory_get_usage(TRUE), 'peak' => memory_get_peak_usage(TRUE));
     // catch the output buffer that we getting from eval() above
     $this->output = ob_get_clean();
     return $this->render();
 }
开发者ID:Ganamuhibudin,项目名称:nomorsurat,代码行数:34,代码来源:Laraeval.php


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