/**
     * @see sfTask
     */
    protected function configure()
    {
        parent::configure();
        $this->addArguments(array(new sfCommandArgument('dir_or_file', sfCommandArgument::REQUIRED | sfCommandArgument::IS_ARRAY, 'Directory or file to load')));
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'), new sfCommandOption('database', null, sfCommandOption::PARAMETER_OPTIONAL, 'The database to use'), new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Whether to force dropping of the database')));
        $this->namespace = 'doctrine';
        $this->name = 'mysql-sql-load';
        $this->briefDescription = 'Loads MySQL queries from files/dir into a MySQL database';
        $this->detailedDescription = <<<EOF
The [doctrine:mysql-sql-load|INFO] is used to load SQL into a MySQL database,
it will not function on non MySQL databases:

  [./symfony doctrine:mysql-sql-load|INFO]

The intended function of this task is to load a MySQL dump backup of a database.

An argument of a target must be specified, mulitple files or a directory of .sql
can be specified.

If you don't want the task to drop and recreate the database and instead want to
just add to the existing database, use the
[--append|COMMENT] option:

  [./symfony doctrine:mysql-sql-load --append target|INFO]
EOF;
    }
コード例 #2
0
 protected function configure()
 {
     parent::configure();
     $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('from', null, sfCommandOption::PARAMETER_REQUIRED, 'member id which start from (inclusive)', 1), new sfCommandOption('to', null, sfCommandOption::PARAMETER_REQUIRED, 'member id which end to (exclusive)', null), new sfCommandOption('header', null, sfCommandOption::PARAMETER_OPTIONAL, 'need to output csv param header', true)));
     $this->namespace = 'opCsvExport';
     $this->name = 'export';
 }
コード例 #3
0
 protected function execute($arguments = array(), $options = array())
 {
     $dbms = '';
     $username = '';
     $password = '';
     $hostname = '';
     $port = '';
     $dbname = '';
     $sock = '';
     $maskedPassword = '******';
     if ($options['redo']) {
         try {
             $this->configuration = parent::createConfiguration($options['application'], $options['env']);
             new sfDatabaseManager($this->configuration);
         } catch (Exception $e) {
             $this->logSection('installer', $e->getMessage(), null, 'ERROR');
             $options['redo'] = false;
         }
     }
     if (!$options['redo']) {
         $validator = new sfValidatorCallback(array('required' => true, 'callback' => array($this, 'validateDBMS')));
         $dbms = $this->askAndValidate(array('Choose DBMS:', '- mysql', '- pgsql (unsupported)', '- sqlite (unsupported)'), $validator, array('style' => 'QUESTION_LARGE'));
         if (!$dbms) {
             $this->logSection('installer', 'task aborted');
             return 1;
         }
         if ($dbms !== 'sqlite') {
             $username = $this->askAndValidate(array('Type database username'), new opValidatorString(), array('style' => 'QUESTION_LARGE'));
             $password = $this->askAndValidate(array('Type database password (optional)'), new opValidatorString(array('required' => false)), array('style' => 'QUESTION_LARGE'));
             $hostname = $this->askAndValidate(array('Type database hostname'), new opValidatorString(), array('style' => 'QUESTION_LARGE'));
             $port = $this->askAndValidate(array('Type database port number (optional)'), new sfValidatorInteger(array('required' => false)), array('style' => 'QUESTION_LARGE'));
         }
         $dbname = $this->askAndValidate(array('Type database name'), new opValidatorString(), array('style' => 'QUESTION_LARGE'));
         if ($dbms == 'sqlite') {
             $dbname = realpath(dirname($dbname)) . DIRECTORY_SEPARATOR . basename($dbname);
         }
         if ($dbms == 'mysql' && ($hostname == 'localhost' || $hostname == '127.0.0.1')) {
             $sock = $this->askAndValidate(array('Type database socket path (optional)'), new opValidatorString(array('required' => false)), array('style' => 'QUESTION_LARGE'));
         }
         if (!$password) {
             $maskedPassword = '';
         }
         $list = array('The DBMS                 : ' . $dbms, 'The Database Username    : '******'The Database Password    : '******'The Database Hostname    : ' . $hostname, 'The Database Port Number : ' . $port, 'The Database Name        : ' . $dbname, 'The Database Socket      : ' . $sock);
     }
     $confirmAsk = 'Is it OK to start this task? (Y/n)';
     $confirmAsks = isset($list) ? array_merge($list, array('', $confirmAsk)) : array($confirmAsk);
     if (!$this->askConfirmation($confirmAsks, 'QUESTION_LARGE')) {
         $this->logSection('installer', 'task aborted');
         return 1;
     }
     $this->doInstall($dbms, $username, $password, $hostname, $port, $dbname, $sock, $options);
     if ($dbms === 'sqlite') {
         $this->getFilesystem()->chmod($dbname, 0666);
     }
     $this->publishAssets();
     // _PEAR_call_destructors() causes an E_STRICT error
     error_reporting(error_reporting() & ~E_STRICT);
     $this->logSection('installer', 'installation is completed!');
 }
コード例 #4
0
 public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter)
 {
     parent::initialize($dispatcher, $formatter);
     if (!self::$done) {
         $libDir = dirname(__FILE__) . '/..';
         $autoloader = sfSimpleAutoload::getInstance();
         $autoloader->addDirectory($libDir);
         $autoloader->register();
         self::$done = true;
     }
 }
コード例 #5
0
    protected function configure()
    {
        parent::configure();
        $this->namespace = 'openpne';
        $this->name = 'friend-link';
        $this->briefDescription = '';
        $this->addOptions(array(new sfCommandOption('start-member-id', null, sfCommandOption::PARAMETER_OPTIONAL, 'Start member id', null), new sfCommandOption('end-member-id', null, sfCommandOption::PARAMETER_OPTIONAL, 'End member id', null)));
        $this->detailedDescription = <<<EOF
The [openpne:friend-link|INFO] task does things.
Call it with:

  [php symfony openpne:friend-link|INFO]
EOF;
    }
コード例 #6
0
 public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter)
 {
     parent::initialize($dispatcher, $formatter);
     self::$done = true;
 }
コード例 #7
0
 public function initialize(sfEventDispatcher $dispatcher, sfFormatter $formatter)
 {
     parent::initialize($dispatcher, $formatter);
     // This is just a hack to make OpenPNE generate a valid url in some helper function
     $_SERVER['SCRIPT_NAME'] = '/index.php';
 }