Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/code_samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

- name: Ignore audit advisory for PHP 7.4
if: matrix.php == '7.4'
run: composer config audit.ignore --json '{"GHSA-68jq-c3rv-pcrr": "As this is for code quality tests and not to run a production DXP, this can be ignored."}'

- uses: ramsey/composer-install@v3
with:
dependency-versions: highest
Expand Down
5 changes: 5 additions & 0 deletions code_samples/api/graphql/config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
App\GraphQL\Schema\MyFieldDefinitionMapper:
decorates: Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper
arguments:
$innerMapper: '@.inner'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types=1);

namespace App\GraphQL\Schema;

use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
use Ibexa\Contracts\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper;
use Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;

class MyFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper
{
protected function getFieldTypeIdentifier(): string
{
return 'my_field_type';
}

public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string
{
if (!$this->canMap($fieldDefinition)) {
return parent::mapToFieldValueInputType($contentType, $fieldDefinition);
}

return $this->nameMyFieldInputType($contentType, $fieldDefinition);
}

private function nameMyFieldInputType(ContentType $contentType, FieldDefinition $fieldDefinition): string
{
$converter = new CamelCaseToSnakeCaseNameConverter(null, false);

return sprintf(
'%s%sInput',
$converter->denormalize($contentType->identifier),
$converter->denormalize($fieldDefinition->identifier)
);
}
}
40 changes: 40 additions & 0 deletions code_samples/back_office/product_tour/config/general_scenario.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ibexa:
system:
admin_group:
product_tour:
my_general_scenario:
type: 'general'
scenario_title_translation_key: tour.my_general_scenario.title
steps:
welcome_step:
step_title_translation_key: title
background_image: /public/img/background.jpg
blocks:
- type: title
params:
text_translation_key: subtitle
- type: text
params:
text_translation_key: tour.step.description
- type: link
params:
url: https://doc.ibexa.co
text_translation_key: tour.link.documentation
- type: image
params:
src: /public/img/diagram.jpg
alt_translation_key: tour.image.alt
- type: video
params:
# 'Big Buck Bunny' licensed under CC 3.0 by the Blender foundation. Hosted by archive.org
url: https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4
- type: list
params:
title_translation_key: tour.list.title
items_translation_keys:
- tour.list.item1
- tour.list.item2
- tour.list.item3
- type: twig_template
params:
template: custom_template.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ibexa:
system:
admin_group:
product_tour:
targetable_dashboard_scenario:
type: 'targetable'
scenario_title_translation_key: tour.targetable_dashboard_scenario.title
steps:
dashboard_options:
step_title_translation_key: Open Dashboard options
target: ".ibexa-db-header__more"
# No interaction_mode specified or the value is set to null
blocks:
- type: text
params:
text_translation_key: Learn how to customize the blocks displayed on your dashboard
open_dashboard_options:
step_title_translation_key: Open Dashboard options
target: '.ibexa-db-header__more'
interaction_mode: clickable
blocks:
- type: text
params:
text_translation_key: Click here to customize your dashboard
customize_dashboard:
step_title_translation_key: Customize Dashboard
target: '.ibexa-db-actions-popup-menu'
interaction_mode: clickable
blocks:
- type: text
params:
text_translation_key: Choose "Customize dashboard"
drag_and_drop_step:
step_title_translation_key: Drag-and-drop blocks
target: ".c-pb-toolbox-blocks-group__blocks > * .c-pb-toolbox-block__content:first-of-type"
interaction_mode: draggable
blocks:
- type: text
params:
text_translation_key: Drag-and-drop blocks from the sidebar to the dashboard to customize it
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace App\EventSubscriber;

use Ibexa\Contracts\Core\Repository\NotificationService;
use Ibexa\Contracts\IntegratedHelp\Event\RenderProductTourScenarioEvent;
use Ibexa\IntegratedHelp\ProductTour\Block\LinkBlock;
use Ibexa\IntegratedHelp\ProductTour\Block\TextBlock;
use Ibexa\IntegratedHelp\ProductTour\ProductTourStep;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class NotificationScenarioSubscriber implements EventSubscriberInterface
{
private NotificationService $notificationService;

public function __construct(NotificationService $notificationService)
{
$this->notificationService = $notificationService;
}

public static function getSubscribedEvents(): array
{
return [
RenderProductTourScenarioEvent::class => ['onRenderScenario'],
];
}

public function onRenderScenario(RenderProductTourScenarioEvent $event): void
{
$scenario = $event->getScenario();
$steps = $scenario->getSteps();

if ($scenario->getIdentifier() !== 'notifications') {
return;
}

foreach ($steps as $step) {
$scenario->removeStep($step);
}

if (!$this->hasUnreadNotifications()) {
return;
}

$customStep = new ProductTourStep();
$customStep->setIdentifier('custom_step_identifier');
$customStep->setInteractionMode('clickable');
$customStep->setTarget('.ibexa-header-user-menu__notifications-toggler');
$customStep->setTitle('You have unread notifications');
$customStep->addBlock(new TextBlock('Click here to preview your unread notifications.'));
$customStep->addBlock(new LinkBlock(
'https://doc.ibexa.co/projects/userguide/en/latest/getting_started/notifications/',
'Learn more about notifications'
));

$scenario->addStep($customStep);
}

private function hasUnreadNotifications(): bool
{
return $this->notificationService->getPendingNotificationCount() > 0;
}
}
19 changes: 19 additions & 0 deletions code_samples/search/content/taxonomy_no_entries_criterion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
use Ibexa\Contracts\Taxonomy\Search\Query\Criterion\TaxonomyNoEntries;

$query = new Query();
$query->query = new LogicalAnd(
[
new TaxonomyNoEntries('tags'),
new ContentTypeIdentifier('article'),
]
);

/** @var \Ibexa\Contracts\Core\Repository\SearchService $searchService */
$results = $searchService->findContent($query);
19 changes: 19 additions & 0 deletions code_samples/search/content/taxonomy_subtree_criterion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
use Ibexa\Contracts\Taxonomy\Search\Query\Criterion\TaxonomySubtree;

$query = new Query();
$query->query = new LogicalAnd(
[
new TaxonomySubtree(42),
new ContentTypeIdentifier('article'),
]
);

/** @var \Ibexa\Contracts\Core\Repository\SearchService $searchService */
$results = $searchService->findContent($query);
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"ibexa/collaboration": "~4.6.x-dev",
"ibexa/share": "~4.6.x-dev",
"ibexa/phpstan": "~4.6.-dev",
"ibexa/integrated-help": "~4.6.x-dev",
"ibexa/cdp": "~4.6.x-dev",
"ibexa/image-editor": "~4.6.x-dev"
},
Expand Down
Loading
Loading