Skip to content

Commit

Permalink
IBX-8418: Refactored solution
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Oct 2, 2024
1 parent d21881b commit f0e028e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/services/forms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ services:
tags:
- { name: ibexa.admin_ui.form.trash_location_option, priority: 60 }

Ibexa\AdminUi\Form\TrashLocationOptionProvider\CanHaveDrafts:
tags:
- { name: ibexa.admin_ui.form.trash_location_option, priority: 20 }

Ibexa\AdminUi\Form\TrashLocationOptionProvider\OptionsFactory:
arguments: [!tagged ibexa.admin_ui.form.trash_location_option]

Expand Down
43 changes: 43 additions & 0 deletions src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Form\TrashLocationOptionProvider;

use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class CanHaveDrafts implements TrashLocationOptionProvider
{
private TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}

public function supports(Location $location): bool
{
return true;
}

public function addOptions(FormInterface $form, Location $location): void
{
$form
->add('can_have_drafts', ChoiceType::class, [
'label' =>
/** @Desc("Drafts") */
$this->translator->trans('drafts.list', [], 'ibexa_drafts'),
'help_multiline' => [
/** @Desc("Sending this content item to Trash will also delete all drafts of content items that haven’t been published yet, and belong to the trashed subtree.") */
$this->translator->trans('trash.modal.send_to_trash_draft_warning.message', [], 'messages'),
],
]);
}
}

0 comments on commit f0e028e

Please sign in to comment.