本文整理汇总了PHP中sfEvent类的典型用法代码示例。如果您正苦于以下问题:PHP sfEvent类的具体用法?PHP sfEvent怎么用?PHP sfEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExceptionHandler
public function ExceptionHandler(sfEvent $event)
{
$exception = $event->getSubject();
if (get_class($exception) == 'OAuthException') {
$response = sfContext::getInstance()->getResponse();
$response->setContentType('text/html');
$request = sfContext::getInstance()->getRequest();
$format = $request->getRequestFormat();
if (!$format) {
$format = 'html';
}
if ($mimeType = $request->getMimeType($format)) {
$response->setContentType($mimeType);
}
if ($format == 'json') {
$response->setContentType('text/javascript');
}
// By default, symfony set 'application/json' and the response is not show in the brower
$response->sendHttpHeaders();
$template = sprintf('error.%s.php', $format);
$path = dirname(__FILE__) . './../config/error/' . $template;
$type = get_class($exception);
$message = $exception->getMessage();
include $path;
return true;
}
}
示例2: contextLoadFactories
public function contextLoadFactories(sfEvent $event)
{
$context = $event->getSubject();
$context->response->addStylesheet('/css/classic', 'last', array('media' => 'all'));
$context->response->addStylesheet('/plugins/sfCaribouPlugin/css/style', 'last', array('media' => 'all'));
$context->response->addJavaScript('/plugins/sfCaribouPlugin/js/navigation', 'last');
}
示例3: filterValues
/**
* Filters form values before they're bound.
*
* Re-embeds all dynamically embedded relations to match up with the input values.
*
* @param sfEvent $event A "form.filter_values" event
* @param array $values Tainted form values
*/
public function filterValues(sfEvent $event, $values)
{
$form = $event->getSubject();
$this->reEmbed($form, $values);
$this->correctValidators($form);
return $values;
}
开发者ID:AUTOPLANNING,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:15,代码来源:sfDoctrineDynamicFormRelations.class.php
示例4: listenToRoutingLoadConfigurationEvent
/**
* Listens to the routing.load_configuration event.
*
* @param sfEvent An sfEvent instance
*/
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
{
$r = $event->getSubject();
// preprend our routes
$r->prependRoute('sf_guard_signin', new sfRoute('/login', array('module' => 'sfGuardAuth', 'action' => 'signin')));
$r->prependRoute('sf_asset_library_dir', new sfRoute('/sfAsset/dir/:dir', array('module' => 'sfAsset', 'action' => 'list', 'dir' => sfConfig::get('app_sfAssetsLibrary_upload_dir', 'media')), array('dir' => '.*?')));
}
示例5: run
public function run(sfEvent $event)
{
$record = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->getRecordInstance();
$this->_dispatcher->notify(new sfEvent($record, 'sympal.user.set_table_definition', array('object' => $record)));
$this->_symfonyContext = $event->getSubject();
$this->_invoker->setCache(new sfSympalCache($this->_invoker));
$this->_invoker->setSymfonyContext($this->_symfonyContext);
$this->_sympalContext = sfSympalContext::createInstance($this->_symfonyContext, $this->_invoker);
$this->_invoker->setSympalContext($this->_sympalContext);
$this->_enableModules();
$this->_checkInstalled();
$this->_invoker->initializeTheme();
$helpers = array('Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N', 'Asset', 'Url', 'Partial');
if ($this->_invoker->isAdminModule()) {
sfConfig::set('sf_login_module', 'sympal_admin');
$helpers[] = 'Admin';
}
$this->_invoker->getProjectConfiguration()->loadHelpers($helpers);
$this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
new sfSympalContextLoadFactoriesListener($this->_dispatcher, $this->_invoker);
new sfSympalComponentMethodNotFoundListener($this->_dispatcher, $this->_invoker);
new sfSympalControllerChangeActionListener($this->_dispatcher, $this->_invoker);
new sfSympalTemplateFilterParametersListener($this->_dispatcher, $this->_invoker);
new sfSympalFormMethodNotFoundListener($this->_dispatcher, $this->_invoker);
new sfSympalFormPostConfigureListener($this->_dispatcher, $this->_invoker);
new sfSympalFormFilterValuesListener($this->_dispatcher, $this->_invoker);
}
示例6: listenToCommandPostCommandEvent
public static function listenToCommandPostCommandEvent(sfEvent $event)
{
$task = $event->getSubject();
if ($task->getFullName() === 'apostrophe:migrate') {
self::migrate();
}
}
示例7: configureDoctrineConnection
public function configureDoctrineConnection(sfEvent $event)
{
$parameters = $event->getParameters();
if ('doctrine2' === $parameters['connection']->getName()) {
$parameters['connection']->setAttribute(Doctrine_Core::ATTR_VALIDATE, false);
}
}
示例8: listenToRoutingAdminLoadConfigurationEvent
public static function listenToRoutingAdminLoadConfigurationEvent(sfEvent $event)
{
$r = $event->getSubject();
$enabledModules = array_flip(sfConfig::get('sf_enabled_modules', array()));
if (isset($enabledModules['aUserAdmin'])) {
$r->prependRoute('a_user_admin', new sfDoctrineRouteCollection(array('name' => 'a_user_admin', 'model' => 'sfGuardUser', 'module' => 'aUserAdmin', 'prefix_path' => 'admin/user', 'column' => 'id', 'with_wildcard_routes' => true)));
}
if (isset($enabledModules['aGroupAdmin'])) {
$r->prependRoute('a_group_admin', new sfDoctrineRouteCollection(array('name' => 'a_group_admin', 'model' => 'sfGuardGroup', 'module' => 'aGroupAdmin', 'prefix_path' => 'admin/group', 'column' => 'id', 'with_wildcard_routes' => true)));
}
if (isset($enabledModules['aPermissionAdmin'])) {
$r->prependRoute('a_permission_admin', new sfDoctrineRouteCollection(array('name' => 'a_permission_admin', 'model' => 'sfGuardPermission', 'module' => 'aPermissionAdmin', 'prefix_path' => 'admin/permission', 'column' => 'id', 'with_wildcard_routes' => true)));
}
// Used by apostrophe:deploy to clear the APC cache, needs a consistent path
if (isset($enabledModules['aSync'])) {
$r->prependRoute('a_sync', new sfRoute('/async/:action', array('module' => 'aSync', 'url' => '/async/:action')));
}
// Right now the admin engine isn't terribly exciting,
// it just redirects away from the /admin page that belongs to it.
// Longer URLs starting with /admin are left alone as they often belong
// to non-engine modules like the users module
if (isset($enabledModules['aAdmin'])) {
$r->prependRoute('a_admin', new aRoute('/', array('module' => 'aAdmin', 'action' => 'index', 'url' => '/')));
}
}
示例9: listenToContextLoadedEvent
public function listenToContextLoadedEvent(sfEvent $e)
{
$this->setBrowser($e->getSubject()->get('browser'));
if (!$e->getSubject()->getI18n()->cultureExists($this->getCulture())) {
$this->setCulture(sfConfig::get('sf_default_culture'));
}
}
示例10: listenToRoutingLoadConfigurationEvent
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
{
$routing = $event->getSubject();
$routing->prependRoute('image_nodefaults', new sfRoute('/image/*', array('module' => 'default', 'action' => 'error')));
$routing->prependRoute('image', new sfRoute('/cache/img/:format/:width_:height/:filename.:noice', array('module' => 'image', 'action' => 'index', 'width' => 'w', 'height' => 'h'), array('filename' => '^[\\w\\d_\\.\\-]+$', 'format' => '^(jpg|png|gif)$', 'width' => '^w[0-9]*$', 'height' => '^h[0-9]*$', 'noice' => '^(jpg|png|gif)$'), array('segment_separators' => array('_', '/', '.'), 'variable_regex' => '[a-zA-Z0-9]+')));
$routing->prependRoute('image_with_suffix', new sfRoute('/cache/img/:format/:width_:height_:suffix/:filename.:noice', array('module' => 'image', 'action' => 'index', 'width' => 'w', 'height' => 'h'), array('filename' => '^[\\w\\d_\\.\\-]+$', 'format' => '^(jpg|png|gif)$', 'width' => '^w[0-9]*$', 'height' => '^h[0-9]*$', 'suffix' => 'sq', 'noice' => '^(jpg|png|gif)$'), array('segment_separators' => array('_', '/', '.'), 'variable_regex' => '[a-zA-Z0-9]+')));
}
示例11: processApplicationConfirm
public function processApplicationConfirm(sfEvent $event)
{
$app = sfConfig::get('sf_app');
$invite = Doctrine::getTable('ApplicationInvite')->find($event['id']);
if (!$invite) {
return false;
}
$application = $invite->getApplication();
if ('pc_frontend' === $app) {
if (!$application->getIsPc()) {
return false;
}
} elseif ('mobile_frontend' === $app) {
if (!$application->getIsMobile()) {
return false;
}
}
if ($event['is_accepted']) {
$action = $event->getSubject();
if ($action instanceof sfAction) {
$action->redirect('@application_add?id=' . $application->getId() . '&invite=' . $invite->getId());
}
} else {
$invite->delete();
$event->setReturnValue("You have just rejected request of invitation to app.");
}
return true;
}
示例12: listenToRoutingLoadConfigurationEvent
/**
* Listens to the routing.load_configuration event.
*
* @param sfEvent An sfEvent instance
*/
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
{
$r = $event->getSubject();
// preprend our routes
// $r->prependRoute('download_packed_files','/packed/:type/:cachefilename/packed.*', array( 'module' => 'sfCombineFilter', 'action' => 'download', 'target_action' => 'index'));
$r->prependRoute('download_packed_files', new sfRoute('/packed/:type/:cachefilename/packed.*', array('module' => 'sfCombineFilter', 'action' => 'download', 'target_action' => 'index')));
}
示例13: SendExceptionNotify
public static function SendExceptionNotify(sfEvent $event)
{
$routing = sfContext::getInstance()->getRouting();
$uri = $routing->getCurrentInternalUri();
$text = 'Ошибка: ' . $event->getSubject()->getMessage() . ' по адресу ' . $uri;
sfJabber::SendMessage($text);
}
示例14: configure
/**
* configure - configures the routing when main project will load it
*
* @listen routing.load_configuration
*
* @param sfEvent $e
* @return void
*/
public static function configure(sfEvent $event)
{
self::checkSymfonyVersion();
$routing = $event->getSubject();
$prefix = self::getBaseRoute();
self::addRoute($routing, 'asset', $prefix . '/:name', array('module' => 'sfDynamics', 'action' => 'asset'), array(), array('segment_separators' => array('/')));
}
示例15: listenToRoutingLoadConfigurationEvent
/**
* Listens to the routing.load_configuration event.
*
* @param sfEvent An sfEvent instance
*/
public static function listenToRoutingLoadConfigurationEvent(sfEvent $event)
{
$routing = $event->getSubject();
$config = sfConfig::get('app_swToolbox_cross_link_application', array());
if (!sfContext::hasInstance() || !$routing instanceof swPatternRouting) {
return;
}
$configuration = sfContext::getInstance()->getConfiguration();
$env = $configuration->getEnvironment();
$app = $configuration->getApplication();
if (!array_key_exists('enabled', $config[$app]) || !$config[$app]['enabled']) {
return;
}
if (!array_key_exists('load', $config[$app]) || !is_array($config[$app]['load'])) {
return;
}
foreach ($config[$app]['load'] as $app_to_load => $options) {
$envs = $options['env'];
$routes = isset($options['routes']) && is_array($options['routes']) ? $options['routes'] : array();
if (!array_key_exists($env, $envs)) {
continue;
}
$config_handler = new swCrossApplicationRoutingConfigHandler();
$config_handler->setApp($app_to_load);
$config_handler->setHost($envs[$env]);
$config_handler->setRoutes($routes);
$routes = $config_handler->evaluate(array(sfConfig::get('sf_apps_dir') . '/' . $app_to_load . '/config/routing.yml'));
foreach ($routes as $name => $route) {
$routing->appendRoute($name, $route);
}
}
}