Created
April 27, 2011 15:57
-
-
Save stephaneerard/944533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class ItSsLoadPhpDataTask extends dmContextTask | |
| { | |
| protected function configure() | |
| { | |
| parent::configure(); | |
| $this->addOption('files', 'f', sfCommandOption::PARAMETER_OPTIONAL | sfCommandOption::IS_ARRAY, 'Give files to load'); | |
| $this->addOption('load-dump', 'l', sfCommandOption::PARAMETER_NONE, 'Loads db dump before'); | |
| $this->namespace = 'it'; | |
| $this->name = 'load-php-data'; | |
| $this->briefDescription = 'Loads data from php files'; | |
| $this->detailedDescription = <<<EOF | |
| The [ItSsGenerateStayAdminUser|INFO] task does load data from php files | |
| Call it with: | |
| [php symfony ItSsGenerateStayAdminUser|INFO] | |
| EOF; | |
| } | |
| protected function execute($arguments = array(), $options = array()) | |
| { | |
| $this->withDatabase(); | |
| if($options['load-dump']) | |
| { | |
| $user = $this->withDatabase()->getDatabase('doctrine')->getParameter('username'); | |
| $password = $this->withDatabase()->getDatabase('doctrine')->getParameter('password'); | |
| `MYSQL_USER=$user MYSQL_PASSWORD=$password ./data/bin/load-dump`; | |
| } | |
| if(empty($options['files'])) | |
| { | |
| $config = sfYaml::load($file = dmOs::join(sfConfig::get('sf_root_dir'), 'config', 'dm', 'php-fixtures.yml')); | |
| if(!is_array($config)){ | |
| $this->logBlock($file . ' doesnt exist', 'ERROR_LARGE'); | |
| return; | |
| } | |
| if(!isset($config['php'])) | |
| { | |
| $this->logBlock($file . ' does not contain any php: key'); | |
| } | |
| $____files = $config['php']; | |
| }else{ | |
| $____files = $options['files']; | |
| } | |
| foreach($____files as $php) | |
| { | |
| $this->logSection('php', 'loading ' . $php); | |
| require $php; | |
| } | |
| } | |
| public function logPhp($msg, $line) | |
| { | |
| $this->logSection($line, $msg); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment