2017 © Pedro Peláez
 

yii2-extension yii2-event-component

Attaches events to all models

image

bariew/yii2-event-component

Attaches events to all models

  • Wednesday, August 6, 2014
  • by bariew
  • Repository
  • 6 Watchers
  • 21 Stars
  • 9,758 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 9 Versions
  • 13 % Grown

The README.md

Yii2 event manager component

Attaches events to all application models in a very simple way. You just list your event handlers in config/_events.php this way: [ 'event\sender\ClassName' => [ 'eventName' => [ 'event\handler\ClassName' => 'methodName' ] ] ];, (*1)

See example below., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist bariew/yii2-event-component "*"

or add, (*5)

"bariew/yii2-event-component": "*"

to the require section of your composer.json file., (*6)

Usage

    Define app component in main config components section like in this example: 
    'components' => [
    ...
          'eventManager'=> [
              'class'     => 'bariew\eventManager\EventManager',
              'events'    => [
                  'app\models\User' => [
                      'afterInsert' => [
                          ['app\models\Email', 'userRegistration']
                      ],  
                  ]
              ]
          ],
    ]

    Explanation: in the example we defined that after creating new User model ('afterInsert')
    Email::userRegistration($event) method will be called.
    Since 1.1.0 you may also not define event manager, but just put _events.php
    into your config folder returning the same 'events' array as in example:

    <?php
    return [
        'app\models\User' => [
            'afterInsert' => [
                ['app\models\Email', 'userRegistration']
            ],
        ]
    ];
    since 1.3.0 handler can also keep additional data and $append boolean as for Event::on() method eg:
    ... [$handlerClassName, $handlerMethodName, ['myData'], false]

The Versions

06/08 2014

dev-master

9999999-dev

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

06/08 2014

2.0.0-beta

2.0.0.0-beta

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

04/08 2014

1.3.0-beta.2

1.3.0.0-beta2

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

04/08 2014

1.3.0-beta.1

1.3.0.0-beta1

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

29/07 2014

1.3.0-beta

1.3.0.0-beta

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

26/06 2014

1.2.1

1.2.1.0

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

23/06 2014

1.2.0

1.2.0.0

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

28/05 2014

1.1.0

1.1.0.0

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event

28/05 2014

1.0.0

1.0.0.0

Attaches events to all models

  Sources   Download

BSD-3-Clause

by Bariev Pavel

extension yii2 event