|
|
@@ -273,7 +273,8 @@ class Table implements RepositoryInterface, EventListenerInterface
|
|
|
* define validation and do any other initialization logic you need.
|
|
|
*
|
|
|
* ```
|
|
|
- * public function initialize(array $config) {
|
|
|
+ * public function initialize(array $config)
|
|
|
+ * {
|
|
|
* $this->belongsTo('Users');
|
|
|
* $this->belongsToMany('Tagging.Tags');
|
|
|
* $this->primaryKey('something_else');
|
|
|
@@ -1100,7 +1101,8 @@ class Table implements RepositoryInterface, EventListenerInterface
|
|
|
* you will need to create a method in your Table subclass as follows:
|
|
|
*
|
|
|
* ```
|
|
|
- * public function validationForSubscription($validator) {
|
|
|
+ * public function validationForSubscription($validator)
|
|
|
+ * {
|
|
|
* return $validator
|
|
|
* ->add('email', 'valid-email', ['rule' => 'email'])
|
|
|
* ->add('password', 'valid', ['rule' => 'notEmpty'])
|
|
|
@@ -1203,6 +1205,8 @@ class Table implements RepositoryInterface, EventListenerInterface
|
|
|
* to be saved. It is possible to provide different options for saving on associated
|
|
|
* table objects using this key by making the custom options the array value.
|
|
|
* If false no associated records will be saved. (default: true)
|
|
|
+ * - checkExisting: Whether or not to check if the entity already exists, assuming that the
|
|
|
+ * entity is marked as not new, and the primary key has been set.
|
|
|
*
|
|
|
* ### Events
|
|
|
*
|
|
|
@@ -1268,7 +1272,8 @@ class Table implements RepositoryInterface, EventListenerInterface
|
|
|
$options = new ArrayObject($options + [
|
|
|
'atomic' => true,
|
|
|
'associated' => true,
|
|
|
- 'checkRules' => true
|
|
|
+ 'checkRules' => true,
|
|
|
+ 'checkExisting' => true
|
|
|
]);
|
|
|
|
|
|
if ($entity->errors()) {
|
|
|
@@ -1303,7 +1308,7 @@ class Table implements RepositoryInterface, EventListenerInterface
|
|
|
{
|
|
|
$primaryColumns = (array)$this->primaryKey();
|
|
|
|
|
|
- if ($primaryColumns && $entity->isNew() && $entity->has($primaryColumns)) {
|
|
|
+ if ($options['checkExisting'] && $primaryColumns && $entity->isNew() && $entity->has($primaryColumns)) {
|
|
|
$alias = $this->alias();
|
|
|
$conditions = [];
|
|
|
foreach ($entity->extract($primaryColumns) as $k => $v) {
|