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]]);
     });
 }
 private function register_event_listener()
 {
     $watch =& $this;
     Event::listen('watcher:reload', function () use($watch) {
         touch($watch->watcher_reload_file);
     });
 }
 /**
  * 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();
     });
 }
 /**
  * EventsDataSource constructor.
  */
 public function __construct()
 {
     $this->points = [];
     Event::listen('*', function () {
         $this->points[] = ['memory' => memory_get_usage(true), 'time' => microtime(true)];
     });
 }
Beispiel #5
0
 public function __construct()
 {
     $this->middleware('jwt.auth');
     Event::listen('tymon.jwt.valid', function ($user) {
         $this->user = $user;
     });
 }
Beispiel #6
0
 /**
  *
  */
 protected function registerListeners()
 {
     EventFacade::listen('*', function ($param) {
         $this->data[] = ['name' => EventFacade::firing(), 'param' => $param, 'time' => microtime(true)];
         $this->stream();
     });
 }
Beispiel #7
0
 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.");
             }
         }
     });
 }
 /**
  * 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
     });
 }
 public function boot()
 {
     Event::listen('illuminate.query', function ($query, $params, $time, $conn) {
         Log::info($query);
     });
     $this->app['router']->post('datagridview', '\\mkdesignn\\datagridview\\DataGridViewController@postIndex');
 }
 /**
  * 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');
     });
 }
 /**
  * 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);
     }
 }
 /**
  * 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);
         });
     }
 }
Beispiel #13
0
 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();
 }
Beispiel #14
0
 /**
  * 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);
         }
     }
 }
Beispiel #15
0
 /**
  * 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();
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Event::listen('laravel.composing', function ($event) {
         dd($event);
     });
     $this->loadViewsFrom(__DIR__ . '/../views', 'notify');
     $this->publishes([__DIR__ . '/../views' => base_path('resources/views/vendor/notify')]);
 }
Beispiel #17
0
 protected function registerListeners()
 {
     EventFacade::listen('composing: *', function (View $view) {
         $data = array_except($view->getData(), ['obLevel', '__env', 'app']);
         $this->data[] = ['data' => $data, 'file' => $view->getPath(), 'name' => $view->name(), 'time' => microtime(true)];
         $this->stream();
     });
 }
Beispiel #18
0
 /**
  * If there are any listeners defined on the service provider, here we'll loop through
  * them and register them as subscribers with Laravel's events system.
  *
  * The format of the array on the service provider should be:
  *
  *     'some.event' => SomeEventListener::class
  */
 protected function registerListeners()
 {
     if (!isset($this->listeners)) {
         return;
     }
     foreach ($this->listeners as $event => $listener) {
         Event::listen($event, $listener);
     }
 }
Beispiel #19
0
 /**
  * Boot the auditable trait for a model.
  *
  * This sets up the listeners for the internal events fired by the Laravel
  * base model class.  In this class we only add one listener --- for after
  * a model is saved.
  *
  * @return void
  */
 public static function bootAuditable()
 {
     $class_name = get_called_class();
     Event::listen('eloquent.saved: ' . $class_name, function ($target) use($class_name) {
         if (method_exists($class_name, 'eventAuditLogger')) {
             call_user_func($class_name . '::eventAuditLogger', $target);
         }
     });
 }
 /**
  * Register any package services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton("one-auth", function () {
         return new OneAuth();
     });
     Event::listen('auth.logout', function () {
         App::make("one-auth")->logout();
     });
 }
Beispiel #21
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct()
 {
     Event::listen('auth.login', function ($event) {
         UsersLogs::create(['user_id' => Auth::user()->id, 'action' => 'login']);
     });
     Event::listen('auth.logout', function ($event) {
         UsersLogs::create(['user_id' => Auth::user()->id, 'action' => 'logout']);
     });
 }
 /**
  * Register any other events for your application.
  * @param  \Illuminate\Contracts\Events\Dispatcher $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     // Listen to all emails to prepend the
     // subject with '[Backstage Website]'
     Event::listen('mailer.sending', function ($message) {
         $message->setSubject('[Backstage Website] ' . $message->getSubject());
     });
 }
 public function __construct(Request $request)
 {
     parent::__construct($request);
     $this->middleware('auth.notWorker', ['except' => ['show', 'edit', 'update']]);
     Event::listen('auth.login', function ($user) {
         $user->last_login = new \DateTime('now');
         $user->save();
     });
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('hardywen/social-login');
     $config = $this->app->config->get('social-login::config');
     if ($config['auto_logout']) {
         Event::listen('auth.logout', function () {
             Session::forget("social_login");
         });
     }
 }
 /**
  * Register events for this service provider.
  *
  * @return void
  */
 public function registerEvents()
 {
     //Store the Kinvey auth token in the user's session, and clear it on logout.
     Event::listen('auth.login', function ($user) {
         Session::put('kinvey', $user->_kmd['authtoken']);
     });
     Event::listen('auth.logout', function ($user) {
         Session::forget('kinvey');
     });
 }
 /**
  * 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('Pizzeria\\Events\\OrderCreated', function ($event) {
         // Handle the event...
         Log::debug('EventServiceProvider::boot [Pizzeria\\Events\\OrderCreated] - got the event message: ');
         Log::debug($event->getMessage());
     });
 }
 /**
  * Register the application's event listeners.
  *
  * @return void
  */
 public function boot()
 {
     foreach ($this->listens() as $event => $listeners) {
         foreach ($listeners as $listener) {
             Event::listen($event, $listener);
         }
     }
     foreach ($this->subscribe as $subscriber) {
         Event::subscribe($subscriber);
     }
 }
Beispiel #28
0
 public static function event_bind($hook_name, $callback = false)
 {
     if (is_string($callback) and function_exists($callback)) {
         if (!isset(self::$hooks[$hook_name])) {
             self::$hooks[$hook_name] = array();
         }
         self::$hooks[$hook_name][] = $callback;
     } else {
         Event::listen($hook_name, $callback);
     }
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     if (!$this->app->routesAreCached()) {
         require __DIR__ . '/../Http/routes.php';
     }
     Event::listen('eloquent.creating: *', CreatingListener::class);
     Event::listen('eloquent.created: *', CreatedListener::class);
     $this->publishes([__DIR__ . '/../../config/config.php' => config_path('genealabs-laravel-governor.php')], 'genealabs-laravel-governor');
     $this->publishes([__DIR__ . '/../../public' => public_path('genealabs-laravel-governor')], 'genealabs-laravel-governor');
     $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'genealabs-laravel-governor');
 }
 public function testCreateAndDeleteRole()
 {
     $role = $this->getRepository()->create($this->sample);
     $this->assertInstanceOf(Role::class, $role);
     $roleId = $role->getId();
     $this->seeInDatabase('auth_roles', ['id' => $roleId]);
     Event::listen(RoleWasDeleted::class, function ($event) use($roleId) {
         $this->assertInstanceOf(Role::class, $event->role);
         $this->assertEquals($roleId, $event->role->getId());
     });
     $this->getRepository()->delete($role);
     $this->assertNull($this->getRepository()->getRole($role->getId()));
 }