protected function doApply() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $storage = new Zeclib_DefaultMigrationStorage($query, $this->system); $storage->versionTable = $this->versionTable; $storage->containerDirectories[] = $this->containerDir->getPath(); $migrator = new Zeclib_Migrator($storage, $query); $migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this); $migrations = array(); $versions = preg_split('/[,\\s]+/', $this->version, 0, PREG_SPLIT_NO_EMPTY); foreach ($versions as $version) { try { $migrations[] = $migrator->loadMigration($version); } catch (Zeclib_MigrationException $e) { $message = $e->getMessage(); $this->log($message, Zeclib_MigrationLogger::TYPE_WARNING); } } $num = $migrator->apply($migrations); $this->log(sprintf('%d migrations are applied.', $num)); }
/** * Returns the stream with an additional linebreak. * * @return the resulting stream, or -1 * if the end of the resulting stream has been reached * * @throws IOException if the underlying stream throws an IOException * during reading */ function read($len = null) { if ($this->processed === true) { return -1; // EOF } // Read $php = null; while (($buffer = $this->in->read($len)) !== -1) { $php .= $buffer; } if ($php === null) { // EOF? return -1; } if (empty($php)) { $this->log("File is empty!", Project::MSG_WARN); return ''; // return empty string } // write buffer to a temporary file, since php_strip_whitespace() needs a filename $file = new PhingFile(tempnam(PhingFile::getTempDir(), 'stripwhitespace')); file_put_contents($file->getAbsolutePath(), $php); $output = file_get_contents($file->getAbsolutePath()) . "\r\n"; unlink($file->getAbsolutePath()); $this->processed = true; return $output; }
/** * do the work * @throws BuildException */ public function main() { $this->validateAttributes(); $filesToExtract = array(); if ($this->file !== null) { if (!$this->isDestinationUpToDate($this->file)) { $filesToExtract[] = $this->file; } else { $this->log('Nothing to do: ' . $this->todir->getAbsolutePath() . ' is up to date for ' . $this->file->getCanonicalPath(), Project::MSG_INFO); } } foreach ($this->filesets as $compressedArchiveFileset) { $compressedArchiveDirScanner = $compressedArchiveFileset->getDirectoryScanner($this->project); $compressedArchiveFiles = $compressedArchiveDirScanner->getIncludedFiles(); $compressedArchiveDir = $compressedArchiveFileset->getDir($this->project); foreach ($compressedArchiveFiles as $compressedArchiveFilePath) { $compressedArchiveFile = new PhingFile($compressedArchiveDir, $compressedArchiveFilePath); if ($compressedArchiveFile->isDirectory()) { throw new BuildException($compressedArchiveFile->getAbsolutePath() . ' compressed archive cannot be a directory.'); } if (!$this->isDestinationUpToDate($compressedArchiveFile)) { $filesToExtract[] = $compressedArchiveFile; } else { $this->log('Nothing to do: ' . $this->todir->getAbsolutePath() . ' is up to date for ' . $compressedArchiveFile->getCanonicalPath(), Project::MSG_INFO); } } } foreach ($filesToExtract as $compressedArchiveFile) { $this->extractArchive($compressedArchiveFile); } }
public function setDir(PhingFile $dir) { if (!$dir->exists()) { throw new BuildException("Can not find asset directory: " . $dir->getAbsolutePath(), $this->location); } $this->assetDir = $dir->getAbsolutePath(); }
public function main() { $plugin = $this->plugin->getAbsolutePath(); $infoFile = $plugin . '/' . self::INFO_FILE; if (!file_exists($infoFile)) { $message = sprintf('Unable to read plugin_info.php file at "%s"', $plugin); throw new BuildException($message); } require_once $infoFile; $class = new ReflectionClass('plugin_info'); try { $value = $class->getStaticPropertyValue($this->key); } catch (Exception $e) { $message = sprintf('Unable to read property with "%s"', $this->key); throw new BuildException($message, $e); } if (!is_string($value) && !is_int($value) && !is_float($value)) { $value = json_encode($value); } if ($this->to != '') { $this->project->setProperty($this->to, $value); } else { $this->log($value); } }
protected function destroyDatabase() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $mdb2 = $query->conn; $mdb2->loadModule('Manager'); $result = $mdb2->dropTable($this->versionTable); if (PEAR::isError($result)) { throw new BuildException($result->getMessage()); } }
/** * Construct a new FileInputStream. * * @param PhingFile|string $file Path to the file * @param boolean $append Whether to append (ignored) * @throws Exception - if invalid argument specified. * @throws IOException - if unable to open file. */ public function __construct($file, $append = false) { if ($file instanceof PhingFile) { $this->file = $file; } elseif (is_string($file)) { $this->file = new PhingFile($file); } else { throw new Exception("Invalid argument type for \$file."); } $stream = @fopen($this->file->getAbsolutePath(), "rb"); if ($stream === false) { throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); } parent::__construct($stream); }
/** * Constructs a new ProjectConfigurator object * This constructor is private. Use a static call to * <code>configureProject</code> to configure a project. * * @param Project $project the Project instance this configurator should use * @param PhingFile $buildFile the buildfile object the parser should use */ public function __construct(Project $project, PhingFile $buildFile) { $this->project = $project; $this->buildFile = new PhingFile($buildFile->getAbsolutePath()); $this->buildFileParent = new PhingFile($this->buildFile->getParent()); $this->parseEndTarget = new Target(); }
/** * Uses a builder class to create the output class. * This method assumes that the DataModelBuilder class has been initialized with the build properties. * @param OMBuilder $builder * @param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES). * @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic). */ protected function build(OMBuilder $builder, $overwrite = true) { $path = $builder->getClassFilePath(); $this->ensureDirExists(dirname($path)); $_f = new PhingFile($this->getOutputDirectory(), $path); // skip files already created once if ($_f->exists() && !$overwrite) { $this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE); return 0; } $script = $builder->build(); foreach ($builder->getWarnings() as $warning) { $this->log($warning, Project::MSG_WARN); } // skip unchanged files if ($_f->exists() && $script == $_f->contents()) { $this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE); return 0; } // write / overwrite new / changed files $action = $_f->exists() ? 'Updating' : 'Creating'; $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder))); file_put_contents($_f->getAbsolutePath(), $script); return 1; }
/** * @param array $files array of filenames * @param PhingFile $dir * @return boolean */ protected function archiveIsUpToDate($files, $dir) { $sfs = new SourceFileScanner($this); $mm = new MergeMapper(); $mm->setTo($this->zipFile->getAbsolutePath()); return count($sfs->restrict($files, $dir, null, $mm)) == 0; }
/** * */ public function parseFile($xmlFile) { try { $this->data = array(); try { $fr = new FileReader($xmlFile); } catch (Exception $e) { $f = new PhingFile($xmlFile); throw new BuildException("XML File not found: " . $f->getAbsolutePath()); } $br = new BufferedReader($fr); $this->parser = new ExpatParser($br); $this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0); $this->parser->setHandler($this); try { $this->parser->parse(); } catch (Exception $e) { print $e->getMessage() . "\n"; $br->close(); } $br->close(); } catch (Exception $e) { print $e->getMessage() . "\n"; print $e->getTraceAsString(); } return $this->data; }
/** * {@inheritDoc} */ public function parseFile(PhingFile $file) { if (!$file->canRead()) { throw new IOException("Unable to read file: " . $file); } try { // We load the Yaml class without the use of namespaces to prevent // parse errors in PHP 5.2. $parserClass = '\\Symfony\\Component\\Yaml\\Parser'; $parser = new $parserClass(); // Cast properties to array in case parse() returns null. $properties = (array) $parser->parse(file_get_contents($file->getAbsolutePath())); } catch (Exception $e) { if (is_a($e, '\\Symfony\\Component\\Yaml\\Exception\\ParseException')) { throw new IOException("Unable to parse contents of " . $file . ": " . $e->getMessage()); } throw $e; } $flattenedProperties = $this->flattenArray($properties); foreach ($flattenedProperties as $key => $flattenedProperty) { if (is_array($flattenedProperty)) { $flattenedProperties[$key] = implode(',', $flattenedProperty); } } return $flattenedProperties; }
public function checkFileExists() { //Get the correct path to asset switch ($this->type) { case Asset::ASSET_TYPE_CSS: $this->assetFolder = $this->paths['css']; break; case Asset::ASSET_TYPE_JS: $this->assetFolder = $this->paths['js']; break; case Asset::ASSET_TYPE_IMAGE: $this->assetFolder = $this->paths['images']; break; default: $folder = ''; } //Path to file $file = new PhingFile($this->assetsDir . '/' . $this->assetFolder . $this->file); //Check file exists if (!$file->exists()) { throw new BuildException("Unable to find asset file: " . $file->getAbsolutePath()); } //Check we can read it if (!$file->canRead()) { throw IOException("Unable to read asset file: " . $file->getPath()); } return $file; }
/** * do the work * @throws BuildException */ public function main() { if ($this->zipFile === null) { throw new BuildException("zipFile attribute must be set!", $this->getLocation()); } if ($this->zipFile->exists() && $this->zipFile->isDirectory()) { throw new BuildException("zipFile is a directory!", $this->getLocation()); } if ($this->zipFile->exists() && !$this->zipFile->canWrite()) { throw new BuildException("Can not write to the specified zipFile!", $this->getLocation()); } // shouldn't need to clone, since the entries in filesets // themselves won't be modified -- only elements will be added $savedFileSets = $this->filesets; try { if (empty($this->filesets)) { throw new BuildException("You must supply some nested filesets.", $this->getLocation()); } $this->log("Building ZIP: " . $this->zipFile->__toString(), Project::MSG_INFO); $zip = new PclZip($this->zipFile->getAbsolutePath()); if ($zip->errorCode() != 1) { throw new Exception("PclZip::open() failed: " . $zip->errorInfo()); } foreach ($this->filesets as $fs) { $files = $fs->getFiles($this->project, $this->includeEmpty); $fsBasedir = null != $this->baseDir ? $this->baseDir : $fs->getDir($this->project); $filesToZip = array(); for ($i = 0, $fcount = count($files); $i < $fcount; $i++) { $f = new PhingFile($fsBasedir, $files[$i]); //$filesToZip[] = realpath($f->getPath()); $fileAbsolutePath = $f->getPath(); $fileDir = rtrim(dirname($fileAbsolutePath), '/\\'); $fileBase = basename($fileAbsolutePath); if (substr($fileDir, -4) == '.svn') { continue; } if ($fileBase == '.svn') { continue; } if (substr(rtrim($fileAbsolutePath, '/\\'), -4) == '.svn') { continue; } //echo "\t\t$fileAbsolutePath\n"; $filesToZip[] = $f->getPath(); } /* $zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix , PCLZIP_OPT_REMOVE_PATH, realpath($fsBasedir->getPath()) ); */ $zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix, PCLZIP_OPT_REMOVE_PATH, $fsBasedir->getPath()); } } catch (IOException $ioe) { $msg = "Problem creating ZIP: " . $ioe->getMessage(); $this->filesets = $savedFileSets; throw new BuildException($msg, $ioe, $this->getLocation()); } $this->filesets = $savedFileSets; }
/** * Runs phpDocumentor 2 */ public function run() { $this->initializePhpDocumentor(); $cache = $this->app['descriptor.cache']; $cache->getOptions()->setCacheDir($this->destDir->getAbsolutePath()); $this->parseFiles(); $this->project->log("Transforming...", Project::MSG_VERBOSE); $this->transformFiles(); }
protected function doApply() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $storage = new Zeclib_DefaultMigrationStorage($query, $this->system); $storage->versionTable = $this->versionTable; $storage->containerDirectories[] = $this->containerDir->getPath(); $migrator = new Zeclib_Migrator($storage, $query); $migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this); $from = $this->from === '' ? null : $this->from; $to = $this->to === '' ? null : $this->to; $num = $migrator->up($from, $to); $this->log(sprintf('%d migrations are applied.', $num)); }
/** * Run the task. * * @throws BuildException trouble, probably file IO */ public function main() { if ($this->prefix != null && $this->regex != null) { throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation()); } //copy the properties file $allProps = array(); /* load properties from file if specified, otherwise use Phing's properties */ if ($this->inFile == null) { // add phing properties $allProps = $this->getProject()->getProperties(); } elseif ($this->inFile != null) { if ($this->inFile->exists() && $this->inFile->isDirectory()) { $message = "srcfile is a directory!"; $this->failOnErrorAction(null, $message, Project::MSG_ERR); return; } if ($this->inFile->exists() && !$this->inFile->canRead()) { $message = "Can not read from the specified srcfile!"; $this->failOnErrorAction(null, $message, Project::MSG_ERR); return; } try { $props = new Properties(); $props->load(new PhingFile($this->inFile)); $allProps = $props->getProperties(); } catch (IOException $ioe) { $message = "Could not read file " . $this->inFile->getAbsolutePath(); $this->failOnErrorAction($ioe, $message, Project::MSG_WARN); return; } } $os = null; try { if ($this->destfile == null) { $os = Phing::getOutputStream(); $this->saveProperties($allProps, $os); $this->log($os, Project::MSG_INFO); } else { if ($this->destfile->exists() && $this->destfile->isDirectory()) { $message = "destfile is a directory!"; $this->failOnErrorAction(null, $message, Project::MSG_ERR); return; } if ($this->destfile->exists() && !$this->destfile->canWrite()) { $message = "Can not write to the specified destfile!"; $this->failOnErrorAction(null, $message, Project::MSG_ERR); return; } $os = new FileOutputStream($this->destfile); $this->saveProperties($allProps, $os); } } catch (IOException $ioe) { $this->failOnErrorAction($ioe); } }
/** * List archive content * @param PhingFile Zip file to list content * @return array List of files inside $zipfile */ protected function listArchiveContent(PhingFile $zipfile) { $zip = new ZipArchive(); $zip->open($zipfile->getAbsolutePath()); $content = array(); for ($i = 0; $i < $zip->numFiles; $i++) { $content[] = array('filename' => $zip->getNameIndex($i)); } return $content; }
protected function doReset() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $storage = new Zeclib_DefaultMigrationStorage($query, $this->system); $storage->versionTable = $this->versionTable; $storage->containerDirectories[] = $this->containerDir->getPath(); $migrator = new Zeclib_Migrator($storage, $query); $migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this); $ignoreMissing = strncmp(strtolower($this->ignoreMissing), 'y', 1) == 0; $num = $migrator->down(null, null, $ignoreMissing); $this->log(sprintf('%d migrations are reverted.', $num)); $migrator->clear(); $this->log(sprintf('All migrations are removed from storage.', $num)); }
/** * Do the work * * @throws BuildException */ public function main() { if ($this->zipFile === null) { throw new BuildException("zipFile attribute must be set!", $this->getLocation()); } if ($this->zipFile->exists() && $this->zipFile->isDirectory()) { throw new BuildException("zipFile is a directory!", $this->getLocation()); } if ($this->zipFile->exists() && !$this->zipFile->canWrite()) { throw new BuildException("Can not write to the specified zipFile!", $this->getLocation()); } // shouldn't need to clone, since the entries in filesets // themselves won't be modified -- only elements will be added $savedFileSets = $this->filesets; try { if (empty($this->filesets)) { throw new BuildException("You must supply some nested filesets.", $this->getLocation()); } $this->log("Building ZIP: " . $this->zipFile->__toString(), Project::MSG_INFO); $zip = new PclZip($this->zipFile->getAbsolutePath()); if ($zip->errorCode() != 1) { throw new Exception("PclZip::open() failed: " . $zip->errorInfo()); } foreach ($this->filesets as $fs) { $files = $fs->getFiles($this->project, $this->includeEmpty); $fsBasedir = $this->baseDir != null ? $this->baseDir : $fs->getDir($this->project); $filesToZip = array(); foreach ($files as $file) { $f = new PhingFile($fsBasedir, $file); $fileAbsolutePath = $f->getPath(); $fileDir = rtrim(dirname($fileAbsolutePath), '/\\'); $fileBase = basename($fileAbsolutePath); // Only use lowercase for $disallowedBases because we'll convert $fileBase to lowercase $disallowedBases = array('.ds_store', '.svn', '.gitignore', 'thumbs.db'); $fileBaseLower = strtolower($fileBase); if (in_array($fileBaseLower, $disallowedBases)) { continue; } if (substr($fileDir, -4) == '.svn') { continue; } if (substr(rtrim($fileAbsolutePath, '/\\'), -4) == '.svn') { continue; } $filesToZip[] = $fileAbsolutePath; } $zip->add($filesToZip, PCLZIP_OPT_ADD_PATH, is_null($this->prefix) ? '' : $this->prefix, PCLZIP_OPT_REMOVE_PATH, $fsBasedir->getPath()); } } catch (IOException $ioe) { $msg = "Problem creating ZIP: " . $ioe->getMessage(); $this->filesets = $savedFileSets; throw new BuildException($msg, $ioe, $this->getLocation()); } $this->filesets = $savedFileSets; }
public function testFlipFlopTarget() { // calls target in main that depends on target in import that depends on // target orverridden in main $this->executeTarget("flipflop"); $f1 = new PhingFile(PHING_TEST_BASE . "/etc/tasks/importing.xml"); $f2 = new PhingFile(PHING_TEST_BASE . "/etc/tasks/imports/imported.xml"); $this->assertInLogs("This is " . $f1->getAbsolutePath() . " flop target."); $this->assertInLogs("This is " . $f2->getAbsolutePath() . " flip target."); $this->assertInLogs("This is " . $f1->getAbsolutePath() . " flipflop target."); }
/** * create the directory and all parents * * @throws BuildException if dir is somehow invalid, or creation failed. */ public function main() { if ($this->dir === null) { throw new BuildException("dir attribute is required", $this->location); } if ($this->dir->isFile()) { throw new BuildException("Unable to create directory as a file already exists with that name: " . $this->dir->getAbsolutePath()); } if (!$this->dir->exists()) { $result = $this->dir->mkdirs($this->mode); if (!$result) { if ($this->dir->exists()) { $this->log("A different process or task has already created " . $this->dir->getAbsolutePath()); return; } $msg = "Directory " . $this->dir->getAbsolutePath() . " creation was not successful for an unknown reason"; throw new BuildException($msg, $this->location); } $this->log("Created dir: " . $this->dir->getAbsolutePath()); } }
/** * Runs phpDocumentor 2 */ public function run() { $this->initializePhpDocumentor(); $xml = $this->parseFiles(); $this->project->log("Transforming...", Project::MSG_VERBOSE); $transformer = new phpDocumentor\Transformer\Transformer(); $transformer->setTemplatesPath($this->phpDocumentorPath . '/../data/templates'); $transformer->setTemplates($this->template); $transformer->setSource($xml); $transformer->setTarget($this->destDir->getAbsolutePath()); $transformer->execute(); }
/** * Transforms the parsed files */ private function transformFiles() { $transformer = $this->app['transformer']; $compiler = $this->app['compiler']; $builder = $this->app['descriptor.builder']; $projectDescriptor = $builder->getProjectDescriptor(); $transformer->getTemplates()->load($this->template, $transformer); $transformer->setTarget($this->destDir->getAbsolutePath()); foreach ($compiler as $pass) { $pass->execute($projectDescriptor); } }
protected function setupDatabase() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $mdb2 = $query->conn; $mdb2->loadModule('Manager'); $def = array('system' => array('type' => 'text', 'length' => 255, 'notnull' => 1), 'version' => array('type' => 'text', 'length' => 255, 'notnull' => 1)); $result = $mdb2->createTable($this->versionTable, $def); if (PEAR::isError($result)) { throw new BuildException($result->getMessage()); } $def = array('primary' => true, 'fields' => array('system' => array(), 'version' => array())); $name = $this->versionTable . '_primary'; $result = $mdb2->createConstraint($this->versionTable, $name, $def); if (PEAR::isError($result)) { throw new BuildException($result->getMessage()); } }
/** * Init a Archive_Tar class with correct compression for the given file. * * @param PhingFile $tarfile * @return Archive_Tar the tar class instance */ private function initTar(PhingFile $tarfile) { $compression = null; $tarfileName = $tarfile->getName(); $mode = strtolower(substr($tarfileName, strrpos($tarfileName, '.'))); $compressions = array('gz' => array('.gz', '.tgz'), 'bz2' => array('.bz2')); foreach ($compressions as $algo => $ext) { if (array_search($mode, $ext) !== false) { $compression = $algo; break; } } return new Archive_Tar($tarfile->getAbsolutePath(), $compression); }
/** * Iterate over all filesets and return all the filenames. * * @return array an array of filenames */ private function getFilenames() { $files = array(); foreach ($this->filesets as $fileset) { $ds = $fileset->getDirectoryScanner($this->project); $ds->scan(); $includedFiles = $ds->getIncludedFiles(); foreach ($includedFiles as $file) { $fs = new PhingFile(basename($ds->getBaseDir()), $file); $files[] = $fs->getAbsolutePath(); } } return $files; }
/** * [REQUIRED] Set the output directory. It will be * created if it doesn't exist. * @param PhingFile $outputDirectory * @return void * @throws Exception */ public function setOutputDirectory(PhingFile $outputDirectory) { try { if (!$outputDirectory->exists()) { $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(), Project::MSG_VERBOSE); if (!$outputDirectory->mkdirs()) { throw new IOException("Unable to create Ouptut directory: " . $outputDirectory->getAbsolutePath()); } } $this->outputDirectory = $outputDirectory->getCanonicalPath(); } catch (IOException $ioe) { throw new BuildException($ioe); } }
/** * Uses a builder class to create the output class. * This method assumes that the DataModelBuilder class has been initialized with the build properties. * @param OMBuilder $builder * @param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES). * @todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic). */ protected function build(OMBuilder $builder, $overwrite = true) { $path = $builder->getClassFilePath(); $this->ensureDirExists(dirname($path)); $_f = new PhingFile($this->getOutputDirectory(), $path); if ($overwrite || !$_f->exists()) { $this->log("\t\t-> " . $builder->getClassname() . " [builder: " . get_class($builder) . "]"); $script = $builder->build(); file_put_contents($_f->getAbsolutePath(), $script); foreach ($builder->getWarnings() as $warning) { $this->log($warning, Project::MSG_WARN); } } else { $this->log("\t\t-> (exists) " . $builder->getClassname()); } }
function transform() { $dir = new PhingFile($this->toDir); if (!$dir->exists()) { throw new BuildException("Directory '" . $this->toDir . "' does not exist"); } $xslfile = $this->getStyleSheet(); $xsl = new DOMDocument(); $xsl->load($xslfile->getAbsolutePath()); $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); ExtendedFileStream::registerStream(); // no output for the framed report // it's all done by extension... $proc->setParameter('', 'output.dir', $dir->getAbsolutePath()); $proc->transformToXML($this->document); }