- Some minor on request debugger
This commit is contained in:
1 parent
c3e3d6a73a
commit
ba74c5a38e
17 files changed
+255
-202
No files matched your search
+14
-1
@@ -8,13 +8,26 @@ use Ulmus\Entity\EntityInterface;
|
||||
|
||||
abstract class Delete extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
public function execute(FormContextInterface $context) : void
|
||||
public function validate(FormContextInterface $context) : bool
|
||||
{
|
||||
if ( ! $this->getEntity()->isLoaded() ) {
|
||||
$context->pushMessage($this->message::generateError(
|
||||
$this->lang('lean.api.form.delete.error.entity')
|
||||
));
|
||||
}
|
||||
|
||||
return $context->valid($this->getEntity()->isLoaded() ? $this->getEntity() : null);
|
||||
}
|
||||
|
||||
public function execute(FormContextInterface $context) : mixed
|
||||
{
|
||||
try {
|
||||
if ( $this->getEntity()::repository()->destroy($this->getEntity()) ) {
|
||||
$context->pushMessage($this->message::generateSuccess(
|
||||
$this->lang('lean.api.form.delete.success.save')
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
throw new \InvalidArgumentException($this->lang('lean.api.form.delete.error.save'));
|
||||
|
||||
Reference in new issue
Block a user