2017 © Pedro Peláez
 

library phact

A Simple Event Propagation with Phalcon Framework

image

wandersonwhcr/phact

A Simple Event Propagation with Phalcon Framework

  • Thursday, September 25, 2014
  • by wandersonwhcr
  • Repository
  • 1 Watchers
  • 8 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Phact

Phact is a simple event propagation usage with Phalcon Framework. With Phact you can create a set of nodes, write some events and execute them with some order., (*1)

Example

use Phact\Manager;
use Phact\NodeInterface;
use Phalcon\Events\Event;
use Phalcon\Events\Manager as EventsManager;

class A implements NodeInterface
{
    public function onExecute(Event $event, NodeInterface $node)
    {
        if ($node instanceof self) { // or $event->getData() == 'A'
            echo "A!";
        }
    }
}

class B implements NodeInterface
{
    public function onBeforeExecute(Event $event, NodeInterface $node)
    {
        if ($node instanceof A) { // or $event->getData() == 'A'
            echo "B before A! ";
        }
    }
}

$manager = (new Manager())
    ->setEventsManager(new EventsManager())
    ->add('A', new A())
    ->add('B', new B());

$manager->execute('A'); // outputs "B before A! A!"

Composer

You can install Phact inside your project with Composer., (*2)

{
    "require": {
        "wandersonwhcr/phact": "1.*"
    }
}

Usage

You can implement three methods using NodeInterface:, (*3)

use Phact\NodeInterface;
use Phalcon\Events\Event;

class Node implements NodeInterface
{
    public function onBeforeExecute(Event $event, NodeInterface $node)
    {
    }

    public function onExecute(Event $event, NodeInterface $node)
    {
    }

    public function onAfterExecute(Event $event, NodeInterface $node)
    {
    }
}

With these events, you can order your node executions and create awesome events propagation like installers or database structure changes., (*4)

The Versions

25/09 2014

dev-master

9999999-dev

A Simple Event Propagation with Phalcon Framework

  Sources   Download

BSD-3-Clause

The Requires

  • ext-phalcon *

 

25/09 2014

v1.0.0

1.0.0.0

A Simple Event Propagation with Phalcon Framework

  Sources   Download

BSD-3-Clause

The Requires

  • ext-phalcon *