|
|
@@ -1677,10 +1677,19 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
|
|
|
{
|
|
|
$options += [
|
|
|
'atomic' => true,
|
|
|
- 'defaults' => true
|
|
|
+ 'defaults' => true,
|
|
|
+ '_primary' => true,
|
|
|
];
|
|
|
|
|
|
- return $this->_processFindOrCreate($search, $callback, $options);
|
|
|
+ $entity = $this->_executeTransaction(function () use ($search, $callback, $options) {
|
|
|
+ return $this->_processFindOrCreate($search, $callback, $options);
|
|
|
+ }, $options['atomic']);
|
|
|
+
|
|
|
+ if ($entity && $this->_transactionCommitted($options['atomic'], $options['_primary'])) {
|
|
|
+ $this->dispatchEvent('Model.afterSaveCommit', compact('entity', 'options'));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $entity;
|
|
|
}
|
|
|
|
|
|
/**
|