I have this task and no matter what I try I keep getting Connection
configuration required
<?php
class checkCurrentStatusTask extends sfBaseTask
//class checkCurrentStatusTask extends sfPropelBaseTask
{
protected function configure()
{
// // add your own arguments here
// $this->addArguments(array(
// new sfCommandArgument('my_arg', sfCommandArgument::REQUIRED,
'My argument'),
// ));
$this->addOptions(array(
new sfCommandoption('application', null,
sfCommandOption::PARAMETER_REQUIRED, 'the application that this is
running as', 'webmaster'),
new sfCommandOption('env', null,
sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
new sfCommandOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'the connection name', 'propel'),
new sfCommandOption('verbose', null,
sfCommandOption::PARAMETER_REQUIRED, 'Enables verbose output', false),
// add your own options here
));
$this->namespace = 'hopcon';
$this->name = 'check-current-status';
$this->briefDescription = 'This task will check on the current
stauts of servers and notify the required people whe the status
changes';
$this->detailedDescription = <<<EOF
The [checkCurrentStatus|INFO] task will check on the current stauts of
servers and notify the required people whe the status changes.
Call it with:
[php symfony checkCurrentStatus|INFO]
EOF;
//
//
// $this->addArgument('application', sfCommandArgument::REQUIRED,
'webmaster');
// $this->addOption('verbose', null,
sfCommandOption::PARAMETER_REQUIRED, 'Enables verbose output', false);
// $this->addOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel');
// $this->addOption('env', null,
sfCommandOption::PARAMETER_REQUIRED, 'The enviroment', 'dev');
}
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options
['connection'] ? $options['connection'] : '')->getConnection();
// $databaseManager = new sfDatabaseManager($configuration);
// echo "connection: ".print_r($connection, true)."\n";
// echo "databaseManager: ".print_r($databaseManager, true)."\n";
// echo "configuration: ".print_r($this->configuration, true)."\n";
// mail('[email protected]', 'debug', print_r($this-
>configuration, true));
// add your code here
/*
* Get all current status's
*/
$server_users = ServerUsersPeer :: doSelect(new Criteria());
$status_indicators = StatusIndicatorPeer :: getAll();
/*
* Only continue if there are server_users
*/
if ($server_users)
{
/*
* for each of records
*/
foreach ($server_users as $server)
{
if ($status_indicators)
{
foreach ($status_indicators as $status_indicator)
{
/*
* find the match
*/
$timestamp = date(sfConfig::get('app_date_format_save'),
strtotime("-".$status_indicator->getPeriod()." minutes"));
$updated_timstamp = ServerUsersPeer ::
getUpdatedAtByServerKey($server->getServerKey());
// $value = eval("\$updated_timstamp \$status_indicator-
>getComparison() \$timestamp");
$value = $updated_timstamp.' '.$status_indicator-
>getComparison().' '.$timestamp;
// $value = eval($updated_timstamp).' '.$status_indicator-
>getComparison().' '.eval($timestamp);
// echo 'value: '.$value."\n";
if ($value)
{
// ok now send the email or what ever
nahoMail::send('test email', 'test body',
'[email protected]');
} // end if
} // end foreach
} // end if
} // end foreach
} // end if
} // end function execute
}
On Mar 11, 1:57 am, Frank He <[email protected]> wrote:
> Sorry guys, it is my fault, they can be called. Love symfony so much!
>
> On Tue, Mar 10, 2009 at 12:54 PM, xhe <[email protected]> wrote:
>
> > I used this line to create a task:
>
> > class sendEmailAlertTask extends sfPropelBaseTask
>
> > But whenever I want to use the propel class, I got fatal error, the
> > class can not be found. So can anyone help me to tell how to use class
> > in the task command line?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---