forked from openpne/OpenPNE3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added opDoctrineEventNotifier for notify Doctrine_Event as sfEvent (r…
…efs #933)
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the OpenPNE package. | ||
* (c) OpenPNE Project (http://www.openpne.jp/) | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file and the NOTICE file that were distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* opDoctrineEventNotifier | ||
* | ||
* @package OpenPNE | ||
* @subpackage util | ||
* @author Eitarow Fukamachi <fukamachi@tejimaya.com> | ||
*/ | ||
class opDoctrineEventNotifier extends Doctrine_Record_Listener | ||
{ | ||
private static function notify($when, $action, $doctrineEvent) | ||
{ | ||
$dispatcher = sfContext::getInstance()->getEventDispatcher(); | ||
$dispatcher->notify(new sfEvent(null, sprintf('op_doctrine.%s_%s_%s', $when, $action, get_class($doctrineEvent->getInvoker())))); | ||
} | ||
|
||
public function preSave(Doctrine_Event $event) | ||
{ | ||
self::notify('pre', 'save', $event); | ||
} | ||
|
||
public function postSave(Doctrine_Event $event) | ||
{ | ||
self::notify('post', 'save', $event); | ||
} | ||
|
||
public function preUpdate(Doctrine_Event $event) | ||
{ | ||
self::notify('pre', 'update', $event); | ||
} | ||
|
||
public function postUpdate(Doctrine_Event $event) | ||
{ | ||
self::notify('post', 'update', $event); | ||
} | ||
|
||
public function preInsert(Doctrine_Event $event) | ||
{ | ||
self::notify('pre', 'insert', $event); | ||
} | ||
|
||
public function postInsert(Doctrine_Event $event) | ||
{ | ||
self::notify('post', 'insert', $event); | ||
} | ||
|
||
public function preDelete(Doctrine_Event $event) | ||
{ | ||
self::notify('pre', 'delete', $event); | ||
} | ||
|
||
public function postDelete(Doctrine_Event $event) | ||
{ | ||
self::notify('post', 'delete', $event); | ||
} | ||
|
||
public function preValidate(Doctrine_Event $event) | ||
{ | ||
self::notify('pre', 'validate', $event); | ||
} | ||
|
||
public function postValidate(Doctrine_Event $event) | ||
{ | ||
self::notify('post', 'validate', $event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters