Skip to content

Raptor integration - feature branch: Fix PHP#3130

Merged
adriendupuis merged 6 commits intoraptor_integration_feature_branchfrom
raptor_integration_feature_branch-php-fix
Apr 13, 2026
Merged

Raptor integration - feature branch: Fix PHP#3130
adriendupuis merged 6 commits intoraptor_integration_feature_branchfrom
raptor_integration_feature_branch-php-fix

Conversation

@adriendupuis
Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis commented Apr 13, 2026

Question Answer
JIRA Ticket
Versions
Edition

Fix PhpStan errors from #3121

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

Should fix PhpStan errors "Variable $product might not be defined."
@github-actions
Copy link
Copy Markdown

Preview of modified files

Preview of modified Markdown:

Should fix PhpStan error "invalid type App\Tracking\ProductInterface"
@github-actions
Copy link
Copy Markdown

code_samples/ change report

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

code_samples/recommendations/EventData.php

docs/recommendations/raptor_integration/tracking_php_api.md@30:``` php

code_samples/recommendations/EventData.php

docs/recommendations/raptor_integration/tracking_php_api.md@30:``` php
docs/recommendations/raptor_integration/tracking_php_api.md@31:[[= include_file('code_samples/recommendations/EventData.php') =]]
docs/recommendations/raptor_integration/tracking_php_api.md@32:```
docs/recommendations/raptor_integration/tracking_php_api.md@31:[[= include_file('code_samples/recommendations/EventData.php', 4, 6) =]]// …
docs/recommendations/raptor_integration/tracking_php_api.md@32:
docs/recommendations/raptor_integration/tracking_php_api.md@33:[[= include_file('code_samples/recommendations/EventData.php', 16, 25, remove_indent=True) =]]
docs/recommendations/raptor_integration/tracking_php_api.md@34:```


001⫶<?php declare(strict_types=1);
002⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\Event\VisitEventData;
003⫶
004⫶$eventData = new VisitEventData(
005⫶ productCode: $product->getCode(),
006⫶ productName: $product->getName(),
007⫶ categoryPath: '25#Electronics;26#Smartphones', // Build manually
008⫶ currency: 'USD',
009⫶ itemPrice: '999.99'
010⫶);
011⫶
012⫶$this->trackingDispatcher->dispatch($eventData);
The following line doesn't include file correctly: [[= include_file('code_samples/recommendations/EventData.php', 16, 25, remove_indent=True) =]]


code_samples/recommendations/EventMapper.php

docs/recommendations/raptor_integration/tracking_php_api.md@19:``` php
docs/recommendations/raptor_integration/tracking_php_api.md@20:[[= include_file('code_samples/recommendations/EventMapper.php') =]]
docs/recommendations/raptor_integration/tracking_php_api.md@21:```

001⫶<?php declare(strict_types=1);


code_samples/recommendations/EventMapper.php

docs/recommendations/raptor_integration/tracking_php_api.md@19:``` php
docs/recommendations/raptor_integration/tracking_php_api.md@20:[[= include_file('code_samples/recommendations/EventMapper.php') =]]
docs/recommendations/raptor_integration/tracking_php_api.md@21:```

001⫶<?php declare(strict_types=1);
002⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventMapperInterface;
003⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventType;
004⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\ServerSideTrackingDispatcherInterface;
005⫶use Ibexa\Contracts\ProductCatalog\Values\ProductInterface;
006⫶
007⫶class EventMapper
008⫶{
009⫶ public function __construct(
010⫶ private readonly EventMapperInterface $eventMapper,
011⫶ private ServerSideTrackingDispatcherInterface $trackingDispatcher,
012⫶ ) {
013⫶ }
014⫶
015⫶ public function trackProductView(ProductInterface $product, string $url): void
016⫶ {
017⫶ // Map product to VisitEventData automatically
018⫶ $eventData = $this->eventMapper->map(EventType::VISIT, $product);
019⫶
020⫶ // Send tracking event
021⫶ $this->trackingDispatcher->dispatch($eventData);
022⫶ }
023⫶}
002⫶
003⫶namespace App\Tracking;
004⫶
005⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventMapperInterface;
006⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventType;
007⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\ServerSideTrackingDispatcherInterface;
008⫶use Ibexa\Contracts\ProductCatalog\Values\ProductInterface;
009⫶
010⫶class EventMapper
011⫶{
012⫶ public function __construct(
013⫶ private readonly EventMapperInterface $eventMapper,
014⫶ private readonly ServerSideTrackingDispatcherInterface $trackingDispatcher,
015⫶ ) {
016⫶ }
017⫶
018⫶ public function trackProductView(ProductInterface $product, string $url): void
019⫶ {
020⫶ // Map product to VisitEventData automatically
021⫶ $eventData = $this->eventMapper->map(EventType::VISIT, $product);
022⫶
023⫶ // Send tracking event
024⫶ $this->trackingDispatcher->dispatch($eventData);
025⫶ }
026⫶}


code_samples/recommendations/EventSubscriber.php



code_samples/recommendations/EventSubscriber.php

docs/recommendations/raptor_integration/tracking_php_api.md@47:``` php
docs/recommendations/raptor_integration/tracking_php_api.md@48:[[= include_file('code_samples/recommendations/EventSubscriber.php') =]]
docs/recommendations/raptor_integration/tracking_php_api.md@49:```
docs/recommendations/raptor_integration/tracking_php_api.md@49:``` php
docs/recommendations/raptor_integration/tracking_php_api.md@50:[[= include_file('code_samples/recommendations/EventSubscriber.php') =]]
docs/recommendations/raptor_integration/tracking_php_api.md@51:```

001⫶<?php declare(strict_types=1);

001⫶<?php declare(strict_types=1);
002⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventMapperInterface;
003⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventType;
004⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\ServerSideTrackingDispatcherInterface;
005⫶use Symfony\Component\EventDispatcher\EventSubscriberInterface;
006⫶use Symfony\Component\HttpKernel\Event\ResponseEvent;
007⫶use Symfony\Component\HttpKernel\KernelEvents;
008⫶
009⫶class EventSubscriber implements EventSubscriberInterface
010⫶{
011⫶ public function __construct(
012⫶ private readonly EventMapperInterface $eventMapper,
013⫶ private ServerSideTrackingDispatcherInterface $trackingDispatcher,
014⫶ ) {
015⫶ }
016⫶
017⫶ public static function getSubscribedEvents(): array
018⫶ {
019⫶ return [KernelEvents::RESPONSE => ['onResponse', -10]];
020⫶ }
021⫶
022⫶ public function onResponse(ResponseEvent $event): void
023⫶ {
024⫶ if (!$event->isMainRequest()) {
025⫶ return;
026⫶ }
027⫶
028⫶ $request = $event->getRequest();
029⫶
030⫶ // Example: track only if request has specific attribute
031⫶ $product = $request->attributes->get('product');
032⫶ if (null === $product) {
033⫶ return;
034⫶ }
035⫶
036⫶ $eventData = $this->eventMapper->map(EventType::VISIT, $product);
037⫶ $this->trackingDispatcher->dispatch($eventData);
038⫶ }
039⫶}
002⫶
003⫶namespace App\Tracking;
004⫶
005⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventMapperInterface;
006⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\EventType;
007⫶use Ibexa\Contracts\ConnectorRaptor\Tracking\ServerSideTrackingDispatcherInterface;
008⫶use Symfony\Component\EventDispatcher\EventSubscriberInterface;
009⫶use Symfony\Component\HttpKernel\Event\ResponseEvent;
010⫶use Symfony\Component\HttpKernel\KernelEvents;
011⫶
012⫶class EventSubscriber implements EventSubscriberInterface
013⫶{
014⫶ public function __construct(
015⫶ private readonly EventMapperInterface $eventMapper,
016⫶ private readonly ServerSideTrackingDispatcherInterface $trackingDispatcher,
017⫶ ) {
018⫶ }
019⫶
020⫶ public static function getSubscribedEvents(): array
021⫶ {
022⫶ return [KernelEvents::RESPONSE => ['onResponse', -10]];
023⫶ }
024⫶
025⫶ public function onResponse(ResponseEvent $event): void
026⫶ {
027⫶ if (!$event->isMainRequest()) {
028⫶ return;
029⫶ }
030⫶
031⫶ $request = $event->getRequest();
032⫶
033⫶ // Example: track only if request has specific attribute
034⫶ $product = $request->attributes->get('product');
035⫶ if (null === $product) {
036⫶ return;
037⫶ }
038⫶
039⫶ $eventData = $this->eventMapper->map(EventType::VISIT, $product);
040⫶ $this->trackingDispatcher->dispatch($eventData);
041⫶ }
042⫶}


Download colorized diff

@adriendupuis adriendupuis marked this pull request as ready for review April 13, 2026 08:50
@adriendupuis adriendupuis merged commit e4450f2 into raptor_integration_feature_branch Apr 13, 2026
7 of 8 checks passed
@adriendupuis adriendupuis deleted the raptor_integration_feature_branch-php-fix branch April 13, 2026 09:03
@sonarqubecloud
Copy link
Copy Markdown

mnocon pushed a commit that referenced this pull request Apr 14, 2026
* first batch added

* content added

* recommendations twig page added

* updates

* content moved, structure updated

* guide added

* guide content

* fixes, content moved

* fixes after review

* Raptor integration - feature branch: fix links (#3123)

* Add preview of linked PHP API Ref entries
* Fix few links

* new batch of fixes

* updates

* new blocks added

* name fix

* fix

* new page added to cards on raptor_connector landing page

* fixes - first batch

* new fixes

* PHP & JS CS Fixes

* new fixes

* block names fixed

* code fixed

* code fixed

* links fixed

* card fixed

* IBX-11571: Rendering recommendations outside of Page Builder documented in Dev-doc (#3127)

* Update JWT (#3108)

* development_security.md: Update JWT firewalls

ibexa/recipes-dev#122
ibexa/recipes-dev#124
ibexa/recipes-dev#125

* rest_api_authentication.md: XML isn't supported for JWT

ibexa/rest#101

* render doc added

* updates

* img added, content added

* mkdocs

* fixes after rev

* fix

* fixes

---------

Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>

* php fix

* composer.json fix - connector-raptor added

* Raptor integration - feature branch: Fix PHP (#3130)

* EventData.php: Wrap into a class
* Event*.php: Format

* language fixes

* Raptor integration: Rework PHP (#3131)

* tracking_php_api.md: Detail EventMapper, EventType, EventContext
* tracking_php_api.md: caution about buy event

---------

Co-authored-by: Tomasz Dąbrowski <64841871+dabrt@users.noreply.github.com>

* server description updated

---------

Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Co-authored-by: julitafalcondusza <julitafalcondusza@users.noreply.github.com>
Co-authored-by: Tomasz Dąbrowski <64841871+dabrt@users.noreply.github.com>
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.

1 participant