-
-
Notifications
You must be signed in to change notification settings - Fork 213
Add Config Providers to let each bundle define it's own default config values #2047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Bundle ReportChanges will increase total bundle size by 7.58MB (100.0%) ⬆️
|
|
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 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. 📒 Files selected for processing (1)
WalkthroughThis PR introduces a provider-based system for configuration management. It defines a new Changes
Sequence DiagramsequenceDiagram
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: ✓
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
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. Comment |
There was a problem hiding this 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 passnullexplicitly.-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): voidOptional ordering (if using tags):
#[TaggedIterator(ProviderInterface::class/*, defaultPriorityMethod: 'getPriority'*/)]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 inSettingsBundle/Resources/config/services/services.php- ✓ Tag string
ProviderInterface::classmatches 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
ProviderInterfaceimplementations found across QuoteBundle, MailerBundle, InvoiceBundle, and CoreBundle all auto-register correctlysrc/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.
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.