public static function listenToRoutingLoadConfigurationEvent(sfEvent $event) { $event->getSubject()->prependRoute('izarus_advanced_layout_customize', new sfRoute('/customize/modules', array('module' => 'izarusAdvancedCustomize', 'action' => 'index'))); $event->getSubject()->prependRoute('izarus_advanced_layout_users', new sfRoute('/customize/permissions', array('module' => 'izarusAdvancedCustomize', 'action' => 'permissions'))); $event->getSubject()->prependRoute('izarus_advanced_layout_lateral', new sfRoute('/customize/lateral', array('module' => 'izarusAdvancedCustomize', 'action' => 'lateral'))); $event->getSubject()->prependRoute('izarus_advanced_layout_select_profile', new sfRoute('/p', array('module' => 'izarusAdvancedCustomize', 'action' => 'selectProfile'))); }
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')); } }
/** * Clears the super cache by listening to the task.cache.clear event. * * @param sfEvent An sfEvent instance */ public static function clearCache(sfEvent $event) { $config = sfFilterConfigHandler::getConfiguration($event['app']->getConfigPaths('config/filters.yml')); $event->getSubject()->logSection('cache', 'Clearing super cache'); // find super cache configuration $found = false; $cacheDir = 'cache'; foreach ($config as $value) { if ('sfSuperCacheFilter' == $value['class']) { $found = true; if (isset($value['param']['cache_dir'])) { $cacheDir = $value['param']['cache_dir']; } break; } } if ($found) { // clear the cache $cacheDir = sfConfig::get('sf_web_dir') . '/' . $cacheDir; if (is_dir($cacheDir)) { // remove cache files $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir)); } } }
/** * Listens to routing.load_configuration * * @param sfEvent $event The routing.load_configuration event * @return void */ public function loadRoutes(sfEvent $event) { $prefix = sfConfig::get('app_doctrine_menu_module_prefix', '/admin/menu'); $event->getSubject()->prependRoute('io_doctrine_menu', new sfDoctrineRouteCollection(array('name' => 'io_doctrine_menu', 'model' => 'ioDoctrineMenuItem', 'module' => 'io_doctrine_menu', 'prefix_path' => $prefix, 'with_wildcard_routes' => true, 'collection_actions' => array(), 'requirements' => array()))); $event->getSubject()->prependRoute('io_doctrine_menu_reorder', new sfDoctrineRoute($prefix . '/reorder/:id', array('module' => 'io_doctrine_menu', 'action' => 'reorder'), array('sf_method' => array('get')), array('model' => 'ioDoctrineMenuItem', 'type' => 'object'))); $event->getSubject()->prependRoute('io_doctrine_menu_reorder_json', new sfDoctrineRoute($prefix . '/reorder/json/:id', array('module' => 'io_doctrine_menu', 'action' => 'json', 'sf_format' => 'json'), array('sf_method' => array('get')), array('model' => 'ioDoctrineMenuItem', 'type' => 'object'))); $event->getSubject()->prependRoute('io_doctrine_menu_reorder_save', new sfDoctrineRoute($prefix . '/reorder/save/:id', array('module' => 'io_doctrine_menu', 'action' => 'saveJson'), array('sf_method' => array('post')), array('model' => 'ioDoctrineMenuItem', 'type' => 'object'))); }
public function run(sfEvent $event) { $event->getSubject()->logSection('sympal', 'Clearing web cache folder'); $cacheDir = sfConfig::get('sf_web_dir') . '/cache'; if (is_dir($cacheDir)) { $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir)); } }
/** * Listens to the routing.load_configuration event. * * @param sfEvent An sfEvent instance * @static */ public static function listenToRoutingLoadConfigurationEvent(sfEvent $event) { // preprend our routes if (sfConfig::get('app_vkontakte_enable_register_routes')) { $event->getSubject()->prependRoute('sf_vkontakte_fetch_profiles', new sfRoute('/sf_vkontakte_fetch_profiles', array('module' => 'sfVkontakteFetch', 'action' => 'profiles'))); $event->getSubject()->prependRoute('sf_vkontakte_upload_photo', new sfRoute('/sf_vkontakte_upload_photo', array('module' => 'sfVkontakteFetch', 'action' => 'uploadPhoto'))); } }
static public function addRoute(sfEvent $event) { $event->getSubject()->prependRoute('sf_jquery_form_validation', new sfRoute('/sfJqueryFormVal/:form', array('module' => 'sfJqueryFormVal', 'action' => 'index'))); $event->getSubject()->prependRoute('sf_jquery_form_remote', new sfRoute('/sfJqueryFormVal/remote/:form/:validator', array('module' => 'sfJqueryFormVal', 'action' => 'remote'))); }
static function userSignedInListener(sfEvent $event) { $user = $event->getSubject()->getUser(); if ($user->hasAttribute('user.signed_in.continue_url') && $user->getAttribute('user.signed_in.continue_url')) { $url = $user->getAttribute('user.signed_in.continue_url'); $user->setAttribute('user.signed_in.continue_url', false); $event->getSubject()->redirect($url); } }
public function listenToContextLoadedEvent(sfEvent $e) { if ($this->configuration instanceof dmAdminApplicationConfiguration) { $e->getSubject()->getResponse()->addJavascript('dmCkEditorPlugin.adminLauncher')->addStylesheet('dmCkEditorPlugin.adminStyle'); } /* * Add ckeditor.js & jquery.js to javascript compressor black list */ $e->getSubject()->get('javascript_compressor')->addToBlackList(array('ckeditor.js', 'jquery.js')); }
/** * Listens to the sympal.load event */ public function bootstrap(sfEvent $event) { $this->_sympalContext = $event->getSubject(); $event->getSubject()->getApplicationConfiguration()->loadHelpers('SympalMenu'); // Listen to sfSympalContent's change_content event $this->dispatcher->connect('sympal.content.set_content', array($event->getSubject()->getService('menu_manager'), 'listenContentSetContent')); // extend the component/action class $actions = new sfSympalMenuActions(); $this->dispatcher->connect('component.method_not_found', array($actions, 'extend')); }
/** * clearSuperCache - clear supercache of minified assets * * @listen task.cache.clear * * @param sfEvent $event * @return void */ public static function clearSuperCache(sfEvent $event) { static $done = false; /* symfony send the task.cache.clear event once by app. */ if (!$done) { $event->getSubject()->logSection('cache', 'Clearing sfDynamicsPlugin minified assets super cache'); if (is_dir($cacheDir = self::getSuperCacheDir(true))) { $event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard(array('.sf', '.htaccess'))->in($cacheDir)); } $done = true; } }
public function listenToSetupAfterEvent(sfEvent $event) { $this->cleanupUploads($event->getSubject()->getFilesystem()); dmDb::table('DmMediaFolder')->checkRoot()->sync(); dmDb::table('DmPage')->checkBasicPages(); if (!sfConfig::get('dm_test_project_built') && $event['clear-db']) { $event->getSubject()->getContext()->get('filesystem')->sf('my:project-builder'); } copy(dmOs::join(sfConfig::get('sf_data_dir'), 'db.sqlite'), dmOs::join(sfConfig::get('sf_data_dir'), 'fresh_db.sqlite')); $this->removeWebSymlinks(); sfConfig::set('dm_test_project_built', true); }
static public function addRouteForNestedCommentAdmin(sfEvent $event) { $event->getSubject()->prependRoute('sf_nested_comment', new sfPropelORMRouteCollection(array( 'name' => 'sf_nested_comment', 'model' => 'sfNestedComment', 'module' => 'sfNestedCommentAdmin', 'prefix_path' => 'sf_nested_comment', 'with_wildcard_routes' => true, 'requirements' => array(), ))); $event->getSubject()->prependRoute('sf_nested_comment_toggle_publish', new sfPropelORMRoute('/sf_nested_comment/:id/toggleApprove.:sf_format', array('module' => 'sfNestedCommentAdmin', 'action' => 'togglePublish', 'sf_format' => 'html'), array(), array('model' => 'sfNestedComment', 'type' => 'object'))); }
/** * Automatic plugin modules and helper loading * * @param sfEvent $event */ public function listenToContextLoadFactories(sfEvent $event) { // Enable module automatically sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), array('ioEditableContent'))); // Load helper as well $event->getSubject()->getConfiguration()->loadHelpers(array('EditableContent')); // create the editable content service $this->_editableContentService = $this->_createEditableContentService($event->getSubject()->getUser()); // load the editor assets if ($this->_editableContentService->shouldShowEditor()) { $this->_loadEditorAssets($event->getSubject()); } }
public static function handleEvent(sfEvent $event) { switch ($event->getName()) { case 'paypal.ipn_success': $transaction = $event->getSubject(); $message = sprintf('IPN Success | Reservation: %s', $transaction->parent_id); self::notifyPaypalEvent($message, $event['ipn_data']); break; case 'paypal.ipn_error': $message = sprintf('IPN Error | %s', $event->getSubject()); self::notifyPaypalEvent($message, $event['ipn_data']); break; } }
public function listenToDmContextLoaded(sfEvent $e) { if ($e->getSubject()->getUser()->can('admin')) { // do not use a CDN if logged as an admin return; } if ($this->configuration instanceof dmFrontApplicationConfiguration) { if (sfConfig::get('app_rackspace_enabled')) { $this->dispatcher->connect('dm.layout.filter_stylesheets', array($this, 'listenToFilterAssetsEvent')); $this->dispatcher->connect('dm.layout.filter_javascripts', array($this, 'listenToFilterAssetsEvent')); } $this->container = $e->getSubject()->getServiceContainer(); $this->dispatcher->connect('dm.asset_compressor.create_cache', array($this, 'listenToAssetCompressorCreateCacheEvent')); } }
/** * Enable/Disable the twss * * @param sfEvent $event */ public function enableOrDisableTwss(sfEvent $event) { if (in_array($event->getSubject()->getUsername(), $this->getContainer()->getParameter('users.trusted'))) { $p = strtolower($event->getSubject()->getTriggerParams()); if ($p == 'on') { $this->log('TWSS Enabled'); $this->enabled = true; } else { if ($p == 'off') { $this->log('TWSS Disabled'); $this->enabled = false; } } } }
/** * Listens to the routing.load_configuration event. * * @param sfEvent An sfEvent instance * @static */ public static function listenToRoutingLoadConfigurationEvent(sfEvent $event) { $r = $event->getSubject(); // preprend our routes $r->prependRoute('knp_sso_signin', new sfRoute('/sso/login', array('module' => 'knpSsoAuth', 'action' => 'signin'))); $r->prependRoute('knp_sso_signout', new sfRoute('/sso/logout', array('module' => 'knpSsoAuth', 'action' => 'signout'))); }
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'); }
public function run(sfEvent $event, $content) { // The following were removed, but should probably be there //$request->isXmlHttpRequest() //$controller->getRenderMode() != sfView::RENDER_CLIENT || $response = $event->getSubject(); if (strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || in_array($response->getStatusCode(), array(302, 301)) || $response->isHeaderOnly()) { return $content; } if ($code = sfSympalConfig::get('google_analytics_code')) { $js = <<<EOF <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); \tdocument.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { \tvar pageTracker = _gat._getTracker("{$code}"); \tpageTracker._trackPageview(); } catch(err) {}</script> EOF; return str_replace('</body>', $js . '</body>', $content); } else { return $content; } }
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); }
public function listenToThrowException(sfEvent $event) { try { if ($this->getOption('mail_superadmin') || $this->getOption('store_in_db')) { $error = new $this->options['error_description_class']($event->getSubject(), $this->context); if ($this->getOption('mail_superadmin')) { $this->mailSuperadmin($error); } if ($this->getOption('store_in_db')) { $this->storeInDb($error); } } } catch (Exception $e) { die(sprintf('Exception %s thrown while notifying exception %s', $e, $event->getSubject())); } }
/** * 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' => '.*?'))); }
/** * Automatic plugin modules and helper loading * * @param sfEvent $event */ public function listenToContextLoadFactories(sfEvent $event) { // Enable module automatically sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), array('sfEditableComponent'))); // Load helper as well $event->getSubject()->getConfiguration()->loadHelpers(array('sfEditable')); }
public static function listenToMediaLibraryControlMenuEvent(sfEvent $event) { /** @var dmMediaLibraryControlMenu */ $media_library_menu = $event->getSubject(); $media_library_menu->addChild($media_library_menu->getI18n()->__('Add multiple files'), $media_library_menu->getHelper()->link('+/dmMediaUploadifyerAdmin/newMultipleFile?folder_id=' . $event['folder']->id)->set('.new_multiple_file.uploadify_dialog_me.s16.s16_file_add'))->end(); dmContext::getInstance()->getResponse()->addJavascript('dmMediaUploadifyerPlugin.adminCtrl'); }
/** * 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); } } }
public static function listenToCommandPostCommandEvent(sfEvent $event) { $task = $event->getSubject(); if ($task->getFullName() === 'apostrophe:migrate') { self::migrate(); } }
/** * 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; }
/** * Listens to the response.filter_content event. * * @param sfEvent $event The sfEvent instance * @param string $context The response content * * @return string The filtered response content */ public function filterResponseContent(sfEvent $event, $content) { if (!sfConfig::get('sf_web_debug')) { return $content; } // log timers information $messages = array(); foreach (sfTimerManager::getTimers() as $name => $timer) { $messages[] = sprintf('%s %.2f ms (%d)', $name, $timer->getElapsedTime() * 1000, $timer->getCalls()); } $this->dispatcher->notify(new sfEvent($this, 'application.log', $messages)); // don't add debug toolbar: // * for XHR requests // * if 304 // * if not rendering to the client // * if HTTP headers only $response = $event->getSubject(); if (!$this->context->has('request') || !$this->context->has('response') || !$this->context->has('controller') || $this->context->getRequest()->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $this->context->getController()->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) { return $content; } // add needed assets for the web debug toolbar $root = $this->context->getRequest()->getRelativeUrlRoot(); $assets = sprintf(' <script type="text/javascript" src="%s"></script> <link rel="stylesheet" type="text/css" media="screen" href="%s" />', $root . sfConfig::get('sf_web_debug_web_dir') . '/js/main.js', $root . sfConfig::get('sf_web_debug_web_dir') . '/css/main.css'); $content = str_ireplace('</head>', $assets . '</head>', $content); // add web debug information to response content $webDebugContent = $this->webDebug->getResults(); $count = 0; $content = str_ireplace('</body>', $webDebugContent . '</body>', $content, $count); if (!$count) { $content .= $webDebugContent; } return $content; }
/** * Adds routes for the kdGuardAuthFacebookConnect plugin. * * @param sfEvent $event */ static public function addRouteForkdGuardAuthFacebookConnect(sfEvent $event) { $r = $event->getSubject(); $r->prependRoute('kd_guard_signin', new sfRoute('/guard/fb_signin', array('module' => 'kdGuardAuthFacebookConnect', 'action' => 'signin'))); $r->prependRoute('kd_guard_signout', new sfRoute('/guard/fb_signout', array('module' => 'kdGuardAuthFacebookConnect', 'action' => 'signout'))); }