create() public method

Create a resource
public create ( mixed $data ) : ZF\ApiProblem\ApiProblem | mixed
$data mixed
return ZF\ApiProblem\ApiProblem | mixed
Example #1
0
 /**
  * Override parent so we can call getValues() to automatically rename uploaded file
  */
 public function create($data)
 {
     $inputFilter = $this->getInputFilter();
     $values = $inputFilter->getValues();
     $data->filename = $values['filename'];
     return parent::create($data);
 }
Example #2
0
 /**
  * Create a resource
  *
  * @param  mixed $data
  * @throws \InvalidArgumentException
  * @return ApiProblem|mixed
  */
 public function create($data)
 {
     if (empty($data->noteId) || !is_numeric($data->noteId)) {
         return new ApiProblem(422, 'noteId value missing');
     }
     if (empty($data->userId) || !is_numeric($data->userId)) {
         return new ApiProblem(422, 'userId value missing');
     }
     $data->user = $data->userId;
     $data->note = $data->noteId;
     $this->setEntityIdentifierName('userId.noteId');
     return parent::create($data);
 }