Skip to content

Commit

Permalink
WIP entity support for UserAction
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 30, 2021
1 parent 7ea93aa commit 33b01d3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ public function addAction(Model\UserAction $action, $executor, $button = null)

$page->add($executor = new $executor());

$action->getModel()->assertIsEntity(); // TODO remove before #1623 merge
$action->getModel()->load($id);
$action->setEntity($action->getModel()->load($id));

$executor->setAction($action);
});
Expand Down
3 changes: 1 addition & 2 deletions src/UserAction/ConfirmationExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public function executeModelAction()
{
$id = $this->stickyGet($this->name);
if ($id && $this->action->appliesTo === Model\UserAction::APPLIES_TO_SINGLE_RECORD) {
$this->action->getModel()->assertIsEntity(); // TODO remove before #1623 merge
$this->action->getModel()->tryLoad($id);
$this->action->setEntity($this->action->getModel()->tryLoad($id));
}

$this->loader->set(function ($modal) {
Expand Down
3 changes: 1 addition & 2 deletions src/UserAction/JsCallbackExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public function executeModelAction(array $args = [])
// may be id is passed as 'id' or model->id_field within $post args.
$id = $_POST['c0'] ?? $_POST['id'] ?? $_POST[$this->action->getModel()->id_field] ?? null;
if ($id && $this->action->appliesTo === Model\UserAction::APPLIES_TO_SINGLE_RECORD) {
$this->action->getModel()->assertIsEntity(); // TODO remove before #1623 merge
$this->action->getModel()->tryLoad($id);
$this->action->setEntity($this->action->getModel()->tryLoad($id));
}

if ($errors = $this->_hasAllArguments()) {
Expand Down
7 changes: 5 additions & 2 deletions src/UserAction/ModalExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ public function executeModelAction()
{
$id = $this->stickyGet($this->name);
if ($id && $this->action->appliesTo === Model\UserAction::APPLIES_TO_SINGLE_RECORD) {
$this->action->getModel()->assertIsEntity(); // TODO remove before #1623 merge
$this->action->getModel()->tryLoad($id);
$this->action->setEntity($this->action->getModel()->tryLoad($id));
}

if ($this->action->fields === true) {
Expand All @@ -193,6 +192,10 @@ public function executeModelAction()
$this->loader->set(function ($modal) {
$this->jsSetBtnState($modal, $this->step);

if (!$this->action->getModel()->isEntity()) {
$this->action->setEntity($this->action->getModel()->createEntity());
}

try {
switch ($this->step) {
case 'args':
Expand Down

0 comments on commit 33b01d3

Please sign in to comment.