forked from sulu/SuluFormBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trash functionality for forms (sulu#326)
- Loading branch information
1 parent
1ab810f
commit ba31c3e
Showing
14 changed files
with
744 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ npm-debug.log | |
|
||
# php-cs-fixer | ||
.php_cs.cache | ||
php-cs-fixer | ||
.php-cs-fixer.cache |
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
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,92 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\FormBundle\Domain\Event; | ||
|
||
use Sulu\Bundle\ActivityBundle\Domain\Event\DomainEvent; | ||
use Sulu\Bundle\FormBundle\Admin\FormAdmin; | ||
use Sulu\Bundle\FormBundle\Entity\Form; | ||
use Sulu\Bundle\FormBundle\Entity\FormTranslation; | ||
|
||
class FormRestoredEvent extends DomainEvent | ||
{ | ||
/** | ||
* @var Form | ||
*/ | ||
private $form; | ||
|
||
/** | ||
* @var mixed[] | ||
*/ | ||
private $payload; | ||
|
||
/** | ||
* @param mixed[] $payload | ||
*/ | ||
public function __construct( | ||
Form $form, | ||
array $payload | ||
) { | ||
parent::__construct(); | ||
|
||
$this->form = $form; | ||
$this->payload = $payload; | ||
} | ||
|
||
public function getForm(): Form | ||
{ | ||
return $this->form; | ||
} | ||
|
||
public function getEventType(): string | ||
{ | ||
return 'restored'; | ||
} | ||
|
||
public function getEventPayload(): ?array | ||
{ | ||
return $this->payload; | ||
} | ||
|
||
public function getResourceKey(): string | ||
{ | ||
return Form::RESOURCE_KEY; | ||
} | ||
|
||
public function getResourceId(): string | ||
{ | ||
return (string) $this->form->getId(); | ||
} | ||
|
||
public function getResourceTitle(): ?string | ||
{ | ||
$translation = $this->getFormTranslation(); | ||
|
||
return $translation ? $translation->getTitle() : null; | ||
} | ||
|
||
public function getResourceTitleLocale(): ?string | ||
{ | ||
$translation = $this->getFormTranslation(); | ||
|
||
return $translation ? $translation->getLocale() : null; | ||
} | ||
|
||
private function getFormTranslation(): ?FormTranslation | ||
{ | ||
return $this->form->getTranslation($this->form->getDefaultLocale()); | ||
} | ||
|
||
public function getResourceSecurityContext(): ?string | ||
{ | ||
return FormAdmin::SECURITY_CONTEXT; | ||
} | ||
} |
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
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
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
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="sulu_form.form_trash_item_handler" | ||
class="Sulu\Bundle\FormBundle\Trash\FormTrashItemHandler"> | ||
<argument type="service" id="sulu_trash.trash_item_repository"/> | ||
<argument type="service" id="doctrine.orm.entity_manager"/> | ||
<argument type="service" id="sulu_trash.doctrine_restore_helper"/> | ||
<argument type="service" id="sulu_activity.domain_event_collector"/> | ||
|
||
<tag name="sulu_trash.store_trash_item_handler"/> | ||
<tag name="sulu_trash.restore_trash_item_handler"/> | ||
<tag name="sulu_trash.restore_configuration_provider"/> | ||
</service> | ||
</services> | ||
</container> |
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
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
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
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
Oops, something went wrong.