本文整理汇总了PHP中sfProjectConfiguration::getApplicationConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP sfProjectConfiguration::getApplicationConfiguration方法的具体用法?PHP sfProjectConfiguration::getApplicationConfiguration怎么用?PHP sfProjectConfiguration::getApplicationConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfProjectConfiguration
的用法示例。
在下文中一共展示了sfProjectConfiguration::getApplicationConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
parent::execute($arguments, $options);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$this->log('[INFO] Flushing old data...' . "\n");
$eventlog_flush = EtvaSettingPeer::retrieveByPK('eventlog_flush');
$flush_range = $eventlog_flush->getValue();
$con->beginTransaction();
$affected = 0;
try {
$offset_date = date("c", time() - $flush_range * 24 * 60 * 60);
/*
* get event records that have creation date outdated
*/
$c = new Criteria();
$c->add(EtvaEventPeer::CREATED_AT, $offset_date, Criteria::LESS_THAN);
$affected = EtvaEventPeer::doDelete($c, $con);
$con->commit();
$message = sprintf('Events Log - %d Record(s) deleted after %d day offset', $affected, $flush_range);
$context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message)));
$this->log('[INFO] ' . $message);
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
$logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
// log the message!
$logger->log("[INFO] The events flush task ran!", 6);
}
示例2: execute
public function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
sfContext::createInstance($configuration);
$conn = Doctrine_Manager::connection();
// Récupération de toutes les notices.
$noeuds = $conn->execute("SELECT id, name FROM ei_data_set_structure;");
$this->log('Récupération des noeuds...OK');
// Création de la requête permettant
$this->log('Création de la requête de mise à jour...');
$requeteToUpdate = "UPDATE ei_data_set_structure SET slug = #{NEW_SLUG} WHERE id = #{NODE_ID};";
$requeteGlobale = array();
foreach ($noeuds->fetchAll() as $noeud) {
// Remplacement SLUG.
$tmpRequete = str_replace("#{NEW_SLUG}", $conn->quote(MyFunction::sluggifyForXML($noeud["name"])), $requeteToUpdate);
// Remplacement ID.
$tmpRequete = str_replace("#{NODE_ID}", $noeud["id"], $tmpRequete);
// Ajout dans la requête globale.
$requeteGlobale[] = $tmpRequete;
}
// Préparation de la requête.
$this->log("Préparation de la requête...");
$requete = implode(" ", $requeteGlobale);
try {
// Exécution de la requête.
$this->log("Exécution de la requête...");
$conn->execute($requete);
// Fin.
$this->log("Processus terminé avec succès.");
} catch (Exception $exc) {
$this->log($exc->getMessage());
}
}
示例3: 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);
ProjectConfiguration::registerCron();
$quiet = (bool) $options['quiet'];
$passed = array();
$assigned = array();
if ($arguments['subreddit'] == '%') {
if (!$quiet) {
echo "Advancing EpisodeAssignments for all Subreddits...";
}
SubredditTable::getInstance()->advanceEpisodeAssignments();
} else {
$subreddit = SubredditTable::getInstance()->findOneByName($arguments['subreddit']);
if ($subreddit) {
if (!$quiet) {
echo "Advancing EpisodeAssignments for {$subreddit} Subreddit...";
}
$subreddit->advanceEpisodeAssignments();
} else {
throw new sfException('Cannot find Subreddit: ' . $arguments['subreddit']);
}
}
if (!$quiet) {
echo "\n";
}
}
示例4: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
parent::execute($arguments, $options);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$options_task_server_backup = array('location' => $arguments['location'], 'filepath' => $arguments['filepath']);
if ($arguments['snapshot']) {
$options_task_server_backup['snapshot'] = $arguments['snapshot'];
}
if ($arguments['newsnapshot']) {
$options_task_server_backup['newsnapshot'] = $arguments['newsnapshot'];
}
if ($arguments['delete']) {
$options_task_server_backup['deletesnapshot'] = $arguments['delete'];
}
if ($arguments['location']) {
if ($arguments['do_not_generate_tar'] && $arguments['do_not_generate_tar'] != 'false') {
$options_task_server_backup['do_not_generate_tar'] = true;
}
}
$task_server_backup = new serverBackupTask($this->dispatcher, new sfFormatter());
return $task_server_backup->run(array('serverid' => $arguments['serverid']), $options_task_server_backup);
}
示例5: execute
/**
* Executes the current task.
*
* @param array $arguments An array of arguments
* @param array $options An array of options
*
* @return integer 0 if everything went fine, or an error code
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
sfContext::createInstance($configuration);
$conn = Doctrine_Manager::connection();
/** @var $parametres Récupération des paramètres à charger */
$parametres = $conn->execute("\n SELECT *\n FROM ei_function_has_param, ei_fonction\n WHERE param_type = 'OUT'\n AND (param_id, ei_fonction.id) NOT IN (SELECT ei_param_function_id, ei_function_id FROM ei_param_block_function_mapping)\n AND ei_function_has_param.function_ref = ei_fonction.function_ref\n AND ei_function_has_param.function_id = ei_fonction.function_id\n ");
$this->log('Récupération des paramètres...OK');
// Création de la requête permettant
$this->log('Création de la requête d\'insertion...');
$requeteToInsert = "INSERT INTO ei_param_block_function_mapping (ei_param_function_id, created_at, updated_at, ei_function_id) ";
$requeteToInsert .= "VALUES(#{PARAM_ID}, now(), now(), #{FONCTION_ID});";
$pile = array();
foreach ($parametres->fetchAll() as $parametre) {
// Remplacement PARAM ID.
$tmpRequete = str_replace("#{PARAM_ID}", $parametre["param_id"], $requeteToInsert);
// Remplacement FONCTION ID.
$tmpRequete = str_replace("#{FONCTION_ID}", $parametre["id"], $tmpRequete);
// Ajout dans la requête globale.
$pile[] = $tmpRequete;
}
// Préparation de la requête.
$this->log("Préparation de la requête...");
$requete = implode(" ", $pile);
try {
// Exécution de la requête.
$this->log("Exécution de la requête...");
$conn->execute($requete);
// Fin.
$this->log("Processus terminé avec succès.");
} catch (Exception $exc) {
$this->log($exc->getMessage());
}
}
示例6: 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);
$one_day_users = sfGuardUserTable::getInstance()->getOneDayEmailReminders();
$one_week_users = sfGuardUserTable::getInstance()->getOneWeekEmailReminders();
$quiet = (bool) $options['quiet'];
if (!$quiet) {
echo "Sending one-day reminder emails to " . count($one_day_users) . " users...";
}
foreach ($one_day_users as $user) {
$sf_user = $context->getUser();
$sf_user->setApiUserId($user->getIncremented());
$sf_user->sendMail('RegisterOneDay');
}
if (!$quiet) {
echo "\nSending one-week reminder emails to " . count($one_week_users) . " users...";
}
foreach ($one_week_users as $user) {
$sf_user = $context->getUser();
$sf_user->setApiUserId($user->getIncremented());
$sf_user->sendMail('RegisterOneWeek');
}
if (!$quiet) {
echo "\n";
}
}
示例7: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// need a scriptname otherwise it uses the symfony file
if ($arguments['env'] != 'prod') {
$_SERVER['SCRIPT_NAME'] = '/' . $arguments['application'] . '_' . $arguments['env'] . '.php';
} else {
$_SERVER['SCRIPT_NAME'] = '/index.php';
}
sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $arguments['env'], true));
$searchIndex = new zsSearchIndex($arguments['index']);
//optimize to increase speed
$searchIndex->optimize();
//loop thru all models specified in this index and update all entries
foreach ($searchIndex->getModels() as $model => $config) {
$this->logSection('update', 'model: ' . $model);
foreach (Doctrine::getTable($model)->findAll() as $object) {
$searchIndex->updateIndex($object);
echo '.';
}
echo "\n";
}
//re-optimize index
$searchIndex->optimize();
}
示例8: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$nid = $arguments['id'];
$this->log("[INFO] node check id={$nid}");
if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
$msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
$error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
$this->log("[ERROR] " . $error['error']);
return $error;
} else {
$etva_node_va = new EtvaNode_VA($etva_node);
$response = $etva_node_va->checkState();
if (!$response['success']) {
$this->log("[ERROR] " . $response['error']);
} else {
$this->log("[INFO] " . $response['response']);
}
return $response;
}
}
示例9: 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";
}
}
示例10: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
if ($options['server'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SERVER_, $options['server']);
}
if ($options['port'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_PORT_, $options['port']);
}
if ($options['security-type'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_SECURITY_, $options['security-type']);
}
if ($options['use-auth'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USE_AUTH_, $options['use-auth']);
}
if ($options['username'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_USERNAME_, $options['username']);
}
if ($options['password'] !== null) {
EtvaSettingPeer::updateSetting(EtvaSettingPeer::_SMTP_KEY_, $options['password']);
}
return;
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', 'dev', true));
parent::execute($arguments, $options);
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$con = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
$this->log('[INFO] Checking VirtAgents state...' . "\n");
$offset = sfConfig::get('app_node_keepalive_update') + sfConfig::get('app_node_keepalive_update_offset');
$total_nodes = EtvaNodePeer::doCount(new Criteria());
if ($total_nodes > 0) {
$con->beginTransaction();
$affected = 0;
try {
$offset_date = date("c", time() - $offset);
/*
* get nodes that have last_keepalive field outdated
*/
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_ACTIVE);
// only active
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_INACTIVE);
$affected += BasePeer::doUpdate($c1, $c2, $con);
// update maintenance and running to maintenance
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE_UP);
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_MAINTENANCE);
$affected += BasePeer::doUpdate($c1, $c2, $con);
// update fail and running to fail
$c1 = new Criteria();
$c1->add(EtvaNodePeer::LAST_KEEPALIVE, $offset_date, Criteria::LESS_THAN);
$c1->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL_UP);
// only active
//update statement
$c2 = new Criteria();
$c2->add(EtvaNodePeer::STATE, EtvaNode::NODE_FAIL);
$affected += BasePeer::doUpdate($c1, $c2, $con);
$con->commit();
$message = sprintf('%d Node(s) NOT received update in time offset of %d seconds', $affected, $offset);
if ($affected > 0) {
$context->getEventDispatcher()->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
}
$this->log('[INFO]' . $message);
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
$logger = new sfFileLogger($context->getEventDispatcher(), array('file' => sfConfig::get("sf_log_dir") . '/cron_status.log'));
// log the message!
$logger->log("[INFO] The check virtAgents task ran!", 6);
}
示例12: execute
protected function execute($arguments = array(), $options = array())
{
$context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
// add your code here
// get parameters
$lv = $arguments['name'];
$size = $arguments['size'];
$vg = $arguments['volumegroup'];
$node_id = $options['node'];
$format = $options['format'];
$persnapshotusage = $options['persnapshotusage'];
/*
* check if lv is a file disk instead
* if is a file disk check if special volume group exists. if not create
*/
$is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
// get etva_node
$etva_node = EtvaNodePeer::getOrElectNodeFromArray(array_merge($options, $arguments));
if (!$etva_node) {
$msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $node_id));
$error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
$this->log("[ERROR] " . $error['error']);
return $error;
}
// get logical volume
if ($etva_lv = $etva_node->retrieveLogicalvolumeByLv($lv)) {
$msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_;
$msg = Etva::getLogMessage(array('name' => $lv), $msg_type);
$msg_i18n = $context->getI18N()->__($msg_type, array('%name%' => $lv));
$error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
$this->log("[ERROR] " . $error['error']);
return $error;
}
if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) {
$msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_);
$msg_i18n = $context->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg));
$error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
$this->log("[ERROR] " . $error['error']);
return $error;
}
// prepare soap info....
$etva_lv = new EtvaLogicalvolume();
$etva_lv->setEtvaVolumegroup($etva_vg);
$etva_lv->setLv($lv);
$lv_va = new EtvaLogicalvolume_VA($etva_lv);
$response = $lv_va->send_create($etva_node, $size, $format, $persnapshotusage);
if (!$response['success']) {
$this->log("[ERROR] " . $response['error']);
} else {
$this->log("[INFO] " . $response['response']);
}
return $response;
}
示例13: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
//$databaseManager = new sfDatabaseManager($this->configuration);
//$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true));
$searchIndex = new zsSearchIndex($arguments['index']);
//optimize to increase speed
$searchIndex->optimize();
}
示例14: execute
/**
* Executes the current task.
*
* @param array $arguments An array of arguments
* @param array $options An array of options
*
* @return integer 0 if everything went fine, or an error code
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
sfContext::createInstance($configuration);
$conn = Doctrine_Manager::connection();
$conn->execute("UPDATE ei_scenario_structure SET type = '" . EiScenarioStructure::$TYPE_BLOCK . "' WHERE type = 1");
$this->log("Mise à jour des structures de scénarios de type " . EiScenarioStructure::$TYPE_BLOCK);
$conn->execute("UPDATE ei_scenario_structure SET type = '" . EiScenarioStructure::$TYPE_PARAM . "' WHERE type = 2");
$this->log("Mise à jour des structures de scénarios de type " . EiScenarioStructure::$TYPE_PARAM);
}
示例15: execute
/**
* Executes the current task.
*
* @param array $arguments An array of arguments
* @param array $options An array of options
*
* @return integer 0 if everything went fine, or an error code
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
sfContext::createInstance($configuration);
$this->connexion = Doctrine_Manager::connection();
$initialStep = 1;
do {
$this->proceedStep($initialStep++);
} while ($this->statutExec === true);
}
开发者ID:lendji4000,项目名称:compose,代码行数:19,代码来源:MigrateScenarioStructureIntoVersionStructureTask.class.php