From 202bbe52d85aac1be5cadd415715864b2a800c17 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 28 Apr 2016 23:35:59 +0800 Subject: [PATCH] Improve CreateRecordAction --- .../RecordAction/CreateRecordAction.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ActionKit/RecordAction/CreateRecordAction.php b/src/ActionKit/RecordAction/CreateRecordAction.php index 45104608..f636d305 100644 --- a/src/ActionKit/RecordAction/CreateRecordAction.php +++ b/src/ActionKit/RecordAction/CreateRecordAction.php @@ -8,18 +8,15 @@ abstract class CreateRecordAction public $enableLoadRecord = false; - public function create($args) + public function create(array $args) { $this->recordResult = $ret = $this->record->create($args); - - /* error checking */ - if (false === $ret->success) { - $this->convertRecordValidation( $ret ); - return $this->createError( $ret ); + if ($ret->error) { + $this->convertRecordValidation($ret); + return $this->createError($ret); } - $this->result->data( $this->record->getStashedData() ); - - return $this->createSuccess( $ret ); + $this->result->data($this->record->getStashedData()); + return $this->createSuccess($ret); } /** @@ -28,8 +25,8 @@ public function create($args) public function run() { /* default run method , to run create action */ - $success = $this->create( $this->args ); - if ( $this->nested && ! empty($this->relationships) ) { + $success = $this->create($this->args); + if ($this->nested && ! empty($this->relationships)) { $success = $this->processSubActions(); } return $success;