Class SimpleModelHelper
RedBean Model Helper.
Connects beans to models.
This is the core of so-called FUSE.
-
RedBeanPHP\SimpleModelHelper
implements
RedBeanPHP\Observer
Namespace: RedBeanPHP
Copyright:
copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
This source file is subject to the BSD/GPLv2 License that is bundled
with this source code in the file license.txt.
License:
BSD/GPLv2
Author:
Gabor de Mooij and the RedBeanPHP Community
File:
RedBeanPHP/ModelHelper.php
Located at SimpleModelHelper.php
Methods summary
public
|
#
onEvent( string $eventName, OODBean $bean )
Gets notified by an observable.
This method decouples the FUSE system from the actual beans.
If a FUSE event happens 'update', this method will attempt to
invoke the corresponding method on the bean.
Gets notified by an observable.
This method decouples the FUSE system from the actual beans.
If a FUSE event happens 'update', this method will attempt to
invoke the corresponding method on the bean.
Parameters
- $eventName
- i.e. 'delete', 'after_delete'
- $bean
- affected bean
Implementation of
|
public
|
#
attachEventListeners( RedBeanPHP\Observable $observable )
Attaches the FUSE event listeners. Now the Model Helper will listen for
CRUD events. If a CRUD event occurs it will send a signal to the model
that belongs to the CRUD bean and this model will take over control from
there. This method will attach the following event listeners to the observable:
Attaches the FUSE event listeners. Now the Model Helper will listen for
CRUD events. If a CRUD event occurs it will send a signal to the model
that belongs to the CRUD bean and this model will take over control from
there. This method will attach the following event listeners to the observable:
- 'update' (gets called by R::store, before the records gets inserted / updated)
- 'after_update' (gets called by R::store, after the records have been inserted / updated)
- 'open' (gets called by R::load, after the record has been retrieved)
- 'delete' (gets called by R::trash, before deletion of record)
- 'after_delete' (gets called by R::trash, after deletion)
- 'dispense' (gets called by R::dispense)
For every event type, this method will register this helper as a listener.
The observable will notify the listener (this object) with the event ID and the
affected bean. This helper will then process the event (onEvent) by invoking
the event on the bean. If a bean offers a method with the same name as the
event ID, this method will be invoked.
Parameters
- $observable
- object to observe
|