DefinitionLinkbaseParser
in package
The DefinitionLinkbaseParser class is responsible for parsing taxonomy definition linkbase XML files. It processes arcs and relationships in the definition linkbase to establish the connections between taxonomy elements such as dimensions, hypercubes, domains, and members.
Table of Contents
Properties
Methods
- __construct() : void
- Constructor method for initializing the class with dependencies.
- parse() : void
- Parses the provided XML file and processes its content to resolve locators and establish relationships within a taxonomy structure.
- ensureDimension() : int
- Ensures the existence of a taxonomy dimension for the given taxonomy element ID.
- ensureDimensionDefault() : void
- Ensures the default values for a taxonomy dimension by inserting or updating the associated record in the taxonomy_dimension_default table.
- ensureDimensionDomain() : void
- Ensures the existence of a taxonomy dimension domain for the given taxonomy dimension ID and taxonomy element ID.
- ensureHypercube() : int
- Ensures the existence of a hypercube entry for the given taxonomy element ID in the database. If no matching entry exists, a new one is created.
- ensureHypercubeDimension() : void
- Ensures the association of a taxonomy hypercube with a taxonomy dimension, including the specified sort order. If an association already exists, the sort order is updated.
- ensureMember() : void
- Ensures the existence of a taxonomy member for the given taxonomy dimension ID and taxonomy element ID.
- ensureMemberRelation() : void
- Ensures the existence of a taxonomy member relation between the specified parent and child taxonomy elements.
- ensurePrimaryItemHypercube() : void
- Ensures the association between a primary taxonomy element and a taxonomy hypercube.
- logSkippedArc() : void
- Logs information about a skipped arc in the XBRL import process.
- resolvePair() : array<string|int, mixed>|null
- Resolves a pair of 'from' and 'to' elements using the provided resolvers and handles exceptions during the process.
Properties
$mySql
private
MySql
$mySql
$namespaceRegistry
private
NamespaceRegistry
$namespaceRegistry
Methods
__construct()
Constructor method for initializing the class with dependencies.
public
__construct(MySql $mySql, NamespaceRegistry $namespaceRegistry) : void
Parameters
- $mySql : MySql
-
An instance of the MySql database handler.
- $namespaceRegistry : NamespaceRegistry
-
An instance managing namespace registration.
parse()
Parses the provided XML file and processes its content to resolve locators and establish relationships within a taxonomy structure.
public
parse(string $file, LocatorResolver $resolver) : void
Parameters
- $file : string
-
The path to the XML file to be parsed.
- $resolver : LocatorResolver
-
An instance responsible for resolving references and relationships between taxonomy elements.
Tags
ensureDimension()
Ensures the existence of a taxonomy dimension for the given taxonomy element ID.
private
ensureDimension(int $taxonomyElementId) : int
If a dimension does not already exist, it creates one and retrieves its ID.
Parameters
- $taxonomyElementId : int
-
The ID of the taxonomy element for which the dimension is ensured or retrieved.
Return values
int —The ID of the ensured or existing taxonomy dimension.
ensureDimensionDefault()
Ensures the default values for a taxonomy dimension by inserting or updating the associated record in the taxonomy_dimension_default table.
private
ensureDimensionDefault(int $taxonomyDimensionId, int $taxonomyElementId, string|null $sortOrder) : void
Parameters
- $taxonomyDimensionId : int
-
The ID of the taxonomy dimension being ensured or updated.
- $taxonomyElementId : int
-
The ID of the taxonomy element associated with the dimension.
- $sortOrder : string|null
-
The sort order to be set or updated; null if no specific order is provided.
ensureDimensionDomain()
Ensures the existence of a taxonomy dimension domain for the given taxonomy dimension ID and taxonomy element ID.
private
ensureDimensionDomain(int $taxonomyDimensionId, int $taxonomyElementId, string|null $sortOrder) : void
If a domain does not already exist, it creates one or updates the sort order of the existing domain.
Parameters
- $taxonomyDimensionId : int
-
The ID of the taxonomy dimension to associate with the domain.
- $taxonomyElementId : int
-
The ID of the taxonomy element to associate with the domain.
- $sortOrder : string|null
-
The sort order to be applied to the domain. Null if no sort order is specified.
ensureHypercube()
Ensures the existence of a hypercube entry for the given taxonomy element ID in the database. If no matching entry exists, a new one is created.
private
ensureHypercube(int $taxonomyElementId) : int
Parameters
- $taxonomyElementId : int
-
The ID of the taxonomy element for which the hypercube entry is ensured.
Return values
int —The ID of the corresponding hypercube entry.
ensureHypercubeDimension()
Ensures the association of a taxonomy hypercube with a taxonomy dimension, including the specified sort order. If an association already exists, the sort order is updated.
private
ensureHypercubeDimension(int $taxonomyHypercubeId, int $taxonomyDimensionId, string|null $sortOrder) : void
Parameters
- $taxonomyHypercubeId : int
-
The ID of the taxonomy hypercube to associate with the dimension.
- $taxonomyDimensionId : int
-
The ID of the taxonomy dimension to associate with the hypercube.
- $sortOrder : string|null
-
The sort order for the association. Can be null if no specific sort order is required.
ensureMember()
Ensures the existence of a taxonomy member for the given taxonomy dimension ID and taxonomy element ID.
private
ensureMember(int $taxonomyDimensionId, int $taxonomyElementId) : void
If a member does not already exist, it creates one.
Parameters
- $taxonomyDimensionId : int
-
The ID of the taxonomy dimension to which the member belongs.
- $taxonomyElementId : int
-
The ID of the taxonomy element to be included as a member.
ensureMemberRelation()
Ensures the existence of a taxonomy member relation between the specified parent and child taxonomy elements.
private
ensureMemberRelation(int $parentTaxonomyElementId, int $childTaxonomyElementId, string|null $sortOrder, int $usable) : void
If a relation already exists, it updates the sort order and usability values.
Parameters
- $parentTaxonomyElementId : int
-
The ID of the parent taxonomy element.
- $childTaxonomyElementId : int
-
The ID of the child taxonomy element.
- $sortOrder : string|null
-
The sort order of the child element relative to the parent element. Can be null.
- $usable : int
-
The usability flag indicating whether the relation is usable.
ensurePrimaryItemHypercube()
Ensures the association between a primary taxonomy element and a taxonomy hypercube.
private
ensurePrimaryItemHypercube(int $primaryElementId, int $taxonomyHypercubeId, string $arcrole, string|null $sortOrder, int $closed, string $contextElement) : void
If the association does not already exist, it creates a new one. If it exists, it updates the association properties.
Parameters
- $primaryElementId : int
-
The ID of the primary taxonomy element being associated with the hypercube.
- $taxonomyHypercubeId : int
-
The ID of the taxonomy hypercube to associate with the primary taxonomy element.
- $arcrole : string
-
The arcrole that defines the type of relationship between the primary element and the hypercube.
- $sortOrder : string|null
-
The sorting order used for the association, or null if no specific order is defined.
- $closed : int
-
Indicates whether the hypercube association is closed (1 for true, 0 for
- $contextElement : string
logSkippedArc()
Logs information about a skipped arc in the XBRL import process.
private
logSkippedArc(string $file, string $reason, string $from, string $to, string $arcrole) : void
Records details such as the file name, arcrole, origin, destination, and the reason for skipping the arc into a log file.
Parameters
- $file : string
-
The name of the file where the skipped arc was encountered.
- $reason : string
-
The reason why the arc was skipped.
- $from : string
-
The source or originating point of the arc.
- $to : string
-
The destination or target point of the arc.
- $arcrole : string
-
The role or purpose of the arc being logged.
Return values
void —This method does not return a value.
resolvePair()
Resolves a pair of 'from' and 'to' elements using the provided resolvers and handles exceptions during the process.
private
resolvePair(LocatorResolver $resolver, string $from, string $to, callable $fromResolver, callable $toResolver, string $file, string $arcrole) : array<string|int, mixed>|null
If an exception occurs, it logs the skipped arc and returns null.
Parameters
- $resolver : LocatorResolver
-
The resolver instance used to resolve the elements.
- $from : string
-
The 'from' element to be processed.
- $to : string
-
The 'to' element to be processed.
- $fromResolver : callable
-
A callable used to resolve the 'from' element.
- $toResolver : callable
-
A callable used to resolve the 'to' element.
- $file : string
-
The file associated with the arc being resolved.
- $arcrole : string
-
The arcrole associated with the arc being resolved.
Return values
array<string|int, mixed>|null —An associative array with 'from' and 'to' keys containing resolved values, or null if resolution fails.