Cake\ORM\Table::_processDelete PHP Method

_processDelete() protected method

Will delete the entity provided. Will remove rows from any dependent associations, and clear out join tables for BelongsToMany associations.
protected _processDelete ( Cake\Datasource\EntityInterface $entity, ArrayObject $options ) : boolean
$entity Cake\Datasource\EntityInterface The entity to delete.
$options ArrayObject The options for the delete.
return boolean success
    protected function _processDelete($entity, $options)
    {
        if ($entity->isNew()) {
            return false;
        }
        $primaryKey = (array) $this->primaryKey();
        if (!$entity->has($primaryKey)) {
            $msg = 'Deleting requires all primary key values.';
            throw new InvalidArgumentException($msg);
        }
        if ($options['checkRules'] && !$this->checkRules($entity, RulesChecker::DELETE, $options)) {
            return false;
        }
        $event = $this->dispatchEvent('Model.beforeDelete', ['entity' => $entity, 'options' => $options]);
        if ($event->isStopped()) {
            return $event->result;
        }
        $this->_associations->cascadeDelete($entity, ['_primary' => false] + $options->getArrayCopy());
        $query = $this->query();
        $conditions = (array) $entity->extract($primaryKey);
        $statement = $query->delete()->where($conditions)->execute();
        $success = $statement->rowCount() > 0;
        if (!$success) {
            return $success;
        }
        $this->dispatchEvent('Model.afterDelete', ['entity' => $entity, 'options' => $options]);
        return $success;
    }