protected function inheritDatabaseAttributes(\DOMElement $databaseElement)
    {
        $attributesToInherit = [];
        foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
            if (!$databaseElement->hasAttribute($databaseAttribute)) {
                continue;
            }

            $attributesToInherit[$tableAttribute] = $databaseElement->getAttribute($databaseAttribute);
        }

        /** @var \DOMElement $tableElement */
        foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
            foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
                if (!isset($attributesToInherit[$tableAttribute])) {
                    continue;
                }

                if ($tableElement->hasAttribute($tableAttribute)) {
                    // do not inherit the attribute if the table defines its own
                    continue;
                }

                // add an inheritance notice
                $databaseAttributeInheritanceNoticeComment = $tableElement->ownerDocument->createComment(
                    "Attribute '{$tableAttribute}'"
                    . " inherited from parent database attribute '{$databaseAttribute}'"
                );
                $tableElement->insertBefore(
                    $databaseAttributeInheritanceNoticeComment,
                    $tableElement->firstChild
                );

                $tableElement->setAttribute($tableAttribute, $attributesToInherit[$tableAttribute]);
            }
        }
    }
protected function inheritDatabaseAttributes(\DOMElement $databaseElement)
    {
        $attributesToInherit = [];
        foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
            if (!$databaseElement->hasAttribute($databaseAttribute)) {
                continue;
            }

            $attributesToInherit[$tableAttribute] = $databaseElement->getAttribute($databaseAttribute);
        }

        /** @var \DOMElement $tableElement */
        foreach ($databaseElement->getElementsByTagName('table') as $tableElement) {
            foreach (static::$DATABASE_INHERITABLE_ATTRIBUTES as $databaseAttribute => $tableAttribute) {
                if (!isset($attributesToInherit[$tableAttribute])) {
                    continue;
                }

                if ($tableElement->hasAttribute($tableAttribute)) {
                    // do not inherit the attribute if the table defines its own
                    continue;
                }

                // add an inheritance notice
                $databaseAttributeInheritanceNoticeComment = $tableElement->ownerDocument->createComment(
                    "Attribute '{$tableAttribute}'"
                    . " inherited from parent database attribute '{$databaseAttribute}'"
                );
                $tableElement->insertBefore(
                    $databaseAttributeInheritanceNoticeComment,
                    $tableElement->firstChild
                );

                $tableElement->setAttribute($tableAttribute, $attributesToInherit[$tableAttribute]);
            }
        }
    }
protected function inheritDatabaseAttributes ( \ DOMElement $ databaseElement ) { $ attributesToInherit = [ ] ; foreach ( static :: $ DATABASE_INHERITABLE_ATTRIBUTES as $ databaseAttribute => $ tableAttribute ) { if ( ! $ databaseElement -> hasAttribute ( $ databaseAttribute ) ) { continue ; } $ attributesToInherit [ $ tableAttribute ] = $ databaseElement -> getAttribute ( $ databaseAttribute ) ; } /** @var \DOMElement $tableElement */ foreach ( $ databaseElement -> getElementsByTagName ( 'table' ) as $ tableElement ) { foreach ( static :: $ DATABASE_INHERITABLE_ATTRIBUTES as $ databaseAttribute => $ tableAttribute ) { if ( ! isset ( $ attributesToInherit [ $ tableAttribute ] ) ) { continue ; } if ( $ tableElement -> hasAttribute ( $ tableAttribute ) ) { // do not inherit the attribute if the table defines its own continue ; } // add an inheritance notice $ databaseAttributeInheritanceNoticeComment = $ tableElement -> ownerDocument -> createComment ( "Attribute '{$tableAttribute}'" . " inherited from parent database attribute '{$databaseAttribute}'" ) ; $ tableElement -> insertBefore ( $ databaseAttributeInheritanceNoticeComment , $ tableElement -> firstChild ) ; $ tableElement -> setAttribute ( $ tableAttribute , $ attributesToInherit [ $ tableAttribute ] ) ; } } }
Copy inheritable database attribute to the tables in the database.
@param \DOMElement $databaseElement Database element to process.
Copy inheritable database attribute to the tables in the database .