Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Model/Behavior/DuplicatableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
* Duplicate record.
*
* @param string|int $id Id of entity to duplicate.
* @param array $saveOptions Additional save options to pass to save().
* @return \Cake\Datasource\EntityInterface|false New entity or false on failure
*/
public function duplicate(int|string $id): EntityInterface|false
public function duplicate(int|string $id, array $saveOptions = []): EntityInterface|false
{
return $this->_table->save(
$this->duplicateEntity($id),
$this->getConfig('saveOptions') + ['associated' => $this->getConfig('contain')]
$this->getConfig('saveOptions') + $saveOptions + ['associated' => $this->getConfig('contain'), 'duplicated' => true, 'originalId' => $id, 'duplicatedModel' => $this->_table->getAlias()]
);
}

Expand Down Expand Up @@ -187,7 +188,7 @@
* @param \Cake\ORM\Table|\Cake\ORM\Association $object Table or association instance.
* @return void
*/
protected function _modifyEntity(EntityInterface $entity, Table|Association $object): void

Check failure on line 191 in src/Model/Behavior/DuplicatableBehavior.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Method Duplicatable\Model\Behavior\DuplicatableBehavior::_modifyEntity() has parameter $object with generic class Cake\ORM\Table but does not specify its types: TBehaviors
{
// belongs to many is tricky
if ($object instanceof BelongsToMany && !$this->getConfig('preserveJoinData')) {
Expand Down Expand Up @@ -221,7 +222,7 @@
* @param array $parts Related properties chain.
* @return void
*/
protected function _drillDownAssoc(EntityInterface $entity, Table|Association $object, array $parts): void

Check failure on line 225 in src/Model/Behavior/DuplicatableBehavior.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Method Duplicatable\Model\Behavior\DuplicatableBehavior::_drillDownAssoc() has parameter $object with generic class Cake\ORM\Table but does not specify its types: TBehaviors
{
$assocName = array_shift($parts);
$prop = $object->{$assocName}->getProperty();
Expand Down
Loading