Skip to content

Commit

Permalink
Improve CreateRecordAction
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Apr 28, 2016
1 parent 6ed9adc commit 202bbe5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/ActionKit/RecordAction/CreateRecordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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;
Expand Down

0 comments on commit 202bbe5

Please sign in to comment.