Created
November 2, 2009 11:51
-
-
Save develop7/224108 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class userActions extends sfActions | |
{ | |
//...где-то в контроллере | |
public function executeSomething(sfWebRequest $request) | |
{ | |
//...ещё глубже в дебри | |
$this->getEventDispatcher()->notify(new sfEvent($this, 'logging.triggerblabla', array('param1' => 'foo))); | |
} | |
} |
This file contains hidden or 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
<?php | |
class myLogHandler | |
{ | |
static $logger = null; | |
static public function handleLogEvent(sfEvent $evt) | |
{ | |
self::$logger->log('By '.$evt->getSubject().' param1='.$evt['param1']);//Например, так | |
} | |
protected getLogger() | |
{ | |
if (self::$logger == null) | |
{ | |
self::$logger = new BlaBlaLogger('foo', 'bar', 'baz'); | |
} | |
return self::$logger; | |
} | |
} |
This file contains hidden or 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
<?php | |
# FROZEN_SF_LIB_DIR: /usr/share/php/symfony | |
require_once dirname(__FILE__).'/../lib/symfony/autoload/sfCoreAutoload.class.php'; | |
sfCoreAutoload::register(); | |
class ProjectConfiguration extends sfProjectConfiguration | |
{ | |
public function setup() | |
{ | |
// for compatibility / remove and enable only the plugins you want | |
$this->enableAllPluginsExcept(array()); | |
$this->registerEventHandlers(); | |
} | |
//... | |
protected function registerEventHandlers() | |
{ | |
//... | |
$this->getEventDispatcher()->connect('logging.triggerblabla', array('myLogHandler', 'handleLogEvent')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment