Gets the relation conditions

@param EntityInterface $entity
@return array
355179
protected function getConditions(EntityInterface $entity)
    {
        $field = "{$this->getParentTableName()}.{$this->getForeignKey()}";
        $property = $this->getPropertyName();
        $conditions = [
            "{$field} = :{$property}" => [
                ":{$property}" => $entity->getId()
            ]
        ];
        return $conditions;
    }
129586
public function saveEvent(EntityInterface $entity): array
    {
        $response = [
            'status' => false,
            'errors' => [],
            'entity' => null,
        ];

        if ($entity instanceof EntityInterface) {
            $entity = $entity->toArray();
        }

        if (empty($entity['id'])) {
            unset($entity['id']);
        }

        $query = $this->find()
            ->where([
                //'source' => empty($entity['source']) ? null : $entity['source'],
                'source_id' => $entity['source_id'],
                'calendar_id' => $entity['calendar_id'],
            ]);

        $query->execute();

        /** @var EntityInterface $event */
        $event = (!$query->count()) ? $this->newEntity() : $query->first();
        $event = $this->patchEntity($event, $entity);

        $saved = $this->save($event);

        if ($saved) {
            $response['status'] = true;
            $response['entity'] = $saved;
        } else {
            $response['errors'] = $event->getErrors();
        }

        return $response;
    }
199058
public function update(EntityInterface $entity)
	{
		$sql = <<<EOT
UPDATE `$this->tableName` 
SET 
	`Name` = :name , 
	`Description` = :description , 
	`Created` = :created  
WHERE `ProjectId` = :id 
EOT;

		$stmt = $this->pdo->prepare($sql);
		$stmt->bindParam(':id', $entity->getProjectId(), \PDO::PARAM_INT);
		$stmt->bindParam(':name', $entity->getName(), \PDO::PARAM_STR);
		$stmt->bindParam(':description', $entity->getDescription(), \PDO::PARAM_STR);
		$stmt->bindParam(':created', $entity->getCreatedRfc3339(), \PDO::PARAM_STR);
		$res = $stmt->execute();

		if ($res === false || $stmt->rowCount() !== 1) {
			return false;
		}

		return $entity;
	}
441651
public function getVersionId(EntityInterface $entity)
    {
        $table = TableRegistry::get($this->_config['versionTable']);
        $preexistent = $table->find()
            ->select(['version_id'])
            ->where([
                    'model' => $this->_config['referenceName']
                ] + $this->_extractForeignKey($entity))
            ->order(['id desc'])
            ->limit(1)
            ->enableHydration(false)
            ->toArray();

        return Hash::get($preexistent, '0.version_id', 0);
    }
396942
protected function extractKeywordsFromKeywordableEntity(KeywordableInterface $entity)
    {
        $references = array();
        $keywords = $entity->getKeywords();

        foreach ($keywords as $keyword) {
            $references[] = $keyword->getId();
        }

        return $references;
    }
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;
  }
205296
private function getIndexableEntities($entity = null)
    {
        if ($entity) {
            return [$entity];
        }

        $entities = [];
        $namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
        $metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');

        foreach ($namespaces->getEntityClassnames() as $classname) {
            try {
                $metaInformation = $metaInformationFactory->loadInformation($classname);
                if ($metaInformation->isNested()) {
                    continue;
                }

                array_push($entities, $metaInformation->getClassName());
            } catch (SolrMappingException $e) {
                continue;
            }
        }

        return $entities;
    }
361710
public function getEntityArrayValues($entity)
    {
        $values = [];
        $properties = $this->getEntityProperties($entity);
        $metadata = $this->em->getClassMetadata(get_class($entity));
        foreach ($properties as $property) {
            $values[$property] = $metadata->getFieldValue($entity, $property);
        }
        return $values;
    }
969229
public function solveFetch(Entity &$entity)
    {
        // We need to find all target entities with the ID defined in the current entity source column
        $column = $this->relation->join->column;

        $value = $entity->{$column};
        $where = array($this->relation->join->targetColumn => $value);

        $query = EntityManager::find($this->relation->targetEntity);
        return $query->where($where)->all();
    }
878442
public function encryptEntity(EntityInterface $entity): EntityInterface
    {
        if (!$this->isEncryptable($entity)) {
            return $entity;
        }

        $fields = $this->getFields();
        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $table = $this->getTable();

        $patch = [];
        foreach ($fields as $name => $field) {
            if (!$table->hasField($name)) {
                continue;
            }
            $value = $entity->get($name);
            if ($value === null || is_resource($value)) {
                continue;
            }
            $encrypted = Security::encrypt($value, $encryptionKey);
            if ($base64 === true) {
                $encrypted = base64_encode($encrypted);
            }
            $patch[$name] = $encrypted;
        }

        if (!empty($patch)) {
            $accessible = array_fill_keys(array_keys($patch), true);
            $entity = $table->patchEntity($entity, $patch, [
                'accessibleFields' => $accessible,
            ]);
        }

        return $entity;
    }
753782
protected function _unsetEmptyFields(EntityInterface $entity)
    {
        $translations = (array)$entity->get('_translations');
        foreach ($translations as $locale => $translation) {
            $fields = $translation->extract($this->_config['fields'], false);
            foreach ($fields as $field => $value) {
                if (strlen($value) === 0) {
                    $translation->unsetProperty($field);
                }
            }

            $translation = $translation->extract($this->_config['fields']);

            // If now, the current locale property is empty,
            // unset it completely.
            if (empty(array_filter($translation))) {
                unset($entity->get('_translations')[$locale]);
            }
        }

        // If now, the whole _translations property is empty,
        // unset it completely and return
        if (empty($entity->get('_translations'))) {
            $entity->unsetProperty('_translations');
        }
    }
150613
private function getAddresses($entity)
    {
        if ($entity instanceof AccountInterface) {
            return $entity->getAccountAddresses();
        } elseif ($entity instanceof Contact) {
            return $entity->getContactAddresses();
        }

        return;
    }
412538
protected function registerEntity(EntityInterface $entity)
    {
        Orm::getRepository($this->getEntityClassName())
            ->getIdentityMap()
            ->set($entity);
        return $this;
    }
215869
public function getSaverForEntity(
        EntityInterface $entity
    ): EntitySaverInterface {
        $fqn = $this->getEntityNamespace($entity);

        return $this->getSaverForEntityFqn($fqn);
    }
674219
public function decode(EntityInterface $entity) {
		$idField = $this->_primaryKey;
		$hashid = $entity->get($idField);
		if (!$hashid) {
			return false;
		}

		$field = $this->_config['field'];
		if (!$field) {
			return false;
		}

		$id = $this->decodeHashid($hashid);

		$entity->set($field, $id);
		$entity->setDirty($field, false);

		return true;
	}
1063296
public function set(EntityInterface $entity)
    {
        $key = get_class($entity).'::'.$entity->getId();
        $this->getCache()->set($key, $entity);
        return $this;
    }
1246023
public function remove(EntityInterface $entity)
    {
        $reflection = $this->getEntityClassReflection();
        
        if ($reflection->isInstance($entity)) {
            
            // trigger event for entity and dispatcher on before remove
            $this->dispatchEvent(ORMEvents::beforeRemove, new EntityLifecycleEvent($this, $entity));
            
            // needed variables
            $metadata = $this->getEntityMetadata();
            $remover = $this->createRemover();
            $identifier = $this->getEntityIdentifier();
            $connection = $this->getConnection();
            $propertyIdentifier = $metadata->getName($identifier, Metadata::CAMILIZED);
            
            // refinement of the request
            $remover->addConditions($identifier, $entity->getByProperty($propertyIdentifier));
            $remover->setLimit(1)->setOffset(0);
            
            // open transaction and try to execute sql
            $connection->transaction(function () use ($connection, $remover) {
                $connection->execute($remover->toSQL());
            });
            
            // reset identifier for removed entity
            $entity->setByProperty($propertyIdentifier, null);
            
            // trigger event for entity and dispatcher on after remove and all actions
            $this->dispatchEvent(ORMEvents::afterRemove, new EntityLifecycleEvent($this, $entity));
            
            return $this;
        }
        
        throw new NotSupportedException(sprintf('Unable to remove entity! Actual entity "%s" expected entity "%s"',
            get_class($entity), $this->getEntityName()));
    }