Iterates through each datamodel/database, dumps the contents of all tables and creates a DOM XML doc.

@return void
@throws BuildException
3576
public function main()
    {
        $this->validate();

        $buf = "Database settings:\n"
            . " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)" ). "\n"
            . " URL: " . $this->databaseUrl . "\n"
            . ($this->databaseUser ? " user: " . $this->databaseUser . "\n" : "")
            . ($this->databasePassword ? " password: " . $this->databasePassword . "\n" : "");

        $this->log($buf, Project::MSG_VERBOSE);

        // 1) First create the Data XML -> database name map.
        $this->createDataDbMap();

        // 2) Now go create the XML files from teh database(s)
        foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
            foreach ($dataModel->getDatabases() as $database) {

                // if database name is specified, then we only want to dump that one db.
                if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {

                    $outFile = $this->getMappedFile($dataModel->getName());

                    $this->log("Dumping data to XML for database: " . $database->getName());
                    $this->log("Writing to XML file: " . $outFile->getName());

                    try {
                        $this->conn = $dataModel->getGeneratorConfig()->getBuildPDO($database->getName());

                        $doc = $this->createXMLDoc($database);
                        $doc->save($outFile->getAbsolutePath());
                    } catch (SQLException $se) {
                        $this->log("SQLException while connecting to DB: " . $se->getMessage(), Project::MSG_ERR);
                        throw new BuildException($se);
                    }
                } // if databaseName && database->getName == databaseName
            } // foreach database
        } // foreach datamodel
    }
453786
public function main()
	{
		$result = array();

		if( !isset( $this->_file ) && count( $this->_filesets ) == 0 ) {
			throw new BuildException( "Missing either a nested fileset or attribute 'file' set" );
		}

		if( !isset( $this->_optfile ) || ( $string = file_get_contents( $this->_optfile ) ) === false ) {
			throw new BuildException( sprintf( 'Unable to open optfile "%1$s"', $this->_optfile ) );
		}

		if( ( $options = unserialize( $string ) ) === false ) {
			throw new BuildException( sprintf( 'Unable to unserialize content of file "%1$s"', $this->_optfile ) );
		}

		if( $this->_file instanceof PhingFile )
		{
			$this->_extract( $this->_file->getPath(), $options );
		}
		else // process filesets
		{
			$project = $this->getProject();

			foreach( $this->_filesets as $fs )
			{
				$files = $fs->getDirectoryScanner( $project )->getIncludedFiles();
				$dir = $fs->getDir( $this->project )->getPath();

				foreach( $files as $file ) {
					$this->_extract( $dir . DIRECTORY_SEPARATOR . $file, $options );
				}
			}
		}

		$len = strlen( $this->_keyprefix );

		foreach( $options as $key => $values )
		{
			if( strncmp( $key, $this->_keyprefix, $len ) !== 0 ) {
				unset( $options[$key] );
			} else if( strpos( $key, 'unknown' ) !== false ) {
				unset( $options[$key] );
			} else if( !isset( $values['short'] ) && $key[0] !== "\n" ) {
				$this->log( 'No doc: ' . $key );
			}
		}

		ksort( $options );
		$this->log( 'Number of config options for ' . $this->_keyprefix . ': ' . count( $options ) );

		$this->_createWikiPages( $options );
	}
391391
protected function build()
    {
        $operation = $this->buildOperation('ListProfiles');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        if ($this->customerId) {
            $xmlMPayTid = $this->document->createElement('customerID', $this->customerId);
            $operation->appendChild($xmlMPayTid);
        }

        if ($this->expiredBy) {
            $xmlMPayTid = $this->document->createElement('expiredBy', $this->expiredBy);
            $operation->appendChild($xmlMPayTid);
        }

        if ($this->begin) {
            $xmlMPayTid = $this->document->createElement('begin', $this->begin);
            $operation->appendChild($xmlMPayTid);
        }

        if ($this->size) {
            $xmlMPayTid = $this->document->createElement('size', $this->size);
            $operation->appendChild($xmlMPayTid);
        }
    }
401414
public function build()
    {
        $this->isValidField($this->classMetadata, $this->fieldName);

        $this->classMetadata->appendExtension($this->getExtensionName(), [
            'slugs' => [
                $this->fieldName => $this->makeConfiguration(),
            ],
        ]);
    }
309030
protected function build()
    {
        $operation = $this->buildOperation('CreateCustomer');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $pType = $this->document->createElement('pType', $this->pType);
        $operation->appendChild($pType);

        $paymentData = $this->document->createElement('paymentData');
        $paymentData->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:type', 'etp:PaymentData' . $this->pType);
        $paymentData = $operation->appendChild($paymentData);

        $this->appendArray($paymentData, $this->paymentData);

        $customerID = $this->document->createElement('customerID', $this->customerId);
        $operation->appendChild($customerID);
        $this->appendArray($operation, $this->additional);
    }
687543
@Override
    public void build() throws DocletException {
        if (writer == null) {
            //Doclet does not support this output.
            return;
        }
        build(layoutParser.parseXML(ROOT), contentTree);
    }
1164163
public void build() throws IOException {
        if (! serialClassFoundToDocument(configuration.root.classes())) {
            //Nothing to document.
            return;
        }
        try {
            writer = configuration.getWriterFactory().getSerializedFormWriter();
            if (writer == null) {
                //Doclet does not support this output.
                return;
            }
        } catch (Exception e) {
            throw new DocletAbortException(e);
        }
        build(layoutParser.parseXML(NAME), contentTree);
        writer.close();
    }
935908
public function build()
    {
        $files = $this->filesystem->listFiles($this->directory);

        $this->cache->clear();

        foreach ($files as $file) {
            if ($file['extension'] == 'yml' || $file['extension'] == 'yaml') {
                $this->cache->put($file['filename'], $this->yaml->parse($this->filesystem->read($file['path'])));
            }
        }

        $this->cache->persist();
        $this->updateValues();
    }
1201750
public function main()
    {
        $this->loadDependencies();

        if (!isset($this->file) && count($this->filesets) == 0) {
            throw new BuildException('Missing either a nested fileset or attribute "file" set');
        }

        if (count($this->formatters) == 0) {
            // turn legacy format attribute into formatter
            $fmt = new PHPCPDFormatterElement($this);
            $fmt->setType($this->format);
            $fmt->setUseFile(false);

            $this->formatters[] = $fmt;
        }

        $this->validateFormatters();

        $filesToParse = [];

        if ($this->file instanceof PhingFile) {
            $filesToParse[] = $this->file->getPath();
        } else {
            // append any files in filesets
            foreach ($this->filesets as $fs) {
                $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();

                foreach ($files as $filename) {
                    $f = new PhingFile($fs->getDir($this->project), $filename);
                    $filesToParse[] = $f->getAbsolutePath();
                }
            }
        }

        $this->log('Processing files...');

        if ($this->oldVersion) {
            $detectorClass = 'PHPCPD_Detector';
            $strategyClass = 'PHPCPD_Detector_Strategy_Default';
        } else {
            $detectorClass = '\\SebastianBergmann\\PHPCPD\\Detector\\Detector';
            $strategyClass = '\\SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy';
        }

        $detector = new $detectorClass(new $strategyClass());
        $clones = $detector->copyPasteDetection(
            $filesToParse,
            $this->minLines,
            $this->minTokens,
            $this->fuzzy
        );

        $this->log('Finished copy/paste detection');

        foreach ($this->formatters as $fe) {
            $formatter = $fe->getFormatter();
            $formatter->processClones(
                $clones,
                $this->project,
                $fe->getUseFile(),
                $fe->getOutfile()
            );
        }
    }
1013075
public function build()
    {
        $this->classMetadata->mergeExtension($this->getExtensionName(), [
            $this->key => $this->fieldName,
        ]);
    }
598020
public function build()
    {
        $value = $this->getValue();

        $this->uppercaseComparator();

        // Check for IS/IS NOT and set the value to NULL if it is.
        if ($this->isComparatorIsNotNullIsNull()) {
            $value = null;
        }

        // Check for IN/NOT IN and build a nice comma-separated list.
        if (!$this->isComparatorIsNotNullIsNull() && $this->isComparatorInNotIn() && is_array($value)) {
            $this->uppercaseComparator();
            $valueArray = [];
            foreach ($value as $valueItem) {
                if ($this->shouldQuoteValues()) {
                    $valueArray[] = $this->query->quote($valueItem);
                } else {
                    $valueArray[] = $valueItem;
                }
            }
            $value = '(' . implode(',', $valueArray) . ')';
        }

        // Now check if we need to still quote the value.
        if (!$this->isComparatorIsNotNullIsNull() && !$this->isComparatorInNotIn() && $this->shouldQuoteValues()) {
            $value = $this->query->quote($value);
        }

        // If we don't have IN/NOT IN, IS/NOT IS, and we shouldn't quote, we assume we're checking fields.
        if ($this->shouldCompareFields()) {
            $valueBuild = [
                $this->query->quoteIdentifier($this->getTableName()),
                '.',
                $this->query->quoteIdentifier($value),
            ];
            $value = implode($valueBuild);
        }

        $tableName = $this->getTableName();
        if ($this->getJoinTableName()) {
            $tableName = $this->getJoinTableName();
        }
        $tableName = $this->query->quoteIdentifier($tableName);

        $returnArray = [
            $tableName . '.' . $this->query->quoteIdentifier($this->getKey()),
            $this->getComparator(),
            $value,
        ];
        $returnString = implode(' ', $returnArray);

        return trim($returnString);
    }
761962
public function main()
    {
        $this->setup('info');

        if ($this->oldVersion) {
            $output = $this->run(['--xml', '--incremental']);

            if (!($xmlObj = @simplexml_load_string($output))) {
                throw new BuildException("Failed to parse the output of 'svn info --xml'.");
            }

            $object = $xmlObj->{$this->element};

            if (!empty($this->subElement)) {
                $object = $object->{$this->subElement};
            }
        } else {
            $output = $this->run();

            if (empty($output) || !isset($output['entry'][0])) {
                throw new BuildException("Failed to parse the output of 'svn info'.");
            }

            $object = $output['entry'][0][$this->element];

            if (!empty($this->subElement)) {
                $object = $object[$this->subElement];
            }
        }

        $this->project->setProperty($this->getPropertyName(), (string) $object);
    }
1290601
protected function loadDataModels()
    {
        $schemas = [];
        $totalNbTables   = 0;
        $dataModelFiles  = $this->getSchemas();
        $defaultPlatform = $this->getGeneratorConfig()->getConfiguredPlatform();

        // Make a transaction for each file
        foreach ($dataModelFiles as $schema) {
            $dmFilename = $schema->getPathName();
            $this->log('Processing: ' . $schema->getFileName());

            $dom = new \DOMDocument('1.0', 'UTF-8');
            $dom->load($dmFilename);

            $this->includeExternalSchemas($dom, $schema->getPath());

            // normalize (or transform) the XML document using XSLT
            if ($this->getGeneratorConfig()->get()['generator']['schema']['transform'] && $this->xsl) {
                $this->log('Transforming ' . $dmFilename . ' using stylesheet ' . $this->xsl->getPath());

                if (!class_exists('\XSLTProcessor')) {
                    $this->log('Could not perform XLST transformation. Make sure PHP has been compiled/configured to support XSLT.');
                } else {
                    // normalize the document using normalizer stylesheet
                    $xslDom = new \DOMDocument('1.0', 'UTF-8');
                    $xslDom->load($this->xsl->getAbsolutePath());
                    $xsl = new \XsltProcessor();
                    $xsl->importStyleSheet($xslDom);
                    $dom = $xsl->transformToDoc($dom);
                }
            }

            // validate the XML document using XSD schema
            if ($this->validate && $this->xsd) {
                $this->log('  Validating XML using schema ' . $this->xsd->getPath());

                if (!$dom->schemaValidate($this->xsd->getAbsolutePath())) {
                    throw new EngineException(sprintf("XML schema file (%s) does not validate. See warnings above for reasons validation failed (make sure error_reporting is set to show E_WARNING if you don't see any).", $dmFilename), $this->getLocation());
                }
            }

            $xmlParser = new SchemaReader($defaultPlatform, $this->dbEncoding);
            $xmlParser->setGeneratorConfig($this->getGeneratorConfig());
            $schema = $xmlParser->parseString($dom->saveXML(), $dmFilename);
            $nbTables = $schema->getDatabase(null, false)->countTables();
            $totalNbTables += $nbTables;

            $this->log(sprintf('  %d tables processed successfully', $nbTables));

            $schema->setName($dmFilename);
            $schemas[] = $schema;
        }

        $this->log(sprintf('%d tables found in %d schema files.', $totalNbTables, count($dataModelFiles)));

        if (empty($schemas)) {
            throw new BuildException('No schema files were found (matching your schema fileset definition).');
        }

        foreach ($schemas as $schema) {
            // map schema filename with database name
            $this->dataModelDbMap[$schema->getName()] = $schema->getDatabase(null, false)->getName();
        }

        if (count($schemas) > 1 && $this->getGeneratorConfig()->get()['generator']['packageObjectModel']) {
            $schema = $this->joinDataModels($schemas);
            $this->dataModels = [$schema];
        } else {
            $this->dataModels = $schemas;
        }

        foreach ($this->dataModels as &$schema) {
            $schema->doFinalInitialization();
        }

        $this->dataModelsLoaded = true;
    }
765221
protected function buildXml()
  {
    parent::buildXml();

   $checkedFiles = array();
   if ( !empty($_POST['files']) && is_array($_POST['files']) ){
     foreach ( $_POST['files'] as $file){
       $checkedFiles[$file['name']] = $file;
     }
   }

   for ($i = 0; $i < $this->zip->numFiles; $i++)
    {
      $fileName = $this->zip->getNameIndex($i);
      if ( !empty($checkedFiles[$fileName]) && $checkedFiles[$fileName]['options'] == 'ok' )
      {
        // file was sucessfully unzipped before
        $this->appendUnzippedNode($this->unzippedNodes,$fileName);
        continue;
      }

      $filePathInfo = pathinfo($fileName);
      $fileType = 'File';
      $fileStat = $this->zip->statName($i);
      if ( empty($filePathInfo['extension']) && empty($fileStat['size']) ){
        $fileType = 'Folder';
        // check if we can create subfolder
        if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FOLDER_CREATE ) ){
          $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
          $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType);
          continue;
        }
      }
      $extractPath = $this->_currentFolder->getServerPath();
      $extractClientPath = $this->_currentFolder->getClientPath();

      $sFileName = $this->checkOneFile( $filePathInfo, $fileName );
      // security test failed, add to skipped
      if ( false !== $sFileName )
      {
        if ( file_exists($extractPath.$sFileName) )
        {
          if ( !is_dir($extractPath.$sFileName) )
          {
            // file was checked before
            if ( !empty($checkedFiles[$fileName]['options']) )
            {
              if ( $checkedFiles[$fileName]['options'] == 'autorename')
              {
                $sFileName = CKFinder_Connector_Utils_FileSystem::autoRename($extractPath,$sFileName);
                $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName);
              }
              elseif ( $checkedFiles[$fileName]['options'] == 'overwrite')
              {
                if ( !$this->_currentFolder->checkAcl( CKFINDER_CONNECTOR_ACL_FILE_DELETE ) ){
                  $this->errorCode = CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED;
                  $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType);
                  continue;
                }
                if (!CKFinder_Connector_Utils_FileSystem::unlink($extractPath.$sFileName))
                {
                  $this->errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
                  $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType);
                }
                else
                {
                  $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName);
                }
              }
              else
              {
                // add to skipped files
                $this->appendUnzippedNode($this->unzippedNodes,$fileName,'skip');
              }
            }
            else
            {
              $this->errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST;
              $this->appendErrorNode($this->skippedFilesNode, $this->errorCode, $fileName, $fileType);
            }
          }
        }
        // file doesn't exist yet
        else
        {
          $this->extractTo($extractPath,$extractClientPath,$filePathInfo,$sFileName,$fileName);
        }
      }
    }
    $this->zip->close();

    $this->_connectorNode->addChild($this->unzippedNodes);

    if ($this->errorCode != CKFINDER_CONNECTOR_ERROR_NONE) {
      $this->_connectorNode->addChild($this->skippedFilesNode);
      $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ZIP_FAILED);
    }
  }
1238997
protected function build()
    {
        $operation = $this->buildOperation('ManualReverse');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        $xmlMPayTid = $this->document->createElement('mpayTID', $this->mpayTid);
        $operation->appendChild($xmlMPayTid);
    }
545899
protected function buildXml()
	{
		$buffer = array();

		$buffer[] = '<?xml version="1.0"?>';
		$buffer[] = '<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
		$buffer[] = ' <database name="">';

		$buffer = array_merge($buffer, $this->buildXmlStructure());

		$buffer[] = ' </database>';
		$buffer[] = '</mysqldump>';

		return implode("\n", $buffer);
	}
418419
private function buildTable() {
        $result = $this->getDbAdapter()->query('SHOW CREATE TABLE `' . $this->getName() . '`')->fetchAll();
        $rawResult = $result[0]['Create Table'];
        $rawResult = $this->buildLines($rawResult);
        $rawResult = trim($rawResult);
        if(preg_match('@^ENGINE=(?P<engine>[^ ]+) (AUTO_INCREMENT=\d+ )?DEFAULT CHARSET=(?P<defaultCharset>[^ ]+) COLLATE=(?P<collate>[^ ]+)$@', $rawResult, $matches)) {
            $this->setEngine($matches['engine']);
            $this->setDefaultCharset($matches['defaultCharset']);
            $this->setCollate($matches['collate']);
        }
    }