Skip to content

IBX-10685: Added information on how to add a custom attribute type to an existing storage definition#3068

Open
mateuszdebinski wants to merge 5 commits into5.0from
IBX-10685-Custom-attribute-type
Open

IBX-10685: Added information on how to add a custom attribute type to an existing storage definition#3068
mateuszdebinski wants to merge 5 commits into5.0from
IBX-10685-Custom-attribute-type

Conversation

@mateuszdebinski
Copy link
Contributor

@mateuszdebinski mateuszdebinski commented Mar 2, 2026

Question Answer
JIRA Ticket IBX-10685
Versions 4.6 and 5.0
Edition Commerce

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Preview of modified files

Preview of modified Markdown:

[[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]]
```

Add the CompilerPass to the container with a priority higher than 0 so that it runs first `src/Kernel.php`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Add the CompilerPass to the container with a priority higher than 0 so that it runs first `src/Kernel.php`:
Add the CompilerPass to the container with a priority higher than 0 so that it runs first.
To do it, create a `src/Kernel.php` file:

or...

"Do it in a src/Kernel.php file:"

@dabrt
Copy link
Contributor

dabrt commented Mar 2, 2026

Hi @mateuszdebinski , would you like @reithor to approve the PR as DEV reviewer?

@mateuszdebinski
Copy link
Contributor Author

Hi @dabrt I asked @Steveb-p to review and approve

@mateuszdebinski mateuszdebinski self-assigned this Mar 3, 2026
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php


code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php

docs/pim/create_custom_attribute_type.md@179:``` php
docs/pim/create_custom_attribute_type.md@180:[[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]]
docs/pim/create_custom_attribute_type.md@181:```

001⫶<?php
002⫶/**
003⫶ * @copyright Copyright (C) Ibexa AS. All rights reserved.
004⫶ * @license For full copyright and license information view LICENSE file distributed with this source code.
005⫶ */
006⫶declare(strict_types=1);
007⫶
008⫶namespace App\DependencyInjection;
009⫶
010⫶use Ibexa\ProductCatalog\Local\Persistence\Legacy\Attribute\Float\StorageDefinition;
011⫶use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
012⫶use Symfony\Component\DependencyInjection\ContainerBuilder;
013⫶
014⫶class AddFloatStorageDefinitionTag implements CompilerPassInterface
015⫶{
016⫶ public function process(ContainerBuilder $container): void
017⫶ {
018⫶ $container->getDefinition(StorageDefinition::class)
019⫶ ->addTag('ibexa.product_catalog.attribute.storage_definition', ['type' => 'percent']);
020⫶ }
021⫶}


code_samples/catalog/custom_attribute_type/src/Kernel.php


code_samples/catalog/custom_attribute_type/src/Kernel.php

docs/pim/create_custom_attribute_type.md@185:``` php hl_lines="5 7-8 14-20"
docs/pim/create_custom_attribute_type.md@186:[[= include_file('code_samples/catalog/custom_attribute_type/src/Kernel.php') =]]
docs/pim/create_custom_attribute_type.md@187:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶namespace App;
004⫶
005❇️use App\DependencyInjection\AddFloatStorageDefinitionTag;
006⫶use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
007❇️use Symfony\Component\DependencyInjection\ContainerBuilder;
008❇️use Symfony\Component\HttpKernel\Kernel as BaseKernel;
009⫶
010⫶class Kernel extends BaseKernel
011⫶{
012⫶ use MicroKernelTrait;
013⫶
014❇️ public function build(ContainerBuilder $container): void
015❇️ {
016❇️ parent::build($container);
017❇️
018❇️ $container->addCompilerPass(new AddFloatStorageDefinitionTag());
019❇️ }
020❇️}

Download colorized diff

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

[[= include_file('code_samples/catalog/custom_attribute_type/src/DependencyInjection/AddFloatStorageDefinitionTag.php') =]]
```

Add the CompilerPass to the container. Do it in a `src/Kernel.php` file or in your Bundle class:
Copy link
Contributor

@dabrt dabrt Mar 10, 2026

Choose a reason for hiding this comment

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

Suggested change
Add the CompilerPass to the container. Do it in a `src/Kernel.php` file or in your Bundle class:
Add the CompilerPass to the container.
Do it in a `src/Kernel.php` file or in your Bundle class:

@mateuszdebinski Thank you for directly contributing to the documentation!

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