public function combine(array $schemaDocuments = [], array $externalSchemaDocuments = [])
    {
        $globalDatabaseElements = [];

        // merge schema documents, per database
        foreach ($schemaDocuments as $sourceSchemaDocument) {
            if (!$sourceSchemaDocument instanceof \DOMDocument) {
                throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
            }

            // work on document clones since we are going to edit them
            $sourceSchemaDocument = clone $sourceSchemaDocument;

            // process all <database> elements in the document
            /** @var \DOMElement $sourceDatabaseElement */
            foreach ($sourceSchemaDocument->getElementsByTagName('database') as $sourceDatabaseElement) {
                // pre-process the element
                $this->filterExternalSchemaElements($sourceDatabaseElement);
                $this->inheritDatabaseAttributes($sourceDatabaseElement);
                $this->applyDatabaseTablePrefix($sourceDatabaseElement);

                // append the element
                $this->mergeDatabaseElement($sourceDatabaseElement);
            }
        }

        // include external schema documents, per database
        foreach ($externalSchemaDocuments as $externalSchemaDocument) {
            if (!$externalSchemaDocument instanceof \DOMDocument) {
                throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
            }

            // process all <database> elements in the document
            /** @var \DOMElement $externalSchemaDatabaseElement */
            foreach ($externalSchemaDocument->getElementsByTagName('database') as $externalSchemaDatabaseElement) {
                // include the document
                $this->includeExternalSchema($externalSchemaDatabaseElement);
            }
        }

        // return the documents, not the database elements
        $globalSchemaDocuments = [];
        /**
         * @var string $database
         * @var \DOMElement $globalDatabaseElement
         */
        foreach ($globalDatabaseElements as $database => $globalDatabaseElement) {
            $globalSchemaDocuments[$database] = $globalDatabaseElement->ownerDocument;
        }

        return $globalSchemaDocuments;
    }
public function combine(array $schemaDocuments = [], array $externalSchemaDocuments = [])
    {
        $globalDatabaseElements = [];

        // merge schema documents, per database
        foreach ($schemaDocuments as $sourceSchemaDocument) {
            if (!$sourceSchemaDocument instanceof \DOMDocument) {
                throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
            }

            // work on document clones since we are going to edit them
            $sourceSchemaDocument = clone $sourceSchemaDocument;

            // process all <database> elements in the document
            /** @var \DOMElement $sourceDatabaseElement */
            foreach ($sourceSchemaDocument->getElementsByTagName('database') as $sourceDatabaseElement) {
                // pre-process the element
                $this->filterExternalSchemaElements($sourceDatabaseElement);
                $this->inheritDatabaseAttributes($sourceDatabaseElement);
                $this->applyDatabaseTablePrefix($sourceDatabaseElement);

                // append the element
                $this->mergeDatabaseElement($sourceDatabaseElement);
            }
        }

        // include external schema documents, per database
        foreach ($externalSchemaDocuments as $externalSchemaDocument) {
            if (!$externalSchemaDocument instanceof \DOMDocument) {
                throw new \InvalidArgumentException('Schema file is not a \DOMDocument');
            }

            // process all <database> elements in the document
            /** @var \DOMElement $externalSchemaDatabaseElement */
            foreach ($externalSchemaDocument->getElementsByTagName('database') as $externalSchemaDatabaseElement) {
                // include the document
                $this->includeExternalSchema($externalSchemaDatabaseElement);
            }
        }

        // return the documents, not the database elements
        $globalSchemaDocuments = [];
        /**
         * @var string $database
         * @var \DOMElement $globalDatabaseElement
         */
        foreach ($globalDatabaseElements as $database => $globalDatabaseElement) {
            $globalSchemaDocuments[$database] = $globalDatabaseElement->ownerDocument;
        }

        return $globalSchemaDocuments;
    }
public function combine ( array $ schemaDocuments = [ ] , array $ externalSchemaDocuments = [ ] ) { $ globalDatabaseElements = [ ] ; // merge schema documents, per database foreach ( $ schemaDocuments as $ sourceSchemaDocument ) { if ( ! $ sourceSchemaDocument instanceof \ DOMDocument ) { throw new \ InvalidArgumentException ( 'Schema file is not a \DOMDocument' ) ; } // work on document clones since we are going to edit them $ sourceSchemaDocument = clone $ sourceSchemaDocument ; // process all <database> elements in the document /** @var \DOMElement $sourceDatabaseElement */ foreach ( $ sourceSchemaDocument -> getElementsByTagName ( 'database' ) as $ sourceDatabaseElement ) { // pre-process the element $ this -> filterExternalSchemaElements ( $ sourceDatabaseElement ) ; $ this -> inheritDatabaseAttributes ( $ sourceDatabaseElement ) ; $ this -> applyDatabaseTablePrefix ( $ sourceDatabaseElement ) ; // append the element $ this -> mergeDatabaseElement ( $ sourceDatabaseElement ) ; } } // include external schema documents, per database foreach ( $ externalSchemaDocuments as $ externalSchemaDocument ) { if ( ! $ externalSchemaDocument instanceof \ DOMDocument ) { throw new \ InvalidArgumentException ( 'Schema file is not a \DOMDocument' ) ; } // process all <database> elements in the document /** @var \DOMElement $externalSchemaDatabaseElement */ foreach ( $ externalSchemaDocument -> getElementsByTagName ( 'database' ) as $ externalSchemaDatabaseElement ) { // include the document $ this -> includeExternalSchema ( $ externalSchemaDatabaseElement ) ; } } // return the documents, not the database elements $ globalSchemaDocuments = [ ] ; /**
         * @var string $database
         * @var \DOMElement $globalDatabaseElement
         */ foreach ( $ globalDatabaseElements as $ database => $ globalDatabaseElement ) { $ globalSchemaDocuments [ $ database ] = $ globalDatabaseElement -> ownerDocument ; } return $ globalSchemaDocuments ; }
Combine multiple schemas into one schema per database.
@param \DOMDocument[] $schemaDocuments Schema documents to combine.
@param \DOMDocument[] $externalSchemaDocuments Schemas documents to include as external schemas in the combined
documents.
@return array A map of [database name => \DOMDocument schema for that database].
Combine multiple schemas into one schema per database .