-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/bundle/Templating/Twig/EmbeddedItemEditFormExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?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\Bundle\AdminUi\Templating\Twig; | ||
|
||
use Ibexa\AdminUi\Form\Data\Content\Draft\ContentEditData; | ||
use Ibexa\AdminUi\Form\Factory\FormFactory; | ||
use Symfony\Component\Form\FormView; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
final class EmbeddedItemEditFormExtension extends AbstractExtension | ||
{ | ||
private FormFactory $formFactory; | ||
|
||
private RouterInterface $router; | ||
|
||
public function __construct( | ||
FormFactory $formFactory, | ||
RouterInterface $router | ||
) { | ||
$this->formFactory = $formFactory; | ||
$this->router = $router; | ||
} | ||
|
||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction( | ||
'ibexa_render_embedded_item_edit_form', | ||
[$this, 'renderEmbeddedItemEditForm'] | ||
), | ||
]; | ||
} | ||
|
||
public function renderEmbeddedItemEditForm(): FormView | ||
{ | ||
return $this->formFactory->contentEdit( | ||
new ContentEditData(), | ||
'embedded_item_edit', | ||
[ | ||
'action' => $this->router->generate('ibexa.content.edit'), | ||
] | ||
)->createView(); | ||
} | ||
} |