mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-06-22 22:53:43 +00:00
clean code and remove unneeded checks
This commit is contained in:
parent
d4a0883cb9
commit
67af8b37db
1 changed files with 29 additions and 29 deletions
|
@ -1807,6 +1807,11 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($fields) && empty($joined)) {
|
||||||
|
$this->whitelist = $_whitelist;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$count = count($fields);
|
$count = count($fields);
|
||||||
|
|
||||||
if (!$exists && $count > 0) {
|
if (!$exists && $count > 0) {
|
||||||
|
@ -1843,38 +1848,33 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($success) {
|
if ($success && !empty($joined)) {
|
||||||
if (!empty($joined)) {
|
$this->_saveMulti($joined, $this->id, $db);
|
||||||
$this->_saveMulti($joined, $this->id, $db);
|
|
||||||
} elseif ($count === 0) {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($success) {
|
|
||||||
if ($count > 0) {
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($created) {
|
|
||||||
$this->data[$this->alias][$this->primaryKey] = $this->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($options['callbacks'] === true || $options['callbacks'] === 'after') {
|
|
||||||
$event = new CakeEvent('Model.afterSave', $this, array($created, $options));
|
|
||||||
$this->getEventManager()->dispatch($event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
$success = $this->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_clearCache();
|
|
||||||
$this->validationErrors = array();
|
|
||||||
$this->data = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->whitelist = $_whitelist;
|
$this->whitelist = $_whitelist;
|
||||||
|
|
||||||
|
if (!$success) {
|
||||||
|
return $success;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($count > 0) {
|
||||||
|
if ($created) {
|
||||||
|
$this->data[$this->alias][$this->primaryKey] = $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($options['callbacks'] === true || $options['callbacks'] === 'after') {
|
||||||
|
$event = new CakeEvent('Model.afterSave', $this, array($created, $options));
|
||||||
|
$this->getEventManager()->dispatch($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$success = $this->data;
|
||||||
|
|
||||||
|
$this->_clearCache();
|
||||||
|
$this->validationErrors = array();
|
||||||
|
$this->data = false;
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue