Cake\ORM\Table::patchEntities PHP Method

patchEntities() public method

Those entries in $entities that cannot be matched to any record in $data will be discarded. Records in $data that could not be matched will be marshalled as a new entity. When merging HasMany or BelongsToMany associations, all the entities in the $data array will appear, those that can be matched by primary key will get the data merged, but those that cannot, will be discarded. You can limit fields that will be present in the merged entities by passing the fieldList option, which is also accepted for associations: $articles = $this->Articles->patchEntities($articles, $this->request->data(), [ 'fieldList' => ['title', 'body', 'tags', 'comments'], 'associated' => ['Tags', 'Comments.Users' => ['fieldList' => 'username']] ] ); You can use the Model.beforeMarshal event to modify request data before it is converted into entities.
public patchEntities ( $entities, array $data, array $options = [] )
$data array
$options array
    public function patchEntities($entities, array $data, array $options = [])
    {
        if (!isset($options['associated'])) {
            $options['associated'] = $this->_associations->keys();
        }
        $marshaller = $this->marshaller();
        return $marshaller->mergeMany($entities, $data, $options);
    }