当前位置: 首页>>代码示例>>PHP>>正文


PHP sfContext::createInstance方法代码示例

本文整理汇总了PHP中sfContext::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP sfContext::createInstance方法的具体用法?PHP sfContext::createInstance怎么用?PHP sfContext::createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfContext的用法示例。


在下文中一共展示了sfContext::createInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * {@inheritdoc}
  */
 public function boot(ContainerInterface $container)
 {
     if (empty($this->options)) {
         throw new \RuntimeException('You must provide options for the Symfony 1.4 kernel.');
     }
     if ($this->isBooted()) {
         return;
     }
     if ($this->classLoader && !$this->classLoader->isAutoloaded()) {
         $this->classLoader->autoload();
     }
     $dispatcher = $container->get('event_dispatcher');
     $event = new LegacyKernelBootEvent($container->get('request'), $this->options);
     $dispatcher->dispatch(LegacyKernelEvents::BOOT, $event);
     $this->options = $event->getOptions();
     require_once $this->rootDir . '/config/ProjectConfiguration.class.php';
     $application = $this->options['application'];
     $environment = $this->options['environment'];
     $debug = $this->options['debug'];
     $this->configuration = \ProjectConfiguration::getApplicationConfiguration($application, $environment, $debug, $this->getRootDir());
     $this->configuration->loadHelpers(array('Url'));
     // Create a context to use with some helpers like Url.
     if (!\sfContext::hasInstance()) {
         $session = $container->get('session');
         if ($session->isStarted()) {
             $session->save();
         }
         ob_start();
         \sfContext::createInstance($this->configuration);
         ob_end_flush();
         $session->migrate();
     }
     $this->isBooted = true;
 }
开发者ID:chancegarcia,项目名称:TheodoEvolutionLegacyWrapperBundle,代码行数:37,代码来源:Symfony14Kernel.php

示例2: execute

 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
     $pcGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('dailyNews');
     $mobileGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('mobileDailyNews');
     $targetMembers = Doctrine::getTable('Member')->findAll();
     foreach ($targetMembers as $member) {
         if (!$member->getConfig('daily_news')) {
             continue;
         }
         if (1 == $member->getConfig('daily_news') && !$this->isDailyNewsDay()) {
             continue;
         }
         $address = $member->getEmailAddress();
         $gadgets = $pcGadgets['dailyNewsContents'];
         if (opToolkit::isMobileEmailAddress($address)) {
             $gadgets = $mobileGadgets['mobileDailyNewsContents'];
         }
         $filteredGadgets = array();
         if ($gadgets) {
             foreach ($gadgets as $gadget) {
                 if ($gadget->isEnabled()) {
                     $filteredGadgets[] = array('component' => array('module' => $gadget->getComponentModule(), 'action' => $gadget->getComponentAction()), 'gadget' => $gadget, 'member' => $member);
                 }
             }
         }
         $context = $this->getContextByEmailAddress($address);
         $params = array('member' => $member, 'gadgets' => $filteredGadgets, 'subject' => $context->getI18N()->__('デイリーニュース'), 'today' => time());
         opMailSend::sendTemplateMail('dailyNews', $address, opConfig::get('admin_mail_address'), $params, $context);
     }
 }
开发者ID:TadahiroKudo,项目名称:OpenPNE3,代码行数:32,代码来源:openpneSendDailyNewsTask.class.php

示例3: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     sfContext::createInstance($this->configuration);
     $blast = Doctrine::getTable('Blast')->find(1);
     $response = Doctrine::getTable('BlastResponse')->find(1);
     BlastManager::createTextResponse($response);
 }
开发者ID:jnankin,项目名称:makeaminyan,代码行数:10,代码来源:TestEmailTask.class.php

示例4: execute

 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));
     }
 }
开发者ID:quafzi,项目名称:timpany-prototype,代码行数:60,代码来源:toolkitRebuildIndexTask.class.php

示例5: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $data = array();
     $modules = $this->findModules();
     $target = sfConfig::get('sf_cache_dir') . '/' . $arguments['application'] . '/' . $arguments['env'] . '/config/configuration.php';
     // remove existing optimization file
     if (file_exists($target)) {
         $this->getFilesystem()->remove($target);
     }
     // recreate configuration without the cache
     $this->setConfiguration($this->createConfiguration($this->configuration->getApplication(), $this->configuration->getEnvironment()));
     // initialize the context
     sfContext::createInstance($this->configuration);
     // force cache generation for generated modules
     foreach ($modules as $module) {
         $this->configuration->getConfigCache()->import('modules/' . $module . '/config/generator.yml', false, true);
     }
     $templates = $this->findTemplates($modules);
     $data['getTemplateDir'] = $this->optimizeGetTemplateDir($modules, $templates);
     $data['getControllerDirs'] = $this->optimizeGetControllerDirs($modules);
     $data['getPluginPaths'] = $this->configuration->getPluginPaths();
     $data['loadHelpers'] = $this->optimizeLoadHelpers($modules);
     if (!file_exists($directory = dirname($target))) {
         $this->getFilesystem()->mkdirs($directory);
     }
     $this->logSection('file+', $target);
     file_put_contents($target, '<?php return ' . var_export($data, true) . ';');
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:31,代码来源:sfProjectOptimizeTask.class.php

示例6: execute

    protected function execute($arguments = array(), $options = array()) {
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
        $context = sfContext::createInstance($this->configuration);
        sfProjectConfiguration::getActive()->loadHelpers('Partial', 'I18N', 'Url');
        $serverUrl = $options['setenvironment'] == '' ? $serverUrl = $options['host'] : $serverUrl = $options['host'] . '/' . $options['setenvironment'];
        $workflows = WorkflowVersionTable::instance()->getWorkflowsToStart(time())->toArray();
        foreach($workflows as $workflow) {
            $sender = WorkflowTemplateTable::instance()->getWorkflowTemplateById($workflow['workflowtemplate_id'])->toArray();
            $userSettings = new UserMailSettings($sender[0]['sender_id']);
            $sendMail = new SendStartWorkflowEmail($userSettings, $context, $workflow, $sender, $serverUrl);
            $workflowTemplate = WorkflowTemplateTable::instance()->getWorkflowTemplateByVersionId($workflow['id']);
            WorkflowVersionTable::instance()->startWorkflowInFuture($workflow['id']);
            $sendToAllSlotsAtOnce = $workflowTemplate[0]->getMailinglistVersion()->toArray();
            if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) {
                $calc = new CreateWorkflow($workflow['id']);
                $calc->setServerUrl($serverUrl);
                $calc->setContext($context);
                $calc->addAllSlots();
            }
            else {
                $calc = new CreateWorkflow($workflow['id']);
                $calc->setServerUrl($serverUrl);
                $calc->setContext($context);
                $calc->addSingleSlot();
            }

        }
  }
开发者ID:rlauenroth,项目名称:cuteflow_v3,代码行数:29,代码来源:startWorkflowTask.class.php

示例7: execute

 protected function execute($args = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // So we can play with app.yml settings from the application
     $context = sfContext::createInstance($this->configuration);
     $admin = Doctrine::getTable('sfGuardUser')->findOneByUsername('admin');
     for ($i = 0; $i < $options['amount']; $i++) {
         echo "Creating event " . ($i + 1) . " of " . $options['amount'] . "...\n";
         $post = new aEvent();
         $post->author_id = $admin->id;
         $post->status = 'published';
         $post->start_date = aDate::mysql(strtotime($i + 1 . ' days'));
         $post->start_time = date('H:i:s', rand(0, time()));
         $post->end_date = aDate::mysql(strtotime($i + rand(1, 14) . ' days'));
         $post->end_time = date('H:i:s', rand(0, time()));
         $post->excerpt = '';
         $post->location = "1168 E. Passyunk Avenue\nPhiladelphia PA 19147";
         $post->published_at = aDate::mysql(strtotime('-' . ($i + 1) . ' days'));
         $title = implode(' ', $this->getWords(mt_rand(5, 10), $options));
         $body = implode(' ', $this->getWords(mt_rand(20, 100), $options));
         $post->setTitle($title);
         $post->save();
         $slot = $post->Page->createSlot('aRichText');
         $slot->value = $body;
         $slot->save();
         $post->Page->newAreaVersion('blog-body', 'update', array('permid' => 1, 'slot' => $slot));
     }
 }
开发者ID:hashir,项目名称:UoA,代码行数:30,代码来源:aBlogGenerateTestEventsTask.class.php

示例8: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     sfContext::createInstance($this->configuration);
     $displayName = $this->ask("Enter a minyan display name (Darchei Noam Glenbrook)");
     $identifier = $this->ask("Enter minyan identifier (dng)");
     $email = $this->ask("Enter username for minyan admin");
     $user = Doctrine::getTable('SfGuardUser')->findOneByUsername(trim(strtolower($email)));
     if (!$user) {
         throw new Exception("User with email {$email} does not exist");
     }
     try {
         $con = Doctrine::getConnectionByTableName("SfGuardUser");
         $con->beginTransaction();
         $minyan = new Minyan();
         $minyan->setName($displayName);
         $minyan->setIdentifier(Utils::formatPermalink($identifier));
         $minyan->save();
         $minyanUser = new MinyanUser();
         $minyanUser->setIsAdmin(true);
         $minyanUser->setUserId($user->getId());
         $minyanUser->setMinyanId($minyan->getId());
         $minyanUser->save();
         $this->logSection('mam', "Minyan {$identifier} created successfully!");
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
开发者ID:jnankin,项目名称:makeaminyan,代码行数:32,代码来源:CreateMinyanTask.class.php

示例9: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $this->context = sfContext::createInstance($this->configuration);
     $this->context->getConfiguration()->loadHelpers(array('Parse', 'Text', 'Tag'));
     ini_set('memory_limit', '2048M');
     Doctrine::getTable('Post')->createQuery()->update()->set('text_original', 'text')->where('text_original is NULL')->execute();
     Doctrine::getTable('PostComment')->createQuery()->update()->set('comment_original', 'comment')->where('comment_original is NULL')->execute();
     $offset = 0;
     do {
         $posts = Doctrine::getTable('Post')->createQuery()->limit(100)->offset($offset)->execute();
         $this->ParsePosts($posts);
         $offset += 100;
         echo "Offset: " . $offset . "\n";
     } while (count($posts));
     $offset = 0;
     do {
         $comments = Doctrine::getTable('PostComment')->createQuery()->limit(100)->offset($offset)->execute();
         $this->ParsetComments($comments);
         $offset += 100;
         echo "Comments Offset: " . $offset . "\n";
     } while (count($comments));
 }
开发者ID:auphau,项目名称:joyreactor,代码行数:25,代码来源:joyreactorUpdatePostsTask.class.php

示例10: execute

 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $this->context = sfContext::createInstance($this->configuration);
     $databaseManager = new sfDatabaseManager($this->configuration);
     $dbdsn = $databaseManager->getDatabase('propel')->getParameter('dsn');
     $dbusername = $databaseManager->getDatabase('propel')->getParameter('username');
     $dbpassword = $databaseManager->getDatabase('propel')->getParameter('password');
     $dbname = preg_replace('/^.*dbname=([^;=]+).*$/', '${1}', $dbdsn);
     ConfigurationHelper::load();
     $backup_method = ConfigurationHelper::getParameter('Backup', 'backup_method');
     $this->logSection('tempos', sprintf('Backup method: %s', $backup_method), 1024);
     if ($backup_method == 'ftp') {
         $backupname = 'tempos-backup.sql';
         $configname = ConfigurationHelper::getDefaultConfigurationFileName();
         $configpath = ConfigurationHelper::getDefaultConfigurationFilePath();
         copy($configpath, '/tmp/' . $configname);
         chdir('/tmp');
         system(sprintf('mysqldump --user=%s --password=%s %s > %s', escapeshellarg($dbusername), escapeshellarg($dbpassword), escapeshellarg($dbname), escapeshellarg($backupname)));
         $tmpfilename = 'tempos-backup-' . date('Y-m-d') . '.tar.gz';
         system(sprintf('tar zcf %s %s %s', escapeshellarg($tmpfilename), escapeshellarg($backupname), escapeshellarg($configname)));
         unlink($backupname);
         unlink($configname);
         try {
             FTPHelper::backupFile($tmpfilename);
         } catch (Exception $ex) {
             unlink($tmpfilename);
             throw $ex;
         }
         unlink($tmpfilename);
     }
 }
开发者ID:jfesquet,项目名称:tempos,代码行数:32,代码来源:temposBackupTask.class.php

示例11: execute

 protected function execute($arguments = array(), $options = array())
 {
     sfContext::createInstance($this->configuration);
     sfContext::getInstance();
     $this->logLevel = $options['verbose'] ? Resque_Worker::LOG_NORMAL : 0;
     $this->logLevel = $options['vverbose'] ? Resque_Worker::LOG_VERBOSE : $this->logLevel;
     $queues = explode(',', $arguments['queues']);
     if ($options['count'] == 1) {
         $worker = $this->createWorker($queues, $options);
         $this->logSection('worker', 'Starting worker ' . $worker);
         $worker->work($options['interval']);
     } else {
         if ($options['count'] > 1) {
             if (!function_exists('pcntl_fork')) {
                 throw new Exception('PHP installation lakcs PCNTL. Recompile with `--enable-pcntl` configuration option.');
             }
             for ($i = 0; $i < $options['count']; ++$i) {
                 $pid = pcntl_fork();
                 if ($pid == -1) {
                     $this->logBlock('Could not fork worker ' . $i, 'ERROR');
                     return;
                 } else {
                     if (!$pid) {
                         $worker = $this->createWorker($queues, $options);
                         $this->logSection('worker', 'Starting worker ' . $worker);
                         $worker->work($options['interval']);
                         break;
                     }
                 }
             }
         }
     }
 }
开发者ID:pmoutet,项目名称:navinum,代码行数:33,代码来源:resqueWorkerTask.class.php

示例12: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $context = sfContext::createInstance($applicationConfig);
     // Go to the Subreddit and obtain the past few keys.
     $reddit_location = $options['subreddit'];
     $reddit = new RedditObject($reddit_location);
     $quiet = (bool) $options['quiet'];
     if (!$quiet) {
         echo "Obtaining the most recent comments from {$reddit_location}...";
     }
     $reddit->appendData();
     $found_keys = count($reddit->getComments());
     if (!$quiet) {
         echo "\nFound {$found_keys} keys.  Updating keys in the database...";
     }
     ValidationTable::getInstance()->storeNewKeys($reddit->getComments());
     // Now that new keys are stored in the database we need to update all applicable users
     $users = sfGuardUserTable::getInstance()->getUsersToBeValidated();
     $updated = sfGuardUserTable::getInstance()->validateUsers($users);
     if (!$quiet) {
         echo "\nSending emails...";
     }
     foreach ($users as $user_id) {
         $sf_user = $context->getUser();
         $sf_user->setApiUserId($user_id);
         $sf_user->sendMail('RedditValidationSucceeded');
     }
     if (!$quiet) {
         echo "\n{$updated} users validated and email sent.\n";
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:35,代码来源:herdditValidateusersTask.class.php

示例13: authenticate

 public function authenticate(MOXMAN_Auth_User $user)
 {
     $config = MOXMAN::getConfig();
     if ($config->get('SymfonyAuthenticator.application_name') == '') {
         die('You should define a SymfonyAuthenticator.application_name name in Moxiemanager config file.');
     }
     if ($config->get('SymfonyAuthenticator.application_env') == '') {
         die('You should define a SymfonyAuthenticator.application_env in Moxiemanager config file.');
     }
     if ($config->get('SymfonyAuthenticator.project_configuration_path') == '') {
         die('You should define a SymfonyAuthenticator.project_configuration_path in Moxiemanager config file.');
     }
     require_once $config->get('SymfonyAuthenticator.project_configuration_path');
     $configuration = ProjectConfiguration::getApplicationConfiguration($config->get('SymfonyAuthenticator.application_name'), $config->get('SymfonyAuthenticator.application_env'), false);
     $context = sfContext::createInstance($configuration);
     // Is the user authenticated ?
     if ($context->getUser()->isAuthenticated()) {
         // Do we need a special role to access to the moxiemanager ?
         if ($config->get('SymfonyAuthenticator.credential') != '') {
             if ($context->getUser()->hasCredential($config->get('SymfonyAuthenticator.credential'))) {
                 return true;
             } else {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:29,代码来源:Plugin.php

示例14: execute

 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance($this->configuration);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $table = PetitionTable::getInstance();
     $con = $table->getConnection();
     $silent = $options['silent'];
     $utc_hour = $options['utc-hour'];
     if ($utc_hour !== '') {
         if (gmdate('H') !== $utc_hour) {
             if (!$silent) {
                 echo "exiting, it is not the right hour.\n";
             }
             return;
         }
     }
     $petitions = $table->fetchScheduleNeed();
     foreach ($petitions as $petition) {
         /* @var $petition Petition */
         if (!$silent) {
             echo $petition->getId() . "\t" . $petition->getName() . "\n";
         }
         //      $petition->state(Doctrine_Record::STATE_DIRTY); // with cachetagging this does not help, we have to change something
         $kind = $petition->getKind();
         $petition->setKind(0);
         $petition->setKind($kind);
         $petition->save();
     }
     if (!$silent) {
         echo "done.\n";
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:34,代码来源:policatActionScheduleTask.class.php

示例15: createContextInstance

 protected function createContextInstance($application = 'frontend', $enviroment = 'dev', $debug = true)
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($application, $enviroment, $debug);
     sfContext::createInstance($configuration);
     sfContext::switchTo($application);
     $this->context = sfContext::getInstance();
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:7,代码来源:AnexaFixClose2015Task.class.php


注:本文中的sfContext::createInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。