Skip to content

[MAINTENANCE] Encapsulate access to physical structure data - part 1 - #2264

Open
beatrycze-volk wants to merge 4 commits into
kitodo:mainfrom
beatrycze-volk:physicalstructure
Open

beatrycze-volk wants to merge 4 commits into
kitodo:mainfrom
beatrycze-volk:physicalstructure

Conversation

@beatrycze-volk

Copy link
Copy Markdown
Collaborator

Direct access to the physicalStructure and physicalStructureInfo properties is now deprecated. Public getter methods, getPhysicalStructure() and getPhysicalStructureInfo(), have been introduced to provide a controlled API for retrieving this data, improving encapsulation.

Accessing these properties directly via __get() will now trigger a deprecation warning, guiding developers to use the new public methods. All internal usages have been updated accordingly.

@beatrycze-volk beatrycze-volk self-assigned this Nov 11, 2026
@beatrycze-volk beatrycze-volk added the ⟳ maintenance A task to keep the code up-to-date and manageable. label Nov 11, 2026
@beatrycze-volk
beatrycze-volk marked this pull request as draft November 11, 2026 15:21
Direct access to the `physicalStructure` and `physicalStructureInfo` properties is now deprecated. Public getter methods, `getPhysicalStructure()` and `getPhysicalStructureInfo()`, have been introduced to provide a controlled API for retrieving this data, improving encapsulation.

Accessing these properties directly via `__get()` will now trigger a deprecation warning, guiding developers to use the new public methods. All internal usages have been updated accordingly.
…nodes

Introduce `getPhysicalStructureNode()` in `AbstractDocument` to centralize and standardize access to individual physical structure nodes by their ID. This new method replaces direct indexed access to the `physicalStructureInfo` array, improving encapsulation and providing a consistent way to handle missing nodes by returning an empty array. All internal usages have been updated accordingly.
@beatrycze-volk
beatrycze-volk force-pushed the physicalstructure branch 2 times, most recently from d4b732c to 79ffa3b Compare November 12, 2026 12:06
Introduce `getPhysicalStructureNodeByPage()` to provide a direct way to retrieve physical structure metadata based on a page number. This new method encapsulates the previous two-step process of first resolving the physical structure ID from the `physicalStructure` array and then fetching the node using its ID.

This change improves code readability and reduces redundancy across the codebase by consolidating a common lookup pattern. It also includes a minor refinement to `getPhysicalStructureNode()` to gracefully handle empty IDs.
Introduce `abstract protected function loadPhysicalStructure()` to centralize the format-specific logic for populating the document's physical structure. The `getPhysicalStructure()` method in `AbstractDocument` is now concrete, providing a consistent public interface that internally manages lazy loading by invoking `loadPhysicalStructure()` if the data is not yet available.

This refactoring separates the concerns of *how* data is loaded (implemented by subclasses) from *when* it's loaded (managed by the abstract base class), reducing duplication and improving clarity in document type implementations. `getPhysicalStructureInfo()` also now utilizes this standardized loading mechanism.
@beatrycze-volk beatrycze-volk changed the title [MAINTENANCE] Encapsulate access to physical structure data [MAINTENANCE] Encapsulate access to physical structure data - part 1 Nov 12, 2026
@beatrycze-volk
beatrycze-volk marked this pull request as ready for review November 12, 2026 13:13
@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (f3aabee) to head (96e3a0a).

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #2264   +/-   ##
============================
============================

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⟳ maintenance A task to keep the code up-to-date and manageable.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant