listen() public static method

Register an event listener with the dispatcher.
public static listen ( string | array $events, mixed $listener, integer $priority ) : void
$events string | array
$listener mixed
$priority integer
return void
 protected function listeners()
 {
     parent::listeners();
     Event::listen($this, Event::BEFORE_UPDATE_FORM_PARSE, array($this, 'handle_widget_before_form_parse'));
     Event::listen($this, Event::BEFORE_CREATE, array($this, 'handle_widget_before_update'));
     Event::listen($this, Event::BEFORE_UPDATE, array($this, 'handle_widget_before_update'));
 }
 protected function listeners()
 {
     Event::listen($this, Event::AFTER_CREATE_FORM, array($this, 'handle_branch_after_create_form'));
     Event::listen($this, Event::AFTER_UPDATE_FORM, array($this, 'handle_branch_after_update_form'));
     Event::listen($this, Event::BEFORE_CREATE_FORM_PARSE, array($this, 'handle_branch_before_create_form_parse'));
     parent::listeners();
 }
 protected function listeners()
 {
     parent::listeners();
     Event::listen($this, Event::BEFORE_LIST, array($this, 'handle_content_before_list'));
     Event::listen($this, Event::BEFORE_LIST_RENDER, array($this, 'handle_content_before_list_render'));
     Event::listen($this, Event::BEFORE_CREATE, array($this, 'handle_content_before_create'));
 }
 public static function enable()
 {
     \Event::listen('list:approved-by-admin', function ($list) {
         $approvedListNotification = new ApprovedListNotifications($list);
         $approvedListNotification->notify();
     });
 }
Example #5
0
 public function __construct($name, $label, &$model = null, &$model_relations = null)
 {
     parent::__construct($name, $label, $model, $model_relations);
     \Event::listen('rapyd.uploaded.' . $this->name, function () {
         $this->fileProcess();
     });
 }
Example #6
0
 /**
  * Constructor.
  *
  * @param   object  &$subject  The object to observe
  * @param   array   $config    An array that holds the plugin configuration
  *
  * @since 1.5
  */
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Log the deprecated API.
     if ($this->params->get('log-deprecated')) {
         \JLog::addLogger(array('text_file' => 'deprecated.php'), \JLog::ALL, array('deprecated'));
     }
     // Log database errors
     if ($this->params->get('log-database-errors')) {
         \JLog::addLogger(array('text_file' => 'jdatabase.error.php'), \JLog::ALL, array('database'));
     }
     // Log database queries
     if ($this->params->get('log-database-queries')) {
         \JLog::addLogger(array('text_file' => 'jdatabase.query.php'), \JLog::ALL, array('databasequery'));
         // Register the HUBzero database logger as well
         // Don't worry, this won't log things twice...queries through joomla's database driver
         // will get logged above, and this will catch queries through hubzero's database driver
         \Event::listen(function ($event) {
             \Hubzero\Database\Log::add($event->getArgument('query'), $event->getArgument('time'));
         }, 'database_query');
     }
     // Only if debugging or language debug is enabled
     if (Config::get('debug') || Config::get('debug_lang')) {
         Config::set('gzip', 0);
         ob_start();
         ob_implicit_flush(false);
     }
     $this->linkFormat = ini_get('xdebug.file_link_format');
 }
Example #7
0
 function sq($date)
 {
     Event::listen('illuminate.query', function ($query) {
         // echo "<pre>";
         var_dump($query);
     });
 }
Example #8
0
 /**
  * Register the Blade view engine with Laravel.
  *
  * @return void
  */
 public static function sharpen()
 {
     Event::listen(View::engine, function ($view) {
         // The Blade view engine should only handle the rendering of views which
         // end with the Blade extension. If the given view does not, we will
         // return false so the View can be rendered as normal.
         if (!str_contains($view->path, BLADE_EXT)) {
             //return;
         }
         $compiled = Blade::compiled($view->path);
         // If the view doesn't exist or has been modified since the last time it
         // was compiled, we will recompile the view into pure PHP from it's
         // Blade representation, writing it to cached storage.
         if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
             file_put_contents($compiled, Blade::compile($view));
         }
         $view->mytplengine or $view->mytplengine = new \TemplateEngine(TEMPLATEPATH);
         //kd($compiled);
         $compiled = $view->mytplengine->display($compiled, true);
         $view->path = $compiled;
         // Once the view has been compiled, we can simply set the path to the
         // compiled view on the view instance and call the typical "get"
         // method on the view to evaluate the compiled PHP view.
         return ltrim($view->get());
     });
 }
 public function boot()
 {
     app('view')->addNamespace('frontend', base_path('resources/layouts'));
     \Event::listen('view.page.edit.before', function ($page) {
         echo view('pages::parts.list')->with('page', $page);
     });
 }
 protected function listeners()
 {
     Event::listen($this, Event::BEFORE_LIST, array($this, 'handle_group_before_list'));
     Event::listen($this, Event::BEFORE_CREATE, array($this, 'handle_group_before_create'));
     Event::listen($this, Event::AFTER_DELETE, array($this, 'handle_group_after_delete'));
     parent::listeners();
 }
Example #11
0
 /**
  * Class constructor
  *
  * @param	array An optional associative array of configuration settings.
  * Recognized key values include 'clientId' (this list is not meant to be comprehensive).
  */
 public function __construct($config = array())
 {
     $config['clientId'] = 0;
     \Event::listen(function ($event) {
         // This must be done before the session is read, otherwise it will overwrite
         // the existing session with a guest non-https session prior to redirecting to https
         // NOTE: we're including a cli check here because the console currently uses the 'site'
         // application.  This should be remedied in the new framework.
         $app = $event->getArgument('app');
         if ($app->getCfg('force_ssl') == 2 && php_sapi_name() != 'cli') {
             $uri = JURI::getInstance();
             if (strtolower($uri->getScheme()) != 'https') {
                 // We also can't use the Application::redirect method here as
                 // it tries to use JFactory::getDocument, which doesn't work
                 // prior to application initialization
                 $uri->setScheme('https');
                 header('HTTP/1.1 303 See other');
                 header('Location: ' . (string) $uri);
                 header('Content-Type: text/html;');
                 $app->close();
             }
         }
     }, 'application_onBeforeSessionCreate');
     parent::__construct($config);
 }
 public function register()
 {
     \Event::listen('SleepingOwl\\Admin\\Events\\UserEvent', function ($event) {
         foreach ($event->model->items() as $group => $items) {
             foreach ($items as $key => $item) {
                 //ignore Roles field
                 if ($item instanceof \SleepingOwl\Admin\FormItems\Roles) {
                     continue;
                 }
                 //ignore Permissions field
                 if ($item instanceof \SleepingOwl\Admin\FormItems\Permissions) {
                     continue;
                 }
                 $value = $item->save();
             }
         }
         $created = $event->model->instance()->save();
         //update the current record and add roles and permissions
         $items = $event->model->items();
         array_walk_recursive($items, function ($item) {
             $item->save();
         });
         $update = $event->model->instance()->save();
     });
 }
 /**
  * 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('Illuminate\\Cache\\Events\\KeyWritten', function ($event) {
         Bugsnag::leaveBreadcrumb('Cache written', 'process', ['key' => $event->key, 'value' => $event->value, 'ttl' => "{$event->minutes}mins"]);
     });
     Bugsnag::setAppVersion(version());
 }
Example #14
0
 public function checkTableNotFound()
 {
     \Event::listen('table.notfound', function () {
         if (!\Schema::hasTable('urlshortner')) {
             \Artisan::call('migrate', array('--bench' => 'xmaestro/urlshortner'));
         }
     });
 }
Example #15
0
 /**
  * Test parameters can be passed to event listeners.
  *
  * @group laravel
  */
 public function testParametersCanBePassedToEvents()
 {
     Event::listen('test.event', function ($var) {
         return $var;
     });
     $responses = Event::fire('test.event', array('Taylor'));
     $this->assertEquals('Taylor', $responses[0]);
 }
Example #16
0
 /**
  * Associates the model provided back to the model by way of their proper keys
  *
  * @param   object   $model     The model to associate
  * @param   closure  $callback  A callback to potentially append additional data
  * @return  object
  * @since   2.0.0
  **/
 public function associate($model, $callback = null)
 {
     $relationship = $this;
     Event::listen(function ($event) use($model, $relationship) {
         $relationship->connect([$model->id]);
     }, $model->getTableName() . '_new');
     return $model;
 }
 /**
  * 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('App\\Events\\sendemail', function ($event) {
         \Log::info("test sendemail in boot");
     });
 }
 /**
  * This method runs when the trait has booted
  * 
  */
 public static function bootHasManyMetaDataTrait()
 {
     $name = static::class;
     // Add a listener on deleting a object and delete all of its metas
     \Event::listen("eloquent.deleting: {$name}", function ($model) {
         $model->delete_all_metas();
     });
 }
 /**
  *
  */
 public function __construct()
 {
     \Event::listen('vikon.parser.before.parse', [$this, 'normalizeLineBreak']);
     // Base rule
     $this->setStartRule(new BaseRule());
     // ESCAPE
     $this->addRule(new EscapeRule(), self::CATEGORY_FORMAT);
     // BR
     if (!$this->isModeGfm()) {
         $this->addRule(new BrRule(), self::CATEGORY_SINGLE);
     }
     // HEADER
     $this->addRule(new HeaderAtxRule(), self::CATEGORY_SINGLE);
     $this->addRule(new HeaderSetextRule(), self::CATEGORY_SINGLE);
     // REFERENCE
     $this->addRule(new ReferenceRule(), self::CATEGORY_SINGLE);
     // URL
     $this->addRule(new LinkInlineRule(), self::CATEGORY_FORMAT);
     $this->addRule(new LinkReferenceRule(), self::CATEGORY_FORMAT);
     if ($this->isModeGfm()) {
         $this->addRule(new LinkAutoRule(), self::CATEGORY_FORMAT);
     }
     // IMAGE
     $this->addRule(new ImageInlineRule(), self::CATEGORY_FORMAT);
     $this->addRule(new ImageReferenceRule(), self::CATEGORY_FORMAT);
     // EMPHASIS / ITALIC
     $this->addRule(new ItalicRule(), self::CATEGORY_FORMAT);
     $this->addRule(new ItalicAltRule(), self::CATEGORY_FORMAT);
     // EMPHASIS / STRONG
     $this->addRule(new StrongRule(), self::CATEGORY_FORMAT);
     $this->addRule(new StrongAltRule(), self::CATEGORY_FORMAT);
     // EMPHASIS / STRIKETHROUGH
     if ($this->isModeGfm()) {
         $this->addRule(new StrikethroughRule(), self::CATEGORY_FORMAT);
     }
     // CODE
     $this->addRule(new CodeRule(), self::CATEGORY_FORMAT);
     $this->addRule(new CodeAltRule(), self::CATEGORY_FORMAT);
     // CODE BLOCK
     $this->addRule(new CodeBlockRule(), self::CATEGORY_BLOCK);
     // FENCED CODE BLOCK
     if ($this->isModeGfm()) {
         $this->addRule(new FencedCodeBlockRule(), self::CATEGORY_BLOCK);
     }
     // END OF LINE
     $this->addRule(new EolRule(), self::CATEGORY_SINGLE);
     // LIST RULE
     $this->addRule(new ListBlockRule(), self::CATEGORY_BLOCK);
     // PARAGRAPH RULE
     $this->addRule(new PRule([], ['LIST_BLOCK_LEVEL_OPEN', 'LIST_BLOCK_LEVEL_CLOSE', 'LIST_BLOCK_ITEM_OPEN', 'LIST_BLOCK_ITEM_CLOSE']), self::CATEGORY_NONE);
     // TABLE
     if ($this->isModeGfm()) {
         $this->addRule(new TableRule(), self::CATEGORY_BLOCK);
     }
     // MATH
     $this->addRule(new MathRule(), self::CATEGORY_FORMAT);
 }
 public function boot()
 {
     \Event::listen('backend.form.extendFields', function ($widget) {
         if (!$widget->getController() instanceof \ArrizalAmin\Portfolio\Controllers\Items) {
             return;
         }
         $widget->addTabFields(['slug' => ['label' => 'Slug', 'preset' => 'title', 'tab' => 'Pages'], 'excerpt' => ['label' => 'arrizalamin.portfoliopages::lang.fields.excerpt', 'type' => 'richeditor', 'size' => 'small', 'tab' => 'Pages']]);
     });
 }
 protected function listeners()
 {
     parent::listeners();
     Event::listen($this, Event::BEFORE_LIST, array($this, 'handle_user_before_list'), TRUE);
     Event::listen($this, Event::AFTER_CREATE_FORM, array($this, 'handle_user_after_create_form'));
     Event::listen($this, Event::BEFORE_UPDATE_FORM_PARSE, array($this, 'handle_user_before_update_form_parse'));
     Event::listen($this, Event::BEFORE_CREATE, array($this, 'handle_user_before_create'));
     Event::listen($this, Event::BEFORE_UPDATE, array($this, 'handle_user_before_update'));
 }
Example #22
0
 /**
  * This method will fire the Event structure of Laravel to listen to calls to save the access story
  */
 public static function listenForInterviews()
 {
     // note - the name of the publish story event must be the same as that of the publish method
     $PublishMethodName = "publishStory";
     //$sPublishClassMethod = __CLASS__."@{$PublishMethodName}";
     \Event::listen(Reader::getEventName(), function () use($PublishMethodName) {
         call_user_func([new static(), $PublishMethodName]);
     });
 }
 /**
  * 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('Rapidweb\\Admin\\Events\\PodcastWasPurchased', function ($event) {
         // Handle the event...
         return 'hello world';
     });
     //
 }
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->package('codesleeve/guard-live-reload');
     \Event::listen('guard.boot', function ($guard) {
         $config = $guard->getConfig();
         $config['events'][] = new LiveReloadEvent();
         $guard->setConfig($config);
     });
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('pagemanager', function () {
         return new Pagemanager();
     });
     \Event::listen('composing: *', function ($view) {
         $pm = \App::make('pagemanager');
         $pm->addBodyClass($view->getName());
     });
 }
Example #26
0
 public function register()
 {
     $this->app->bind('backup.zippy', function () {
         return Zippy::load();
     });
     \Event::listen('admin::menu.load', function ($menu) {
         $format = '<img src="%s" class="fa" />&nbsp;&nbsp;<span>%s</span>';
         $menu->add(sprintf($format, moduleAsset('backup', 'images/icon_backup.png'), 'Backup'), route('admin.backup.index'));
     });
 }
Example #27
0
 public function testApiTheme()
 {
     Event::flush('cms.activeTheme');
     Event::listen('cms.activeTheme', function () {
         return 'apitest';
     });
     $activeTheme = Theme::getActiveTheme();
     $this->assertNotNull($activeTheme);
     $this->assertEquals('apitest', $activeTheme->getDirName());
 }
Example #28
0
 /**
  * Let the reflection do it's work
  * @param Product $model the Eloquent model
  */
 public function __construct(Product $model)
 {
     $this->model = $model;
     // We can bind to Epi specific events
     Event::listen('after.update', function ($modelName, $id, $model, $input) {
     });
     // We can bind to Epi specific events for a certain model
     Event::listen('after.update: Vespakoen\\Epi\\Example\\Models\\Product', function ($id, $model, $input) {
     });
 }
Example #29
0
 /**
  * Boot the trait.
  */
 public static function bootAdminImage()
 {
     // Observer for the model
     static::observe(ImageObserver::class);
     // Add Assets
     $assetManager = app(AssetsContract::class);
     $assetManager->addJs('js/flow.js/flow.min.js');
     $assetManager->addJs('js/sortable/Sortable.min.js');
     // We need to listen for booted event and modify the model.
     \Event::listen('eloquent.booted: ' . static::class, [new self(), 'bootstrapModel']);
 }
Example #30
0
 public function testStopListeningRemovesListener()
 {
     $callback = 'beforePerformEventCallback';
     $event = 'beforePerform';
     Event::listen($event, array($this, $callback));
     Event::stopListening($event, array($this, $callback));
     $job = $this->getEventTestJob();
     $this->worker->perform($job);
     $this->worker->work(0);
     $this->assertNotContains($callback, $this->callbacksHit, $event . ' callback (' . $callback . ') was called though Event::stopListening was called');
 }