Returns items that have no cascade callback.

@param \Cake\Datasource\EntityInterface $entity The entity to delete associations for.
@param array $options The options used in the delete operation.
@return \Cake\ORM\Association[]
351181
protected function _getNoCascadeItems($entity, $options)
    {
        $noCascade = [];
        foreach ($this->_items as $assoc) {
            if (!$assoc->getCascadeCallbacks()) {
                $noCascade[] = $assoc;
                continue;
            }
            $assoc->cascadeDelete($entity, $options);
        }

        return $noCascade;
    }
891328
public function cover($entity, array $options = []) {
		$options += ['internal' => false];
		$result = [
			'type' => $entity->raw['type'],
			'title' => $entity->title()
		];

		if ($options['internal']) {
			return ['url' => 'instagram://' . $entity->id()] + $result;
		}
		if (!$url = static::_url($entity->raw)) {
			return false;
		}
		return compact('url') + $result;
	}
650323
protected function _emailVerification(EntityInterface &$entity, $options) {
		if ($options['emailVerification'] === true) {
			$entity->set($this->_field('emailToken'), $this->generateToken($options['tokenLength']));
			if ($options['verificationExpirationTime'] !== false) {
				$entity->set($this->_field('emailTokenExpires'), $this->expirationTime($options['verificationExpirationTime']));
			}
			$entity->set($this->_field('emailVerified'), false);
		} else {
			$entity->set($this->_field('emailVerified'), true);
		}
	}
232292
public function delete(Entity $entity)
    {
        $this->delete = new Delete('history');
        $this->delete->where(array(
             'history.history_id = ?' => $entity->getHistoryId()
        ));
                 
        return $this->deleteRow();
    }
759134
public function removeAllImageVersions(EntityInterface $entity, array $options = []) {
		return $this->removeImageVersions(
			$entity,
			$this->getAllVersionsKeysForModel($entity->get('model')),
			$options
		);
	}
572936
public function deleteOne(FlexibleEntityInterface &$entity)
    {
        $entity = $this->deleteByPK($entity->fields($this->getStructure()->getPrimaryKey()));

        return $this;
    }
21756
public function delete($entity)
    {
        if ($this->manager->isTraversable($entity)) {
            return $this->deleteCollection($entity);
        } else {
            $this->deleteEntity($entity);
        }
    }
133249
public function referencedBy( $entity )
    {

        if( !( $entity instanceof Base || $entity instanceof Container ) ) {
            throw new \InvalidArgumentException("You can only lookup references by Entity or Container");
        }

        $class = $entity instanceof Container
            ? $entity->class
            : $entity;

        $properties = $this->propertiesOfTypeGet( $class );

        // found a entity?
        if( !$properties ) {
            throw new \LogicException(
                sprintf(
                    "Can't find which entity property for repository `%s` references entity of type `%s`",
                    $this->entity,
                    $entityClass
                )
            );
        } elseif( count( $properties ) > 1 ) {
            throw new \LogicException(
                sprintf(
                    "Multiple columns [%s] reference a entity of this type [%s]. This is ambiguous. Can't help you here.",
                    implode( ",", $properties ),
                    \Bond\get_unqualified_class( $entity )
                )
            );
        }

        $property = array_pop( $properties );

        // get references to this entity
        $filterComponent = $this->getFindFilterFactory()
            ->get( $property, null, $entity );

        return $this->findByFilterComponents(
            FindFilterComponentFactory::FIND_ALL,
            array( $property => $filterComponent )
        );

    }
1079435
public function deleteEntity(SearchableEntityInterface $entity)
    {
        foreach ($this->locales as $locale) {
            $uid       = $this->getDocUid($entity, $locale);
            $indexType = $this->indexType;
            $this->searchProvider->deleteDocument($this->indexName, $indexType, $uid);
        }
    }
595725
protected function getImplicitParams(Entity $entity)
    {
        if ($entity instanceof ContentItem && $entity->isIndex()) {
            return [
                'entries' => $this->entries->getIndexEntries($entity),
            ];
        }

        return [];
    }
327837
private function cascadePersist($entity, array &$visited)
    {
        $class = $this->em->getClassMetadata(get_class($entity));

        if ($entity instanceof GhostObjectInterface && ! $entity->isProxyInitialized()) {
            // nothing to do - proxy is not initialized, therefore we don't do anything with it
            return;
        }

        foreach ($class->getDeclaredPropertiesIterator() as $association) {
            if (! ($association instanceof AssociationMetadata && in_array('persist', $association->getCascade(), true))) {
                continue;
            }

            /** @var AssociationMetadata $association */
            $relatedEntities = $association->getValue($entity);
            $targetEntity    = $association->getTargetEntity();

            switch (true) {
                case $relatedEntities instanceof PersistentCollection:
                    // Unwrap so that foreach() does not initialize
                    $relatedEntities = $relatedEntities->unwrap();
                    // break; is commented intentionally!

                case $relatedEntities instanceof Collection:
                case is_array($relatedEntities):
                    if (! ($association instanceof ToManyAssociationMetadata)) {
                        throw ORMInvalidArgumentException::invalidAssociation(
                            $this->em->getClassMetadata($targetEntity),
                            $association,
                            $relatedEntities
                        );
                    }

                    foreach ($relatedEntities as $relatedEntity) {
                        $this->doPersist($relatedEntity, $visited);
                    }

                    break;

                case $relatedEntities !== null:
                    if (! $relatedEntities instanceof $targetEntity) {
                        throw ORMInvalidArgumentException::invalidAssociation(
                            $this->em->getClassMetadata($targetEntity),
                            $association,
                            $relatedEntities
                        );
                    }

                    $this->doPersist($relatedEntities, $visited);
                    break;

                default:
                    // Do nothing
            }
        }
    }
329049
protected function deleteRelation(
        EntityInterface $entity,
        EntityCollectionInterface $collection
    ) {
        $repository = $this->getParentRepository();
        $adapter = $repository->getAdapter();
        $parts = explode('\\', $this->getEntityDescriptor()->className());
        $entityName = lcfirst(array_pop($parts));
        $parts = explode('\\', $this->getParentEntityDescriptor()->className());
        $relatedName = lcfirst(array_pop($parts));
        $value = $collection->parentEntity()->getId();
        Sql::createSql($adapter)
            ->delete($this->getRelationTable())
            ->where(
                [
                    "{$this->getRelatedForeignKey()} = :{$relatedName} AND
                     {$this->getForeignKey()} = :{$entityName}" => [
                        ":{$relatedName}" => $entity->getId(),
                        ":{$entityName}" => $value
                    ]
                ]
            )
            ->execute();
        return $this;
    }
1113312
private function cascadePersist($entity, array &$visited)
    {
        $class = $this->em->getClassMetadata(get_class($entity));

        $associationMappings = array_filter(
            $class->associationMappings,
            function ($assoc) { return $assoc['isCascadePersist']; }
        );

        foreach ($associationMappings as $assoc) {
            $relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity);

            switch (true) {
                case ($relatedEntities instanceof PersistentCollection):
                    // Unwrap so that foreach() does not initialize
                    $relatedEntities = $relatedEntities->unwrap();
                    // break; is commented intentionally!

                case ($relatedEntities instanceof Collection):
                case (is_array($relatedEntities)):
                    if (($assoc['type'] & ClassMetadata::TO_MANY) <= 0) {
                        throw ORMInvalidArgumentException::invalidAssociation(
                            $this->em->getClassMetadata($assoc['targetEntity']),
                            $assoc,
                            $relatedEntities
                        );
                    }

                    foreach ($relatedEntities as $relatedEntity) {
                        $this->doPersist($relatedEntity, $visited);
                    }

                    break;

                case ($relatedEntities !== null):
                    if (! $relatedEntities instanceof $assoc['targetEntity']) {
                        throw ORMInvalidArgumentException::invalidAssociation(
                            $this->em->getClassMetadata($assoc['targetEntity']),
                            $assoc,
                            $relatedEntities
                        );
                    }

                    $this->doPersist($relatedEntities, $visited);
                    break;

                default:
                    // Do nothing
            }
        }
    }
78573
protected function _getScope(EntityInterface $entity)
    {
        $scope = [];
        $config = $this->getConfig();

        // If scope are specified and data for all scope fields is not
        // provided we cannot calculate new order
        if ($config['scope']) {
            $scope = $entity->extract($config['scope']);
            if (count($scope) !== count($config['scope'])) {
                return false;
            }

            // Modify where clauses when NULL values are used
            foreach ($scope as $field => $value) {
                if (is_null($value)) {
                    $scope[$field . ' IS'] = $value;
                    unset($scope[$field]);
                }
            }
        }

        return $scope;
    }
722926
protected function getDefaultOperations(EntityInterface $entity) {
    $operations = [];
    if ($entity->access('update') && $entity->hasLinkTemplate('edit-form')) {
      $operations['edit'] = [
        'title' => $this->t('Edit'),
        'weight' => 10,
        'url' => $entity->urlInfo('edit-form'),
      ];
    }
    if ($entity->access('delete') && $entity->hasLinkTemplate('delete-form')) {
      $operations['delete'] = [
        'title' => $this->t('Delete'),
        'weight' => 100,
        'url' => $entity->urlInfo('delete-form'),
      ];
    }

    return $operations;
  }
690432
public function afterDelete(Event $event, EntityInterface $entity, ArrayObject $options) {
		$field = $this->getConfig('field');

		$value = $entity->get($field);
		if (!$value) {
			return;
		}

		$conditions = $this->buildConditions($entity);

		$order = $this->getConfig('findOrder');
		if ($order === null) {
			$order = [];
			if ($this->_table->getSchema()->getColumn('modified')) {
				$order['modified'] = 'DESC';
			}
		}
		$entity = $this->_table->find()->where($conditions)->order($order)->first();
		if (!$entity) {
			// This should be caught with a validation rule if at least one "primary" must exist
			return;
		}

		$entity->set($field, true);
		$this->_table->saveOrFail($entity);
	}
878560
protected function _afterRegister(EntityInterface $entity, $options) {
		if ($entity) {
			if ($options['emailVerification'] === true) {
				$this->sendVerificationEmail($entity, [
					'to' => $entity->get($this->_field('email'))
				]);
			}
		}

		return $entity;
	}