Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save digitalbase/4123bd6a2b220d662c89dfd4e0d5a95e to your computer and use it in GitHub Desktop.
Save digitalbase/4123bd6a2b220d662c89dfd4e0d5a95e to your computer and use it in GitHub Desktop.
<?php
use Prezly\Auth\Session\BackendSessionReference;
use Prezly\Command\Import\HandleRecord;
use Prezly\Task\BaseTask;
class importResumeRecordTask extends BaseTask
{
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 name','cli'),
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
new sfCommandOption('record_id', null, sfCommandOption::PARAMETER_OPTIONAL, 'record_id to be synced')
// add your own options here
));
$this->namespace = 'import';
$this->name = 'record';
$this->briefDescription = '';
$this->detailedDescription = <<<EOF
The [import:record|INFO] task does things.
Call it with:
[php symfony import:record|INFO]
EOF;
}
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
$record = PressContactImportRecordPeer::retrieveByPK($options["record_id"]);
$import = $record->getPressContactImport();
// create BackendSessionReference instance for HandleRecord
$account = UserLicensePeer::retrievePkOrFail($import->getUserId(), $import->getLicenseId());
$backend_session = new BackendSessionReference($account, md5($account->getUserId()));
$this->dispatchNow(new HandleRecord($record->getId(), $backend_session));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment