Example #1
0
 /**
  * 
  * @param string $taskName
  */
 public function runPhing($taskName)
 {
     // Copy Files
     $this->mySchemaBuilder->loadXmlFiles();
     // Create build.properties file
     $this->createBuildPropertiesFile($this->tmpDir . '/build.properties');
     // Create buildtime-conf file
     $this->createBuildTimeConfFile($this->tmpDir . '/buildtime-conf.xml');
     //
     $args = array();
     $args = $this->getPhingArguments();
     $args[] = $taskName;
     // Enable output buffering
     \Phing::setOutputStream(new \OutputStream(fopen('php://output', 'w')));
     \Phing::setErrorStream(new \OutputStream(fopen('php://output', 'w')));
     \Phing::startup();
     \Phing::setProperty('phing.home', getenv('PHING_HOME'));
     //
     $myPhing = new \Phing();
     //$returnStatus = true;
     $myPhing->execute($args);
     $myPhing->runBuild();
     /*$this->buffer = ob_get_contents();
       // Guess errors
       if (strstr($this->buffer, 'failed. Aborting.') ||
           strstr($this->buffer, 'Failed to execute') ||
           strstr($this->buffer, 'failed for the following reason:')) {
       }*/
 }
Example #2
0
 protected function callPhing($taskName, $checkSchema, $properties = array())
 {
     $schemas = sfFinder::type('file')->name('*schema.xml')->relative()->follow_link()->in(sfConfig::get('sf_config_dir'));
     if (self::CHECK_SCHEMA === $checkSchema && !$schemas) {
         throw new sfCommandException('You must create a schema.yml or schema.xml file.');
     }
     // Call phing targets
     sfToolkit::addIncludePath(array(sfConfig::get('sf_symfony_lib_dir'), sfConfig::get('sf_propel_generator_path', realpath(dirname(__FILE__) . '/../vendor/propel-generator/classes'))));
     $args = array();
     $bufferPhingOutput = null === $this->commandApplication || !$this->commandApplication->withTrace();
     $properties = array_merge(array('build.properties' => 'propel.ini', 'project.dir' => sfConfig::get('sf_config_dir'), 'propel.output.dir' => sfConfig::get('sf_root_dir')), $properties);
     foreach ($properties as $key => $value) {
         $args[] = "-D{$key}={$value}";
     }
     // Build file
     $args[] = '-f';
     $args[] = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'propel-generator' . DIRECTORY_SEPARATOR . 'build.xml');
     // Logger
     if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) {
         $args[] = '-logger';
         $args[] = 'phing.listener.AnsiColorLogger';
     }
     // Add our listener to detect errors
     $args[] = '-listener';
     $args[] = 'sfPhingListener';
     // Add any arbitrary arguments last
     foreach ($this->additionalPhingArgs as $arg) {
         if (in_array($arg, array('verbose', 'debug'))) {
             $bufferPhingOutput = false;
         }
         $args[] = '-' . $arg;
     }
     $args[] = $taskName;
     // filter arguments through the event dispatcher
     $args = $this->dispatcher->filter(new sfEvent($this, 'propel.filter_phing_args'), $args)->getReturnValue();
     require_once dirname(__FILE__) . '/sfPhing.class.php';
     // enable output buffering
     Phing::setOutputStream(new OutputStream(fopen('php://output', 'w')));
     Phing::startup();
     Phing::setProperty('phing.home', getenv('PHING_HOME'));
     $this->logSection('propel', 'Running "' . $taskName . '" phing task');
     if ($bufferPhingOutput) {
         ob_start();
     }
     $m = new sfPhing();
     $m->execute($args);
     $m->runBuild();
     if ($bufferPhingOutput) {
         ob_end_clean();
     }
     chdir(sfConfig::get('sf_root_dir'));
     // any errors?
     $ret = true;
     if (sfPhingListener::hasErrors()) {
         $messages = array('Some problems occurred when executing the task:');
         foreach (sfPhingListener::getExceptions() as $exception) {
             $messages[] = '';
             $messages[] = preg_replace('/^.*build\\-propel\\.xml/', 'build-propel.xml', $exception->getMessage());
             $messages[] = '';
         }
         if (count(sfPhingListener::getErrors())) {
             $messages[] = 'If the exception message is not clear enough, read the output of the task for';
             $messages[] = 'more information';
         }
         $this->logBlock($messages, 'ERROR_LARGE');
         $ret = false;
     }
     return $ret;
 }
Example #3
0
 /**
  * Run propel phing commands
  *
  * @param string $cmd	phing target
  * @param array $argv arguments
  * @return string
  */
 public static function propelGen($cmd = '', $argv = array())
 {
     $autoloader = App::getInstance()->autoloader;
     $generatorBase = dirname(dirname(dirname($autoloader->findFile('AbstractPropelDataModelTask'))));
     $buildXml = $generatorBase . '/build.xml';
     $projectPath = \Curry\App::getInstance()['projectPath'] . '/propel';
     $argv[] = '-logger';
     $argv[] = 'phing.listener.AnsiColorLogger';
     $argv[] = '-f';
     $argv[] = $buildXml;
     $argv[] = '-Dproject.dir=' . $projectPath;
     if ($cmd) {
         $argv[] = $cmd;
     }
     $cwd = getcwd();
     $stream = fopen("php://temp", 'r+');
     $outputStream = new OutputStream($stream);
     Phing::setOutputStream($outputStream);
     Phing::setErrorStream($outputStream);
     Phing::startup();
     Phing::fire($argv);
     rewind($stream);
     $content = stream_get_contents($stream);
     Phing::shutdown();
     chdir($cwd);
     if (extension_loaded('apc')) {
         @apc_clear_cache();
     }
     return $content;
 }