Conversation
… PHP AsAttributeType attribute does not.
…tributeType attribute.
| Q | A |-----------------|----- | Branch? |1.14 or 2.0 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | License | MIT Changing the PR description template
The AttributeType service has a configuration_form_type entry but the
PHP AsAttributeType attribute does not.
| Q | A
|-----------------|-----
| Branch? | 1.14, 2.0, 2.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| License | MIT
------------
Trying to create custom attribute type I get an error trying to use
AsAttributeType because it missing the configurationFormType property as
the service yaml or xml declaration.
**Working**
```yaml
services:
App\Attribute\AttributeType\EntityAttributeType:
tags:
- { name: sylius.attribute.type, attribute_type: entity, label: 'Entity', form_type: 'App\Form\Type\AttributeType\EntityAttributeType', configuration_form_type: 'App\Form\Type\AttributeType\Configuration\EntityAttributeConfigurationType' }
```
**Error**
```php
<?php
declare(strict_types=1);
namespace App\Attribute\AttributeType;
use App\Form\Type\AttributeType\Configuration\EntityAttributeConfigurationType;
use Sylius\Bundle\AttributeBundle\Attribute\AsAttributeType;
use Sylius\Component\Attribute\AttributeType\AttributeTypeInterface;
use Sylius\Component\Attribute\Model\AttributeValueInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[AsAttributeType(
type: 'entity',
label: 'Entity',
formType: \App\Form\Type\AttributeType\EntityAttributeType::class,
configurationFormType: EntityAttributeConfigurationType::class // Unknown named parameter 'configurationFormType'
)]
final class EntityAttributeType implements AttributeTypeInterface
{
public const string TYPE = 'entity';
public function getStorageType(): string
{
return AttributeValueInterface::STORAGE_JSON;
}
public function getType(): string
{
return self::TYPE;
}
public function getValue(AttributeValueInterface $attributeValue)
{
// Implement logic to fetch values
}
public function validate(AttributeValueInterface $attributeValue, ExecutionContextInterface $context, array $configuration): void
{
// Implement validate() method.
}
}
```
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
This PR has been generated automatically.
For more details see upmerge_pr.yaml.
Remember! The upmerge should always be merged with using
Merge pull requestbutton.In case of conflicts, please resolve them manually with usign the following commands:
If you use other name for the upstream remote, please replace
upstreamwith the name of your remote pointing to theSylius/Syliusrepository.Once the conflicts are resolved, please run
git merge --continueand push the changes to this PR.