コード例 #1
0
 public function run()
 {
     opApplicationConfiguration::unregisterZend();
     $task = new sfDoctrineBuildModelTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => 'pc_frontend', 'env' => sfConfig::get('sf_environment', 'prod')));
     $task = new sfCacheClearTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => null, 'env' => sfConfig::get('sf_environment', 'prod')));
     opApplicationConfiguration::registerZend();
 }
コード例 #2
0
 public static function initialize()
 {
     if (!self::$initialized) {
         opApplicationConfiguration::registerZend();
         if ($host = sfConfig::get('op_mail_smtp_host')) {
             $tr = new Zend_Mail_Transport_Smtp($host, sfConfig::get('op_mail_smtp_config', array()));
             Zend_Mail::setDefaultTransport($tr);
         } elseif ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
             $tr = new Zend_Mail_Transport_Sendmail('-f' . $envelopeFrom);
             Zend_Mail::setDefaultTransport($tr);
         }
         opApplicationConfiguration::unregisterZend();
         self::$initialized = true;
     }
 }
コード例 #3
0
 public function run()
 {
     $this->getDatabaseManager();
     // build all tables for models
     if (!$this->getOption('models')) {
         opApplicationConfiguration::unregisterZend();
         $path = sfConfig::get('sf_lib_dir') . '/model/doctrine';
         Doctrine_Core::loadModels($path, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
         Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
         opApplicationConfiguration::registerZend();
         return true;
     }
     foreach ($this->getQueries() as $query) {
         $db = $this->getDatabaseManager()->getDatabase('doctrine');
         $db->getDoctrineConnection()->execute($query);
     }
 }
コード例 #4
0
 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     opApplicationConfiguration::unregisterZend();
     $birthday = Doctrine::getTable('Profile')->retrieveByName('op_preset_birthday');
     if (!$birthday) {
         throw new sfException('This project doesn\'t have the op_preset_birthday profile item.');
     }
     $profiles = Doctrine::getTable('MemberProfile')->createQuery()->where('profile_id = ?', $birthday->id)->andWhere('DATE_FORMAT(value_datetime, ?) = ?', array('%m-%d', date('m-d', strtotime('+ 1 week'))))->execute();
     opApplicationConfiguration::registerZend();
     $context = sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'));
     $i18n = $context->getI18N();
     foreach ($profiles as $profile) {
         $birthMember = $profile->getMember();
         foreach ($birthMember->getFriends() as $member) {
             $params = array('member' => $member, 'birthMember' => $birthMember, 'subject' => $i18n->__('There is your %my_friend% that its birthday is coming soon'));
             opMailSend::sendTemplateMailToMember('birthday', $member, $params, array(), $context);
         }
     }
 }
コード例 #5
0
 protected function execute($arguments = array(), $options = array())
 {
     sfConfig::set('sf_test', true);
     opApplicationConfiguration::registerZend();
     $stdin = file_get_contents('php://stdin');
     $message = new opMailMessage(array('raw' => $stdin));
     opMailRequest::setMailMessage($message);
     opApplicationConfiguration::unregisterZend();
     $configuration = ProjectConfiguration::getApplicationConfiguration('mobile_mail_frontend', 'prod', false);
     $context = sfContext::createInstance($configuration);
     $request = $context->getRequest();
     ob_start();
     $context->getController()->dispatch();
     $retval = ob_get_clean();
     if ($retval) {
         $subject = $context->getResponse()->getTitle();
         $to = $message->from;
         $from = $message->to;
         opMailSend::execute($subject, $to, $from, $retval);
     }
 }
コード例 #6
0
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     $result = $mailer->send();
     opApplicationConfiguration::unregisterZend();
     return $result;
 }
コード例 #7
0
 protected function execute($arguments = array(), $options = array())
 {
     $definitions = $this->getDefinition();
     $timer = new sfTimer();
     $succeeded = array();
     $targets = $this->getOption('targets', array_keys($definitions));
     foreach ((array) $definitions as $k => $v) {
         if (!in_array($k, $targets)) {
             continue;
         }
         $timer->startTimer();
         $defaultOptions = array_merge($this->options, array('name' => $k, 'dir' => $this->basePath, 'required_rules' => array(), 'configuration' => $this->configuration, 'dispatcher' => new sfEventDispatcher(), 'formatter' => $this->formatter));
         $v = array_merge(array('options' => $defaultOptions), $v);
         if (!isset($v['options']['required_rules'])) {
             $v['options']['required_rules'] = array();
         }
         $requiredRules = (array) $v['options']['required_rules'];
         if (!empty($requiredRules) && array_diff($requiredRules, $succeeded)) {
             $this->logSection('upgrade', 'Passed ' . $k, null, 'ERROR');
             continue;
         }
         $this->logSection('upgrade', 'Processing ' . $k);
         if (isset($v['file']) && is_file($v['file'])) {
             require_once $v['file'];
         }
         if (class_exists($v['strategy'])) {
             $className = $v['strategy'];
         } else {
             $className = 'opUpgrade' . $v['strategy'] . 'Strategy';
         }
         opApplicationConfiguration::registerZend();
         try {
             // disable Doctrine profiling
             sfConfig::set('sf_debug', false);
             $strategy = new $className($v['options']);
             $strategy->run();
             $succeeded[] = $k;
         } catch (Exception $e) {
             $this->logBlock($e->getMessage(), 'ERROR');
         }
         opApplicationConfiguration::unregisterZend();
         $this->logSection('upgrade', sprintf('Processed %s (%.2f sec)', $k, $timer->addTime()));
     }
     $this->logSection('upgrade', sprintf('Completed Upgrading (%.2f sec)', $timer->getElapsedTime()));
     $this->logSection('upgrade', sprintf('The %.2f MB memory allocated', round(memory_get_peak_usage(true) / 1048576, 2)));
 }
コード例 #8
0
 protected function dataLoad($path)
 {
     opApplicationConfiguration::unregisterZend();
     Doctrine::loadData($path, true);
     opApplicationConfiguration::registerZend();
 }