Skip to content

IBX-9147: Symbol attribute type described in Developer Documentation - v5.0 #2826

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

Merged
merged 9 commits into from
Jul 22, 2025

Conversation

julitafalcondusza
Copy link
Contributor

@julitafalcondusza julitafalcondusza commented Jul 15, 2025

Question Answer
JIRA Ticket (https://issues.ibexa.co/browse/IBX-9147)
Versions 5.0
Edition All

Symbol attribute type described in Developer Documentation - v5.0

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • 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

Copy link

github-actions bot commented Jul 15, 2025

@julitafalcondusza julitafalcondusza marked this pull request as ready for review July 16, 2025 10:26
@julitafalcondusza julitafalcondusza requested a review from a team July 16, 2025 10:27
@ezrobot ezrobot requested review from mnocon, adriendupuis and dabrt and removed request for a team July 16, 2025 10:27
@julitafalcondusza julitafalcondusza requested review from adamwojs and removed request for adriendupuis and dabrt July 16, 2025 10:27
Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

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

Text looks good, just one small thing: please add the Composer requirement for ibexa/product-catalog-symbol-attribute.

We have that for 4.6:
https://github.com/ibexa/documentation-developer/pull/2525/files#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34R74

The version constraint should be ~5.0.x-dev

Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

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

Thank you!

@julitafalcondusza julitafalcondusza added Wait with merge PRs that shouldn't be merged instantly and removed Needs DOC review Needs DEV review labels Jul 17, 2025
Copy link

code_samples/ change report

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

code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php


code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php

docs/search/criteria_reference/symbolattribute_criterion.md@18:``` php
docs/search/criteria_reference/symbolattribute_criterion.md@19:[[= include_file('code_samples/back_office/search/src/Query/SymbolAttributeTypeQuery.php') =]]
docs/search/criteria_reference/symbolattribute_criterion.md@20:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶use Ibexa\Contracts\ProductCatalog\Values\Product\ProductQuery;
004⫶use Ibexa\Contracts\ProductCatalogSymbolAttribute\Search\Criterion\SymbolAttribute;
005⫶
006⫶$query = new ProductQuery();
007⫶$query->setFilter(new SymbolAttribute('ean', ['5023920187205']));
008⫶/** @var \Ibexa\Contracts\ProductCatalog\ProductServiceInterface $productService */
009⫶$results = $productService->findProducts($query);


code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php


code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php

docs/pim/attributes/symbol_attribute_type.md@68:``` php
docs/pim/attributes/symbol_attribute_type.md@69:[[= include_file('code_samples/pim/Symbol/Format/Checksum/LuhnChecksum.php') =]]
docs/pim/attributes/symbol_attribute_type.md@70:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\PIM\Symbol\Format\Checksum;
006⫶
007⫶use Ibexa\Contracts\ProductCatalog\Values\AttributeDefinitionInterface;
008⫶use Ibexa\Contracts\ProductCatalogSymbolAttribute\Value\ChecksumInterface;
009⫶
010⫶final class LuhnChecksum implements ChecksumInterface
011⫶{
012⫶ public function validate(AttributeDefinitionInterface $attributeDefinition, string $value): bool
013⫶ {
014⫶ $digits = $this->getDigits($value);
015⫶
016⫶ $count = count($digits);
017⫶ $total = 0;
018⫶ for ($i = $count - 2; $i >= 0; $i -= 2) {
019⫶ $digit = $digits[$i];
020⫶ if ($i % 2 === 0) {
021⫶ $digit *= 2;
022⫶ }
023⫶
024⫶ $total += $digit > 9 ? $digit - 9 : $digit;
025⫶ }
026⫶
027⫶ $checksum = $digits[$count - 1];
028⫶
029⫶ return $total + $checksum === 0;
030⫶ }
031⫶
032⫶ /**
033⫶ * Returns an array of digits from the given value (skipping any formatting characters).
034⫶ *
035⫶ * @return int[]
036⫶ */
037⫶ private function getDigits(string $value): array
038⫶ {
039⫶ $chars = array_filter(
040⫶ str_split($value),
041⫶ static fn (string $char): bool => $char !== '-'
042⫶ );
043⫶
044⫶ return array_map('intval', array_values($chars));
045⫶ }
046⫶}

Download colorized diff

@julitafalcondusza julitafalcondusza merged commit 82dbe35 into 5.0 Jul 22, 2025
6 of 7 checks passed
@julitafalcondusza julitafalcondusza deleted the IBX-9147-v5 branch July 22, 2025 11:26
@julitafalcondusza julitafalcondusza removed the Wait with merge PRs that shouldn't be merged instantly label Jul 24, 2025
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