Skip to content

refactor: make Acorn Socials package more modular#29

Open
dulgermuhammet wants to merge 2 commits into
mainfrom
issues/28/Make-acorn-socials-package-more-modular
Open

refactor: make Acorn Socials package more modular#29
dulgermuhammet wants to merge 2 commits into
mainfrom
issues/28/Make-acorn-socials-package-more-modular

Conversation

@dulgermuhammet
Copy link
Copy Markdown
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug fix
  • Breaking change
  • Requires manual action post-deploy
  • Optimisation
  • Documentation update

Description

This PR refactors the Acorn Socials package to make it more modular and reusable. The changes extract common repository functionality into an abstract base class and use dependency injection with interfaces rather than concrete implementations, allowing the package to be used independently of the Customizer integration.

Related Tickets & Documents

Changes

  • Created AbstractSectionRepository abstract class with common repository methods (getSharableSocials(), getSocialPages())
  • Updated SectionRepositoryInterface to include all repository method signatures
  • Refactored AcornSocials to depend on SectionRepositoryInterface instead of concrete SocialsSectionRepository
  • Made HookManager nullable to allow flexible usage without requiring hook registration
  • Removed duplicate code from SocialsSectionRepository by extending abstract class
  • Added conditional hook registration only when HookManager is provided

Impact

Affected areas:

  • Repository layer architecture
  • Dependency injection setup
  • Hook registration behaviour

Breaking changes:

  • None (backwards compatible - existing implementations continue to work)

Database changes:

  • None

QA Instructions, Screenshots, Recordings

Testing instructions:

  1. Verify existing Customizer integration continues to work:

    • Check that social links appear correctly in the Customizer
    • Verify sharable socials functionality works as expected
    • Confirm social pages display properly
  2. Verify package can be used independently:

    • Create a custom SectionRepositoryInterface implementation
    • Instantiate AcornSocials without HookManager (pass null)
    • Confirm no errors occur and basic functionality works
  3. Run unit tests if available:

    composer test
  4. Check for PHP errors in logs after deployment

Tested on:

  • PHP 8.3
  • WordPress 6.x
  • Sage theme integration

UI accessibility checklist

N/A - No UI changes

Deployment checklist

  • I have deployed this PR to staging and I can confirm the behaviour is expected/correct

[optional] Are there any post-deployment tasks we need to perform?

No post-deployment tasks required.

@dulgermuhammet dulgermuhammet marked this pull request as ready for review April 21, 2026 10:23
@dulgermuhammet dulgermuhammet requested a review from Copilot April 21, 2026 10:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Acorn Socials package to be more modular by extracting shared repository logic into an abstract base class and shifting AcornSocials to depend on a repository interface, with optional hook registration.

Changes:

  • Added AbstractSectionRepository with common filtering methods (getSharableSocials(), getSocialPages()).
  • Expanded SectionRepositoryInterface to cover all repository methods and updated signatures.
  • Updated AcornSocials to accept SectionRepositoryInterface and allow a nullable HookManager.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Integrations/Customizer/SocialsSectionRepository.php Removes duplicated filtering methods and relies on the new abstract base class.
src/Contracts/SectionRepositoryInterface.php Updates the repository contract to include getData() and the derived filtering methods.
src/Concretes/AbstractSectionRepository.php Introduces shared repository caching + filtering logic.
src/AcornSocials.php Switches constructor dependency to the interface and makes hook registration conditional.
acorn-socials.php Bumps plugin version to 0.6.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Concretes/AbstractSectionRepository.php
Comment thread src/AcornSocials.php
Comment thread src/Contracts/SectionRepositoryInterface.php
@dulgermuhammet dulgermuhammet requested review from a team and petarbajic84 April 21, 2026 11:01
@codepuncher
Copy link
Copy Markdown
Member

why do we need this?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants