main/app/API/Crud.php
public function create($class, $data, array $options = [])
    {
        // validates submitted data.
        if (!in_array(self::NO_VALIDATE, $options)) {
            $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options);

            if (count($errors) > 0) {
                return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent
            }
        }

        // gets entity from raw data.
        $object = new $class();
        $object = $this->serializer->deserialize($data, $object, $options);

        // creates the entity if allowed
        $this->checkPermission('CREATE', $object, [], true);

        if ($this->dispatch('create', 'pre', [$object, $options])) {
            $this->om->save($object);
            if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) {
                $this->dispatch('create', 'post', [$object, $options]);
            }
        }

        return $object;
    }
public function create($class, $data, array $options = [])
    {
        // validates submitted data.
        if (!in_array(self::NO_VALIDATE, $options)) {
            $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options);

            if (count($errors) > 0) {
                return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent
            }
        }

        // gets entity from raw data.
        $object = new $class();
        $object = $this->serializer->deserialize($data, $object, $options);

        // creates the entity if allowed
        $this->checkPermission('CREATE', $object, [], true);

        if ($this->dispatch('create', 'pre', [$object, $options])) {
            $this->om->save($object);
            if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) {
                $this->dispatch('create', 'post', [$object, $options]);
            }
        }

        return $object;
    }
public function create ( $ class , $ data , array $ options = [ ] ) { // validates submitted data. if ( ! in_array ( self :: NO_VALIDATE , $ options ) ) { $ errors = $ this -> validate ( $ class , $ data , ValidatorProvider :: CREATE , $ options ) ; if ( count ( $ errors ) > 0 ) { return $ errors ; // todo : it should throw an Exception otherwise it makes return inconsistent } } // gets entity from raw data. $ object = new $ class ( ) ; $ object = $ this -> serializer -> deserialize ( $ data , $ object , $ options ) ; // creates the entity if allowed $ this -> checkPermission ( 'CREATE' , $ object , [ ] , true ) ; if ( $ this -> dispatch ( 'create' , 'pre' , [ $ object , $ options ] ) ) { $ this -> om -> save ( $ object ) ; if ( ! in_array ( Options :: IGNORE_CRUD_POST_EVENT , $ options ) ) { $ this -> dispatch ( 'create' , 'post' , [ $ object , $ options ] ) ; } } return $ object ; }
Creates a new entry for `class` and populates it with `data`.

@param string $class   - the class of the entity to create
@param mixed  $data    - the serialized data of the object to create
@param array  $options - additional creation options

@return object
Creates a new entry for class and populates it with data .