Skip to content

Conversation

@pierredup
Copy link
Member

No description provided.

@pierredup pierredup added this to the 2.4.0 milestone Oct 27, 2025
@pierredup pierredup self-assigned this Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Bundle Report

Changes will increase total bundle size by 7.58MB (100.0%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
solidinvoice-webpack-bundle-array-push 7.58MB 7.58MB (100%) ⬆️⚠️

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Warning

Rate limit exceeded

@pierredup has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 6 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4199872 and 2fa1fa0.

📒 Files selected for processing (1)
  • src/SettingsBundle/Tests/Twig/Components/__snapshots__/SettingsTest__testChangeSection__1.html (2 hunks)

Walkthrough

This PR introduces a provider-based system for configuration management. It defines a new ProviderInterface and Config DTO, refactors DefaultData to accept multiple configuration providers via dependency injection, and implements providers for system, invoice, mailer, and quote settings. Navigation snapshot tests are updated to reflect Email settings repositioned after Invoice settings.

Changes

Cohort / File(s) Summary
Configuration infrastructure
src/SettingsBundle/Config/ProviderInterface.php, src/SettingsBundle/DTO/Config.php
New interface defining provide(array $data): array contract and new DTO to represent configuration entries with key, value, description, and formType.
Configuration providers
src/CoreBundle/Config/SystemConfigProvider.php, src/InvoiceBundle/Config/ConfigProvider.php, src/MailerBundle/Config/ConfigProvider.php, src/QuoteBundle/Config/ConfigProvider.php
Four new provider implementations supplying system, invoice, mailer, and quote-related configuration entries respectively.
DefaultData refactoring
src/CoreBundle/Company/DefaultData.php
Converted to final readonly class; constructor now accepts iterable of config providers via AutowireIterator; replaced hardcoded app config with provider-driven loop that invokes each provider, validates Config instances with runtime type checking, and persists Settings.
Test updates
src/CoreBundle/Tests/Company/DefaultDataTest.php
Updated DefaultData instantiation to pass array of four provider instances.
Dependency injection
src/SettingsBundle/DependencyInjection/SolidInvoiceSettingsExtension.php
Added autoconfiguration and tagging for ProviderInterface.
Navigation snapshots
src/SettingsBundle/Tests/Twig/Components/__snapshots__/SettingsTest__testChangeSection__*.html, SettingsTest__testRenderComponent__1.html, SettingsTest__testSaveOnDifferentSection__2.html
Reordered Email navigation item to appear after Invoice item.

Sequence Diagram

sequenceDiagram
    participant DefaultData
    participant SystemProvider
    participant InvoiceProvider
    participant MailerProvider
    participant QuoteProvider
    participant Database

    DefaultData->>SystemProvider: provide(data)
    SystemProvider-->>DefaultData: Config[]
    DefaultData->>InvoiceProvider: provide(data)
    InvoiceProvider-->>DefaultData: Config[]
    DefaultData->>MailerProvider: provide(data)
    MailerProvider-->>DefaultData: Config[]
    DefaultData->>QuoteProvider: provide(data)
    QuoteProvider-->>DefaultData: Config[]
    
    Note over DefaultData: Validate each Config<br/>Build Setting entities<br/>Associate with Company
    
    DefaultData->>Database: persist(Settings)
    Database-->>DefaultData: ✓
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Key areas for attention:
    • Type validation in DefaultData using get_debug_type for runtime Config instance checking and RuntimeException handling
    • Correctness of each provider's provide() method return values and Config object construction
    • Verify all four providers implement ProviderInterface correctly and are auto-registered via dependency injection
    • Confirm DefaultData constructor properly injects and iterates over the config providers
    • Snapshot test updates align with intended navigation ordering

Possibly related PRs

  • Add setting to delete company #1893: Adds Company::$settings OneToMany collection and deletion support—directly complements this PR's provider-driven Setting entity creation and persistence.

Suggested labels

enhancement

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning No pull request description was provided by the author. While the description check is intentionally lenient and does not require extensive detail, a pull request should include at least some explanation of the changes and their motivation. The absence of any description prevents verification that context and rationale are communicated, which is important for code review and future reference, even if the provided title summarizes the main change.
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Add Config Providers to let each bundle define it's own default config values" accurately and clearly describes the primary change in this pull request. The PR introduces a new provider pattern (ProviderInterface, Config DTO, and concrete provider implementations) that allows bundles like InvoiceBundle, QuoteBundle, and MailerBundle to define their own default configuration values. This aligns with the substantial refactoring of DefaultData to use an injectable iterable of config providers and the new autoconfiguration support. The title is concise and specific enough for a teammate to understand the intent without being vague or overly broad.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (7)
src/SettingsBundle/DTO/Config.php (1)

14-23: Minor ergonomics: default nullable args to null.
Reduces noise at call sites where many pass null explicitly.

-final class Config
+final class Config
 {
     public function __construct(
         public readonly string $key,
-        public readonly mixed $value,
-        public readonly ?string $description,
-        public readonly ?string $formType,
+        public readonly mixed $value = null,
+        public readonly ?string $description = null,
+        public readonly ?string $formType = null,
     ) {
     }
 }
src/SettingsBundle/Config/ProviderInterface.php (1)

16-23: Tighten phpdoc for static analysis.
Indicate a numerically indexed list for clearer tooling.

     /**
-     * @param array{company_name?: string|null, currency?: string|null} $data
-     *
-     * @return Config[]
+     * @param array{company_name?: string|null, currency?: string|null} $data
+     * @return list<Config>
      */
     public function provide(array $data): array;
src/CoreBundle/Config/SystemConfigProvider.php (1)

29-35: Use TelType for phone number input.
Improves semantics and built-in validation/UX for phone fields.

-            new Config('system/company/contact_details/phone_number', null, null, TextType::class),
+            new Config('system/company/contact_details/phone_number', null, null, \Symfony\Component\Form\Extension\Core\Type\TelType::class),
src/InvoiceBundle/Config/ConfigProvider.php (1)

23-33: Silence PHPMD for unused $data.
Interface requires the parameter; this implementation doesn’t use it. Suppress the warning.

 final class ConfigProvider implements ProviderInterface
 {
+    /**
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+     */
     public function provide(array $data): array
     {
         return [

Alternative: unset($data); as the first line in the method.

src/QuoteBundle/Config/ConfigProvider.php (1)

23-33: Silence PHPMD for unused $data (interface requirement) and document return type.

Keep the signature, but add an UnusedFormalParameter suppression and a precise return phpdoc.

 final class ConfigProvider implements ProviderInterface
 {
-    public function provide(array $data): array
+    /**
+     * @return list<Config>
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+     */
+    public function provide(array $data): array
     {
         return [
src/CoreBundle/Company/DefaultData.php (2)

66-80: Add idempotency guard to avoid duplicate settings on re-run.

If DefaultData can run more than once, check for existing keys before persisting or upsert.

-                $this->em->persist($settingEntity);
+                // Skip if key already exists
+                if (! $this->em->getRepository(Setting::class)->findOneBy(['key' => $config->key])) {
+                    $this->em->persist($settingEntity);
+                }

47-64: Tighten annotations and consider deterministic provider order.

  • The JsonException @throws may be stale for createAppConfig(); drop or update if not thrown here.
  • If provider order matters, consider ordering via tag priority.
-    /**
-     * @param array{currency: string} $data
-     * @throws JsonException
-     */
+    /**
+     * @param array{currency: string} $data
+     */
     private function createAppConfig(Company $company, array $data): void

Optional ordering (if using tags):

#[TaggedIterator(ProviderInterface::class/*, defaultPriorityMethod: 'getPriority'*/)]
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49413af and 0bea967.

📒 Files selected for processing (9)
  • src/CoreBundle/Company/DefaultData.php (2 hunks)
  • src/CoreBundle/Config/SystemConfigProvider.php (1 hunks)
  • src/CoreBundle/Tests/Company/DefaultDataTest.php (1 hunks)
  • src/InvoiceBundle/Config/ConfigProvider.php (1 hunks)
  • src/MailerBundle/Config/ConfigProvider.php (1 hunks)
  • src/QuoteBundle/Config/ConfigProvider.php (1 hunks)
  • src/SettingsBundle/Config/ProviderInterface.php (1 hunks)
  • src/SettingsBundle/DTO/Config.php (1 hunks)
  • src/SettingsBundle/DependencyInjection/SolidInvoiceSettingsExtension.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
src/SettingsBundle/DTO/Config.php (1)
src/CoreBundle/Company/DefaultData.php (1)
  • __construct (39-45)
src/MailerBundle/Config/ConfigProvider.php (4)
src/SettingsBundle/DTO/Config.php (1)
  • Config (14-23)
src/SettingsBundle/Form/Type/MailTransportType.php (1)
  • MailTransportType (36-136)
src/CoreBundle/Config/SystemConfigProvider.php (1)
  • provide (25-36)
src/SettingsBundle/Config/ProviderInterface.php (1)
  • provide (23-23)
src/SettingsBundle/Config/ProviderInterface.php (5)
src/SettingsBundle/DTO/Config.php (1)
  • Config (14-23)
src/CoreBundle/Config/SystemConfigProvider.php (1)
  • provide (25-36)
src/InvoiceBundle/Config/ConfigProvider.php (1)
  • provide (23-33)
src/MailerBundle/Config/ConfigProvider.php (1)
  • provide (21-28)
src/QuoteBundle/Config/ConfigProvider.php (1)
  • provide (23-33)
src/InvoiceBundle/Config/ConfigProvider.php (4)
src/SettingsBundle/DTO/Config.php (1)
  • Config (14-23)
src/CoreBundle/Form/Type/BillingIdConfigurationType.php (1)
  • BillingIdConfigurationType (25-55)
src/QuoteBundle/Config/ConfigProvider.php (2)
  • ConfigProvider (21-34)
  • provide (23-33)
src/SettingsBundle/Config/ProviderInterface.php (1)
  • provide (23-23)
src/CoreBundle/Company/DefaultData.php (7)
src/SettingsBundle/DTO/Config.php (2)
  • Config (14-23)
  • __construct (16-22)
src/CoreBundle/Config/SystemConfigProvider.php (1)
  • provide (25-36)
src/InvoiceBundle/Config/ConfigProvider.php (1)
  • provide (23-33)
src/MailerBundle/Config/ConfigProvider.php (1)
  • provide (21-28)
src/QuoteBundle/Config/ConfigProvider.php (1)
  • provide (23-33)
src/SettingsBundle/Config/ProviderInterface.php (1)
  • provide (23-23)
src/SettingsBundle/Entity/Setting.php (1)
  • setKey (65-70)
src/QuoteBundle/Config/ConfigProvider.php (4)
src/SettingsBundle/DTO/Config.php (1)
  • Config (14-23)
src/CoreBundle/Form/Type/BillingIdConfigurationType.php (1)
  • BillingIdConfigurationType (25-55)
src/InvoiceBundle/Config/ConfigProvider.php (2)
  • ConfigProvider (21-34)
  • provide (23-33)
src/SettingsBundle/Config/ProviderInterface.php (1)
  • provide (23-23)
src/CoreBundle/Config/SystemConfigProvider.php (4)
src/SettingsBundle/DTO/Config.php (1)
  • Config (14-23)
src/CoreBundle/Form/Type/ImageUploadType.php (1)
  • ImageUploadType (25-69)
src/MoneyBundle/Form/Type/CurrencyType.php (1)
  • CurrencyType (25-60)
src/SettingsBundle/Config/ProviderInterface.php (1)
  • provide (23-23)
src/CoreBundle/Tests/Company/DefaultDataTest.php (1)
src/CoreBundle/Company/DefaultData.php (1)
  • DefaultData (32-162)
🪛 PHPMD (2.15.0)
src/InvoiceBundle/Config/ConfigProvider.php

23-23: Avoid unused parameters such as '$data'. (undefined)

(UnusedFormalParameter)

src/QuoteBundle/Config/ConfigProvider.php

23-23: Avoid unused parameters such as '$data'. (undefined)

(UnusedFormalParameter)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: Composer Normalize
  • GitHub Check: DB (MariaDB pdo_mysql 11)
  • GitHub Check: DB (MariaDB pdo_mysql 11.0)
  • GitHub Check: DB (MySQL pdo_mysql 9)
  • GitHub Check: DB (PostgreSQL pdo_pgsql 17)
  • GitHub Check: Lint
  • GitHub Check: DB (MySQL pdo_mysql 8.3)
  • GitHub Check: DB (MariaDB pdo_mysql 10.11)
  • GitHub Check: DB (PostgreSQL pdo_pgsql 16)
  • GitHub Check: DB (MariaDB pdo_mysql 10.6)
  • GitHub Check: DB (MariaDB pdo_mysql 10.5)
  • GitHub Check: DB (MariaDB pdo_mysql 11.4)
  • GitHub Check: DB (MariaDB pdo_mysql 10.4)
  • GitHub Check: DB (MySQL pdo_mysql 5.7)
  • GitHub Check: DB (MySQL pdo_mysql 8.0)
  • GitHub Check: DB (MySQL pdo_mysql 8.4)
  • GitHub Check: Unit ( PHP 8.4 )
  • GitHub Check: Unit ( PHP 8.4 )
🔇 Additional comments (3)
src/SettingsBundle/DependencyInjection/SolidInvoiceSettingsExtension.php (2)

16-16: Import looks good.
No issues with the new use statement.


34-35: Implementation is correct—all concerns are addressed.

Verification confirms:

  • autoconfigure() is explicitly enabled in SettingsBundle/Resources/config/services/services.php
  • ✓ Tag string ProviderInterface::class matches the #[AutowireIterator(ProviderInterface::class)] parameter exactly
  • ✓ Provider iteration in DefaultData::createAppConfig() is order-agnostic (iterates generically without ordering dependencies), so priority tagging is unnecessary
  • ✓ Four ProviderInterface implementations found across QuoteBundle, MailerBundle, InvoiceBundle, and CoreBundle all auto-register correctly
src/QuoteBundle/Config/ConfigProvider.php (1)

26-31: Consistency check with Invoice provider defaults.

Values, descriptions, and form types mirror Invoice provider; looks good. No action needed.

@pierredup pierredup merged commit 8accc7d into 2.4.x Oct 28, 2025
59 of 69 checks passed
@pierredup pierredup deleted the config-providers branch October 28, 2025 07:56
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.13%. Comparing base (87e020a) to head (2fa1fa0).
⚠️ Report is 9 commits behind head on 2.4.x.

Files with missing lines Patch % Lines
...endencyInjection/SolidInvoiceSettingsExtension.php 0.00% 2 Missing ⚠️
src/CoreBundle/Company/DefaultData.php 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              2.4.x    #2047      +/-   ##
============================================
+ Coverage     48.07%   48.13%   +0.06%     
- Complexity     2818     2825       +7     
============================================
  Files           513      518       +5     
  Lines          9517     9534      +17     
============================================
+ Hits           4575     4589      +14     
- Misses         4942     4945       +3     
Flag Coverage Δ
unittests 48.13% <93.87%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants