示例#1
0
 /**
  * Combine multiple text assets into a single file for better http performance this
  * method generates a new cache file with every symfony cc you can override the cache
  * by adding ?clearassetcache=1 to the page request.
  *
  * @param type      string css or js
  * @param namespace string the combined file namespace (eg. module+action names)
  * @param response  object the sfWebResponse instance
  * @return          string the url for the combiner service
  */
 public function combine($type, $namespace, sfWebResponse $response)
 {
     //configure the combiner
     $type = $type === 'css' ? 'css' : 'js';
     $fullname = $type === 'css' ? 'Stylesheets' : 'Javascripts';
     $response_getter = 'get' . $fullname;
     $namespace = StreemeUtil::slugify($namespace);
     //integrate into symfony's asset globals
     sfConfig::set(sprintf('symfony.asset.%s_included', strtolower($fullname)), true);
     //build the cache filename - this file will be regenerated on a symfony cc
     $path = sprintf('%s/combine/%s/', sfConfig::get('sf_cache_dir'), $type);
     $filename = sprintf('%s.%s', $namespace, $type);
     // you can force a cache clear by passing ?clearassetcache=1 to any template
     if (!is_readable($path . $filename) || @$_GET['clearassetcache'] == 1) {
         //build one file of all of the css or js files
         $file_content = '';
         //load vendor libraries for minifying assets
         require_once sfConfig::get('sf_lib_dir') . '/vendor/jsmin/jsmin.php';
         require_once sfConfig::get('sf_lib_dir') . '/vendor/cssmin/cssmin.php';
         foreach ($response->{$response_getter}() as $file => $options) {
             if ($type === 'css') {
                 $file_content .= CSSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
             } else {
                 $file_content .= JSMin::minify(file_get_contents(sfConfig::get('sf_web_dir') . $file));
             }
         }
         //this file resides in the cache and requires wide permissions for both cli and apache users
         @umask(00);
         @mkdir($path, 0777, true);
         file_put_contents($path . $filename, $file_content);
     }
     return sprintf('/service/combine/%s/%s', $type, str_replace('-', '_', $namespace));
 }
 public function initialize()
 {
     $enabledModules = sfConfig::get('sf_enabled_modules');
     if (is_array($enabledModules)) {
         sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules'), array('oauth')));
     }
 }
 protected function setNavigation(Member $member)
 {
     if ($member->getId() !== $this->getUser()->getMemberId()) {
         sfConfig::set('sf_nav_type', 'friend');
         sfConfig::set('sf_nav_id', $member->getId());
     }
 }
示例#4
0
 public function executeShow(sfWebRequest $request)
 {
     $p = $request->getParameter('page', 'unavailable');
     $this->title = sfConfig::get('app_message_with_layout_' . $p . '_title');
     $this->text = sfConfig::get('app_message_with_layout_' . $p . '_text');
     sfConfig::set('sf_web_debug', false);
 }
 public function execute($filterChain)
 {
     $context = $this->getContext();
     $request = $context->getRequest();
     if (jfPortableDevice::isPortableDevice()) {
         $layout = isset(self::$_layout) ? self::$_layout : $this->getParameter('layout');
         $context->getActionStack()->getFirstEntry()->getActionInstance()->setLayout($layout);
         if (class_exists('sfWidgetFormSchema')) {
             // compatibility with symfony 1.0
             sfWidgetFormSchema::setDefaultFormFormatterName($this->getParameter('defaultFormFormatterName', 'jfPD'));
         }
         jfPortableDevice::setPageAttribute('data-url', $request->getUri());
     }
     $filterChain->execute();
     if (jfPortableDevice::isPortableDevice()) {
         if (jfPortableDevice::getConfig('lazyLoadImages')) {
             $response = $context->getResponse();
             $content = $response->getContent();
             $content = preg_replace('/(<img.*)(src=)([\'|\\"].*>)/', '$1data-jfPD-src=$3', $content);
             $response->setContent($content);
         }
         if (jfPortableDevice::isNativeApp()) {
             sfConfig::set('sf_web_debug', false);
         }
     }
 }
 public function initialize()
 {
     if (class_exists('sfPlop')) {
         sfPlop::loadPlugin(array('slots' => array('GoogleMaps' => 'GoogleMaps map', 'GoogleMapsFilter' => 'GoogleMaps filter', 'GoogleMapsPosition' => 'GoogleMaps position')));
     }
     sfConfig::set('sf_plop_googlemaps_zooms', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
 }
示例#7
0
 /**
  * Executes search action
  *
  * @param sfWebRequest $request a request object
  */
 public function executeSearch(sfWebRequest $request)
 {
     sfConfig::set('sf_nav_type', 'default');
     $params = $request->getParameter('community', array());
     $this->isResult = false;
     $this->category_id = 0;
     if (isset($params['name'])) {
         $params['name'] = $params['name'];
         $this->isResult = true;
     }
     if (isset($params['community_category_id'])) {
         $this->category_id = $params['community_category_id'];
         $params['community_category_id'] = $this->category_id;
         $this->isResult = true;
     }
     $this->filters = new CommunityFormFilter();
     $this->filters->bind($params);
     $q = $this->filters->getQuery()->orderBy('id desc');
     $this->pager = new sfDoctrinePager('Community', 10);
     $this->pager->setQuery($q);
     $this->pager->setPage($request->getParameter('page', 1));
     $this->pager->init();
     $this->categorys = Doctrine::getTable('CommunityCategory')->createQuery()->where('lft > 1')->execute();
     return sfView::SUCCESS;
 }
 protected function handleAction($filterChain, $actionInstance)
 {
     $moduleName = $actionInstance->getModuleName();
     $actionName = $actionInstance->getActionName();
     $request = $actionInstance->getRequest();
     if ($request->needToRedirectToSoftBankGateway()) {
         $request->redirectToSoftBankGateway();
     }
     $this->handleSsl($actionInstance);
     $dispatcher = sfContext::getInstance()->getEventDispatcher();
     // sfDoctrinePlugin needs to notify this event for enabling i18n
     $dispatcher->notify(new sfEvent($this, 'user.change_culture', array('culture' => sfContext::getInstance()->getUser()->getCulture())));
     self::notifyPreExecuteActionEvent($this, $dispatcher, $actionInstance);
     Doctrine::getTable('SnsTerm')->configure(sfContext::getInstance()->getUser()->getCulture(), sfConfig::get('sf_app'));
     if (sfConfig::has('op_is_use_captcha')) {
         sfConfig::set('op_is_use_captcha', opConfig::get('is_use_captcha'));
     }
     try {
         $result = parent::handleAction($filterChain, $actionInstance);
     } catch (opRuntimeException $e) {
         $this->forwardToErrorAction();
     } catch (sfValidatorErrorSchema $e) {
         if (isset($e['_csrf_token'])) {
             $this->forwardToCSRFErrorAction();
         }
         throw $e;
     }
     self::notifyPostExecuteActionEvent($this, $dispatcher, $actionInstance, $result);
     return $result;
 }
 /**
  * List unassigned currencies for given employee and pay grade
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->setLayout(false);
     sfConfig::set('sf_web_debug', false);
     sfConfig::set('sf_debug', false);
     $currencies = array();
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     }
     $payGrade = $request->getParameter('paygrade');
     $empNumber = $request->getParameter('empNumber');
     if (!empty($payGrade) && !empty($empNumber)) {
         $employeeService = $this->getEmployeeService();
         // TODO: call method that returns data in array format (or pass parameter)
         $currencies = $employeeService->getAssignedCurrencyList($payGrade, true);
     } else {
         //
         // Return full currency list
         //
         $currencyService = $this->getCurrencyService();
         $currencies = $currencyService->getCurrencyList(true);
     }
     $currencyArray = array();
     foreach ($currencies as $currency) {
         $currency['currency_name'] = __($currency['currency_name']);
         $currencyArray[] = $currency;
     }
     return $this->renderText(json_encode($currencyArray));
 }
 protected function executeGenerate($arguments = array(), $options = array())
 {
     // generate module
     $tmpDir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . md5(uniqid(rand(), true));
     sfConfig::set('sf_module_cache_dir', $tmpDir);
     $generatorManager = new sfGeneratorManager($this->configuration);
     $generatorManager->generate('sfPropelCrudGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'], 'non_atomic_actions' => $options['non-atomic-actions'], 'non_verbose_templates' => $options['non-verbose-templates'], 'with_show' => $options['with-show']));
     $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module'];
     // copy our generated module
     $this->getFilesystem()->mirror($tmpDir . '/auto' . ucfirst($arguments['module']), $moduleDir, sfFinder::type('any'));
     if (!$options['with-show']) {
         $this->getFilesystem()->remove($moduleDir . '/templates/showSuccess.php');
     }
     // change module name
     $this->getFilesystem()->replaceTokens($moduleDir . '/actions/actions.class.php', '', '', array('auto' . ucfirst($arguments['module']) => $arguments['module']));
     // customize php and yml files
     $finder = sfFinder::type('file')->name('*.php', '*.yml');
     $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants);
     // create basic test
     $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . '/task/generator/skeleton/module/test/actionsTest.php', sfConfig::get('sf_test_dir') . '/functional/' . $arguments['application'] . '/' . $arguments['module'] . 'ActionsTest.php');
     // customize test file
     $this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir') . '/functional/' . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php', '##', '##', $this->constants);
     // delete temp files
     $this->getFilesystem()->remove(sfFinder::type('any')->in($tmpDir));
 }
 function createContext()
 {
     $context = sfContext::getInstance(array('request' => 'sfWebRequest', 'response' => 'sfWebResponse'), true);
     $context->configuration = new ApplicationConfigurationMock();
     sfConfig::set('sf_standard_helpers', array('Text'));
     return $context;
 }
 public function execute($request)
 {
     sfConfig::set('sf_web_debug', false);
     sfConfig::set('sf_debug', false);
     $leaveId = $request->getParameter("leaveId");
     $leaveRequestId = $request->getParameter('leaveRequestId');
     $comments = array();
     $leaveRequestService = $this->getLeaveRequestService();
     if (!empty($leaveRequestId)) {
         $comments = $leaveRequestService->getLeaveRequestComments($leaveRequestId);
     } else {
         if (!empty($leaveId)) {
             $comments = $leaveRequestService->getLeaveComments($leaveId);
         }
     }
     $returnData = array();
     if (count($comments) > 0) {
         foreach ($comments as $comment) {
             $commentDate = new DateTime($comment->getCreated());
             $row['date'] = set_datepicker_date_format($commentDate->format('Y-m-d'));
             $row['time'] = $commentDate->format('H:i');
             $row['author'] = $comment->getCreatedByName();
             $row['comments'] = $comment->getComments();
             $returnData[] = $row;
         }
     }
     $response = $this->getResponse();
     $response->setHttpHeader('Expires', '0');
     $response->setHttpHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0, max-age=0");
     $response->setHttpHeader("Cache-Control", "private", false);
     return $this->renderText(json_encode($returnData));
 }
 /**
  *
  * @param <type> $request
  * @return <type>
  */
 public function execute($request)
 {
     $this->setLayout(false);
     sfConfig::set('sf_web_debug', false);
     sfConfig::set('sf_debug', false);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     }
     $userRoleManager = $this->getContext()->getUserRoleManager();
     $mode = $request->getParameter('mode');
     $dataGroupName = $mode == self::MODE_CANDIDATES ? 'recruitment_candidates' : 'recruitment_vacancies';
     $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array($dataGroupName => new ResourcePermission(true, false, false, false)));
     $allowedVacancyList = $userRoleManager->getAccessibleEntityIds('Vacancy', null, null, array(), array(), $requiredPermissions);
     $jobTitle = $request->getParameter('jobTitle');
     $vacancyService = new VacancyService();
     $vacancyList = $vacancyService->getVacancyListForJobTitle($jobTitle, $allowedVacancyList, true);
     $newVacancyList = array();
     foreach ($vacancyList as $vacancy) {
         if ($vacancy['status'] == JobVacancy::CLOSED) {
             $vacancy['name'] = $vacancy['name'] . " (Closed)";
         }
         $newVacancyList[] = $vacancy;
     }
     return $this->renderText(json_encode($newVacancyList));
 }
 /**
  * Executes index action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     //definition
     $service = self::getZendGdata();
     $Id = $this->getRequestParameter('id');
     $member_id = isset($Id) ? $Id : $this->getUser()->getMemberId();
     $memberS = Doctrine::getTable('Member')->find($member_id);
     if (!$memberS) {
         return sfView::ERROR;
     }
     if ($member_id !== $this->getUser()->getMemberId()) {
         sfConfig::set('sf_nav_type', 'friend');
         sfConfig::set('sf_nav_id', $member_id);
     }
     $this->member_name = $memberS->getName();
     $memberSpreadSheetKey = self::getMemberMasterSpreadSheetKey($service, $member_id);
     $domain = null;
     if (!is_null(opConfig::get('op_kintai_apps_domain', null))) {
         $domain = 'a/' . opConfig::get('op_kintai_apps_domain') . '/';
     }
     $this->member_splink = "https://docs.google.com/" . $domain . "spreadsheet/ccc?key=" . $memberSpreadSheetKey . "&hl=ja";
     $memberEditableKey = self::getMemberSpreadSheetKey($service, $member_id);
     if (!is_null($memberEditableKey)) {
         $this->member_editablelink = "https://docs.google.com/" . $domain . "spreadsheet/ccc?key=" . $memberEditableKey . "&hl=ja";
     } else {
         $this->member_editablelink = null;
     }
     $this->data = $data;
     $this->currentMember = $this->getUser()->getMemberId();
     $this->viewMember = $member_id;
     return sfView::SUCCESS;
 }
 /**
  * Initialize some sfConfig values for Sympal
  *
  * @return void
  */
 private function _initializeSymfonyConfig()
 {
     sfConfig::set('sf_cache', sfSympalConfig::get('page_cache', 'enabled', false));
     sfConfig::set('sf_default_culture', sfSympalConfig::get('default_culture', null, 'en'));
     sfConfig::set('sf_admin_module_web_dir', sfSympalConfig::get('admin_module_web_dir', null, '/sfSympalAdminPlugin'));
     sfConfig::set('app_sf_guard_plugin_success_signin_url', sfSympalConfig::get('success_signin_url'));
     if (sfConfig::get('sf_login_module') == 'default') {
         sfConfig::set('sf_login_module', 'sympal_auth');
         sfConfig::set('sf_login_action', 'signin');
     }
     if (sfConfig::get('sf_secure_module') == 'default') {
         sfConfig::set('sf_secure_module', 'sympal_auth');
         sfConfig::set('sf_secure_action', 'secure');
     }
     if (sfConfig::get('sf_error_404_module') == 'default') {
         sfConfig::set('sf_error_404_module', 'sympal_default');
         sfConfig::set('sf_error_404_action', 'error404');
     }
     if (sfConfig::get('sf_module_disabled_module') == 'default') {
         sfConfig::set('sf_module_disabled_module', 'sympal_default');
         sfConfig::set('sf_module_disabled_action', 'disabled');
     }
     sfConfig::set('sf_jquery_path', sfSympalConfig::get('jquery_reloaded', 'path'));
     sfConfig::set('sf_jquery_plugin_paths', sfSympalConfig::get('jquery_reloaded', 'plugin_paths'));
 }
function add_js_onload($jsStr, $position = 'last')
{
    static $countRun = 0;
    $delimiter = '//' . str_repeat('*', 40);
    $context = sfContext::getInstance();
    $cacheManager = $context->getViewCacheManager();
    $cacher = null;
    if ($cacheManager) {
        $cacher = $cacheManager->getCache();
        $cacheKey = sprintf('javascript.events.onload.%s.%s', $context->getModuleName(), $context->getActionName());
        if ($countRun > 0) {
            $oldStr = $cacher->get($cacheKey);
        } else {
            $oldStr = '';
        }
    } else {
        $oldStr = sfConfig::get('javascript.events.onload', '');
    }
    if ('last' == $position) {
        $newStr = $oldStr . "\r\n" . $delimiter . "\r\n" . $jsStr;
    } else {
        if ('first' == $position) {
            $newStr = $jsStr . "\r\n" . $delimiter . "\r\n" . $oldStr;
        }
    }
    if ($cacheManager) {
        $cacher->set($cacheKey, $newStr);
    } else {
        sfConfig::set('javascript.events.onload', $newStr);
    }
    $countRun++;
}
 /**
  * Executes first time
  */
  public function preExecute()
  {
    if (is_callable(array($this->getRoute(), 'getObject')))
    {
      $object = $this->getRoute()->getObject();
      if ($object instanceof Member)
      {
        $this->member = $object;
        $this->relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($this->getUser()->getMemberId(), $this->member->getId());
      }
    }

    if (empty($this->member))
    {
      $this->member = $this->getUser()->getMember();
    }

    $this->id = $this->member->id;

    if ($this->id != $this->getUser()->getMemberId())
    {
      sfConfig::set('sf_nav_type', 'friend');
    }

  }
示例#18
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     /*
     if($options['include'] != "" && $options['exclude'] != "")
     {
       throw new Exception("Only one option is authorized");
     }
     */
     if ($options['include'] != "") {
         $to_replace = split(",", $options['include']);
         sfConfig::set('app_sync_tables', $to_replace);
     }
     if ($options['exclude'] != "") {
         $tables = sfConfig::get('app_sync_tables');
         $excludes = split(",", $options['exclude']);
         foreach ($excludes as $exclude) {
             if (($key = array_search($exclude, $tables)) !== false) {
                 unset($tables[$key]);
             }
         }
         sfConfig::set('app_sync_tables', $tables);
     }
     $sync = new ServerVipSync($this->configuration);
     $sync->startSync();
 }
 public function initialize()
 {
     $enabledModules = sfConfig::get('sf_enabled_modules');
     if (!empty($enabledModules)) {
         sfConfig::set('sf_enabled_modules', array_merge($enabledModules, array('directory')));
     }
 }
示例#20
0
 public function preExecute()
 {
     parent::preExecute();
     if ($this->id == $this->getUser()->getMemberId()) {
         sfConfig::set('sf_nav_type', 'default');
     }
 }
示例#21
0
 /**
  * postExecute
  */
 public function postExecute()
 {
     if ($this->community instanceof Community) {
         sfConfig::set('sf_nav_type', 'community');
         sfConfig::set('sf_nav_id', $this->community->getId());
     }
 }
 /**
  * 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'));
 }
 /**
  * Executes filter chain
  *
  * @param sfFilterChain $filterChain
  */
 public function execute($filterChain)
 {
     if ($this->isFirstCall()) {
         $context = $this->getContext();
         $request = $context->getRequest();
         $response = $context->getResponse();
         $user = $context->getUser();
         $cookieName = sfConfig::get('app_translation_cookie', 'myCulture');
         //get the user's preferred browser language
         $culture = $request->getPreferredCulture(sfConfig::get('sf_translations_available', array()));
         $this->log(sprintf('Browser language is %s', $culture));
         //override with a user cookie language if it exists
         if ($request->getCookie($cookieName)) {
             $culture = $request->getCookie($cookieName);
             $this->log(sprintf('Overriding culture %s from culture cookie', $culture));
         }
         //has the user overridden the language manually?
         if ($request->getParameter('sf_culture') && in_array(strtolower($request->getParameter('sf_culture')), array_map('strtolower', sfConfig::get('sf_translations_available', array())))) {
             //set the language for this request, so you don't have to refresh
             $culture = $request->getParameter('sf_culture');
             //update the cookie with the new language for future requests
             $response->setCookie($cookieName, $culture, time() + 60 * 60 * 24 * 30 * 12 * 30, '/');
             $this->log(sprintf('Culture manually overridden to %s', $culture));
         }
         $this->log(sprintf('Applying culture: %s for this session', $culture));
         $user->setCulture($culture);
         sfConfig::set('sf_current_culture', $culture);
         $context->getResponse()->addMeta('language', $culture, true);
     }
     $filterChain->execute();
 }
 /**
  * @see sfPluginConfiguration
  */
 public function initialize()
 {
     sfConfig::set('sf_orm', 'doctrine');
     if (!sfConfig::get('sf_admin_module_web_dir')) {
         sfConfig::set('sf_admin_module_web_dir', '/sfDoctrinePlugin');
     }
     if (sfConfig::get('sf_web_debug')) {
         require_once dirname(__FILE__) . '/../lib/debug/sfWebDebugPanelDoctrine.class.php';
         $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelDoctrine', 'listenToAddPanelEvent'));
     }
     if (!class_exists('Doctrine_Core', false)) {
         require_once sfConfig::get('sf_doctrine_dir', realpath(dirname(__FILE__) . '/../lib/vendor/doctrine')) . '/Doctrine/Core.php';
     }
     spl_autoload_register(array('Doctrine_Core', 'autoload'));
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL);
     $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE);
     $manager->setAttribute(Doctrine_Core::ATTR_RECURSIVE_MERGE_FIXTURES, true);
     $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
     // apply default attributes
     $manager->setDefaultAttributes();
     if (method_exists($this->configuration, 'configureDoctrine')) {
         $this->configuration->configureDoctrine($manager);
     }
     $this->dispatcher->notify(new sfEvent($manager, 'doctrine.configure'));
     // make sure the culture is intercepted
     $this->dispatcher->connect('user.change_culture', array('sfDoctrineRecord', 'listenToChangeCultureEvent'));
 }
示例#25
0
文件: dmContext.php 项目: rafix/diem
 /**
  * Initializes the current dmContext instance.
  *
  * @param dmApplicationConfiguration $configuration  An dmApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->checkProjectIsSetup();
     parent::initialize($configuration);
     sfConfig::set('dm_debug', $this->getRequest()->getParameter('dm_debug', false));
     // load the service container instance
     $this->loadServiceContainer();
     // configure the service container with its required dependencies
     $this->configureServiceContainer($this->serviceContainer);
     if (method_exists($this->configuration, 'configureServiceContainer')) {
         $this->configuration->configureServiceContainer($this->serviceContainer);
     }
     // connect the service container and its services to the event dispatcher
     $this->serviceContainer->connect();
     /*
      * dmForm requires service container...
      */
     dmForm::setServiceContainer($this->serviceContainer);
     /*
      * some classes needs the event dispatcher to communicate
      * and the service container...
      */
     dmDoctrineQuery::setModuleManager($this->getModuleManager());
     dmDoctrineTable::setServiceContainer($this->serviceContainer);
     $this->helper = $this->serviceContainer->getService('helper');
     // notify that context is ready
     $this->dispatcher->notify(new sfEvent($this, 'dm.context.loaded'));
 }
 protected function execute($arguments = array(), $options = array())
 {
     // Memory usage is a bit high here because we look at every page, and the Rackspace Cloud
     // environment has a very low default memory limit for their ersatz "cron jobs."
     // TODO: prioritize a low-memory solution for rebuild-search-index, which will be
     // necessary for large sites anyway
     ini_set('memory_limit', '256M');
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // Initialize the context, which loading use of helpers, notably url_for
     // First set config vars so that reasonable siteless-but-rooted URLs can be generated
     // TODO: think about ways to make this work for people who like frontend_dev.php etc., although
     // we're doing rather well with an index.php that suits each environment
     sfConfig::set('sf_no_script_name', true);
     $_SERVER['PHP_SELF'] = '';
     $_SERVER['SCRIPT_NAME'] = '';
     $context = sfContext::createInstance($this->configuration);
     if (isset($options['table'])) {
         $indexes = array($options['table']);
     } else {
         $indexes = sfConfig::get('app_aToolkit_indexes', array());
     }
     $count = 0;
     foreach ($indexes as $index) {
         $table = Doctrine::getTable($index);
         if ($index === 'aPage') {
             aZendSearch::purgeLuceneIndex($table);
             // We're about to request updates of all page/culture combinations. Don't
             // add that to an existing workload which could result in a huge pileup of
             // repeat requests if someone starts interrupting this task and trying again, etc.
             $this->query('DELETE FROM a_lucene_update');
             $pages = Doctrine::getTable('aPage')->createQuery('p')->innerJoin('p.Areas a')->execute(array(), Doctrine::HYDRATE_ARRAY);
             foreach ($pages as $page) {
                 $cultures = array();
                 foreach ($page['Areas'] as $area) {
                     $cultures[$area['culture']] = true;
                 }
                 $cultures = array_keys($cultures);
                 foreach ($cultures as $culture) {
                     $this->query('INSERT INTO a_lucene_update (page_id, culture) VALUES (:page_id, :culture)', array('page_id' => $page['id'], 'culture' => $culture));
                 }
             }
             while (true) {
                 $result = $this->query('SELECT COUNT(id) AS total FROM a_lucene_update');
                 $count = $result[0]['total'];
                 if ($count == 0) {
                     break;
                 }
                 $this->logSection('toolkit', "{$count} pages remain to be indexed, starting another update pass...");
                 $this->update();
             }
         } else {
             // We don't have a deferred update feature for other tables,
             // so we'll have to get them done in the memory available
             $table->rebuildLuceneIndex();
         }
         $this->logSection('toolkit', sprintf('Index for "%s" rebuilt', $index));
     }
 }
 /**
  * @see sfPluginConfiguration
  */
 public function initialize()
 {
     sfConfig::set('sf_orm', 'propel');
     if (!sfConfig::get('sf_admin_module_web_dir')) {
         sfConfig::set('sf_admin_module_web_dir', '/sfPropelPlugin');
     }
     sfToolkit::addIncludePath(array(sfConfig::get('sf_root_dir'), sfConfig::get('sf_propel_runtime_path', realpath(dirname(__FILE__) . '/../lib/vendor'))));
     require_once 'propel/Propel.php';
     if (!Propel::isInit()) {
         if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
             Propel::setLogger(new sfPropelLogger($this->dispatcher));
         }
         $propelConfiguration = new PropelConfiguration();
         Propel::setConfiguration($propelConfiguration);
         $this->dispatcher->notify(new sfEvent($propelConfiguration, 'propel.configure'));
         Propel::initialize();
     }
     $this->dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent'));
     if (sfConfig::get('sf_web_debug')) {
         $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelPropel', 'listenToAddPanelEvent'));
     }
     if (sfConfig::get('sf_test')) {
         $this->dispatcher->connect('context.load_factories', array($this, 'clearAllInstancePools'));
     }
 }
 /**
  * Sets the project dimension.
  *
  * @param array The configuration dimension as an array
  */
 public function setDimension($dimension)
 {
     if ($dimension === null || $dimension === false) {
         $this->dimension = null;
         // if dimension changes, change cache dir
         $this->setCacheDir($this->getRootDir() . '/cache');
     } else {
         try {
             if (!$this->hasDimension()) {
                 $this->application = isset($this->application) ? $this->application : '';
                 $this->environment = isset($this->environment) ? $this->environment : '';
                 $this->dimension = new ysfConfigDimension($this->getEventDispatcher(), $this->getDimensionCacheHandler());
             }
             // set dimension
             $this->dimension->set($dimension);
             sfConfig::set('sf_dimension', $this->dimension->getName());
             // if dimension changes, change cache dir
             $this->setCacheDir($this->getRootDir() . '/cache/' . $this->dimension->getName());
         } catch (sfException $e) {
             if (method_exists($e, 'asResponse')) {
                 // handle exception early on and exit if something bad happens
                 $e->asResponse()->send();
                 exit;
             } else {
                 echo $e->getMessage();
                 exit;
             }
         }
     }
 }
 public static function add($class, $behaviors)
 {
     foreach ($behaviors as $name => $parameters) {
         if (is_int($name)) {
             // no parameters
             $name = $parameters;
         } else {
             // register parameters
             foreach ($parameters as $key => $value) {
                 sfConfig::set('propel_behavior_' . $name . '_' . $class . '_' . $key, $value);
             }
         }
         if (!isset(self::$behaviors[$name])) {
             throw new sfConfigurationException(sprintf('Propel behavior "%s" is not registered', $name));
         }
         // register hooks
         foreach (self::$behaviors[$name]['hooks'] as $hook => $callables) {
             foreach ($callables as $callable) {
                 sfMixer::register('Base' . $class . $hook, $callable);
             }
         }
         // register new methods
         foreach (self::$behaviors[$name]['methods'] as $callable) {
             sfMixer::register('Base' . $class, $callable);
         }
     }
 }
  public function initialize()
  {
    if ($this->configuration instanceof sfApplicationConfiguration)
    {
      if (sfConfig::get('app_sfSimpleBlog_use_feeds', false))
      {
        sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules'), array('sfSimpleBlogFeed')));
        if (sfConfig::get('app_sfSimpleBlog_routes_register', true))
        {
          $this->dispatcher->connect('routing.load_configuration', array('sfSimpleBlog15Routing', 'listenToFeedRoutingLoadConfigurationEvent'));
        }
      }
      
      if (sfConfig::get('app_sfSimpleBlog_routes_register', true) && in_array('sfSimpleBlog', sfConfig::get('sf_enabled_modules', array())))
      {
        $this->dispatcher->connect('routing.load_configuration', array('sfSimpleBlog15Routing', 'listenToRoutingLoadConfigurationEvent'));
      }

      if (sfConfig::get('app_sfSimpleBlog_routes_register', true))
      {
        foreach (array('sfSimpleBlogPostAdmin', 'sfSimpleBlogCategoryAdmin', 'sfSimpleBlogPageAdmin', 'sfSimpleBlogTagAdmin', 'sfSimpleBlogLinkAdmin', 'sfSimpleBlogLinkCategoryAdmin') as $module)
        {
          if (in_array($module, sfConfig::get('sf_enabled_modules')))
          {
            $this->dispatcher->connect('routing.load_configuration', array('sfSimpleBlog15Routing', 'addRouteFor'.str_replace('sfSimpleBlog', '', $module)));
          }
        }
      }
    }
  }