Fetch target entity or entities.

@param Entity $entity
@return mixed
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();
    }
504252
private function getMapping($entity)
    {
        if (!array_key_exists($entity, $this->mappings)) {
            throw new \InvalidArgumentException("'$entity' is not a valid mapping key. One of [".implode(', ', array_keys($this->mappings)).'] is expected.');
        }

        return $this->mappings[$entity];
    }
369982
public function find($entity)
    {
        $conditions = array();

        if (is_array($entity)) {
            foreach ($entity as $key => $value) {
                $conditions[$this->_target_property.'.'.$key] = $value;
            }
        } else {
            $conditions[$this->_target_property] = $entity;
        }

        $conditions[$this->_property] = $this->_root;

        return $this->_child->find($conditions);
    }
899822
private function getContentFromEntity( $entity ) {
		switch ( $entity->getType() ) {
			case Item::ENTITY_TYPE:
				return new ItemContent( $entity );
			case Property::ENTITY_TYPE:
				return new PropertyContent( $entity );
			default:
				throw new RuntimeException( 'I cant get a content for this type of entity' );
		}
	}
1307293
public function getMapperFor($entity)
    {
        return  $this->mappers->containsKey($entity)
            ? $this->mappers->get($entity)
            : $this->createMapper($entity);
    }
813939
public function getManagerForEntity($entity): EntityManagerInterface
    {
        $class = ClassUtils::getClass($entity);
        $entityManager = $this->doctrine->getManagerForClass($class);
        if (!$entityManager instanceof EntityManagerInterface) {
            throw new \InvalidArgumentException("No manager found for class {$class}");
        }

        return $entityManager;
    }
1309042
protected function getCurrent(EntityInterface $entity) {
		$conditions = $this->buildConditions($entity);

		return $this->_table->find()
			->where($conditions)
			->first();
	}
925907
protected function generateGetExtensionsMethod(Entity $entity)
    {
        $lines      = [];
        $descriptor = $entity->getDescriptor();
        $fieldName  = $this->getUniqueFieldName($descriptor, 'extensions');

        $lines[] = 'if ( $this->' . $fieldName . ' !== null) {';
        $lines[] = '    return $this->' . $fieldName . ';';
        $lines[] = '}';
        $lines[] = null;
        $lines[] = 'return $this->' . $fieldName . ' = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);';

        return MethodGenerator::fromArray([
            'name'       => 'extensions',
            'body'       => implode(PHP_EOL, $lines),
            'docblock'   => [
                'shortDescription' => "{@inheritdoc}"
            ]
        ]);
    }
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 )
        );

    }
584495
public function getDraftRevision($entity)
    {
        $currentRevision = $this->getCurrentRevision($entity);
        $latestRevision = $this->getLatestRevision($entity);

        return ($currentRevision < $latestRevision) ? $latestRevision : null;
    }
1241525
protected function getEntityKey($entity)
    {
        $keyName = Manager::getMapper($entity)->getEntityMap()->getKeyName();

        $wrapper = $this->factory->make($entity);

        return $wrapper->getEntityAttribute($keyName);
    }
642349
protected function getEntityTable($entity)
    {
        if (!$entity instanceof EntityInterface) {
            $entity = $this->getEntityClass($entity);
        }
        return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
    }
79336
public static function update($entity)
    {
        $entityManager = self::getEntityManager();
        $entity = $entityManager->merge($entity);
        $entityManager->flush(); // transact

        return $entity;
    }
769047
private function getClass($entity)
    {
        if (is_object($entity)) {
            return get_class($entity);
        }

        if (class_exists($entity)) {
            return $entity;
        }

        $realClassName = $this->classnameResolver->resolveFullQualifiedClassname($entity);

        return $realClassName;
    }
1362252
public function extract($entity)
    {
        $metadata = $this->getMetadata();
        $collection = [];
        
        foreach ($metadata->getSQLNames() as $sqlName) {
            $propertyName = $metadata->getName($sqlName, Metadata::CAMILIZED);
            $propertyValue = $this->getReflection()->getProperty($propertyName)->getValue($entity);
            $propertyValue = $propertyValue !== null
                ? $metadata->toPlatform($metadata->getName($sqlName), $propertyValue) : null;
            $collection[$sqlName] = $propertyValue;
        }
        
        return $collection;
    }
1229189
private function getRepository($entity)
    {
        if (!array_key_exists($entity, $this->repositories)) {
            throw new \InvalidArgumentException("'$entity' is not a valid repository. One of [".implode(', ', array_keys($this->repositories)).'] is expected.');
        }

        return $this->repositories[$entity];
    }
410011
public function getPositionFieldByEntity($entity)
	{
		if (is_object($entity)) {
			$entity = \Doctrine\Common\Util\ClassUtils::getClass($entity);
		}

		if (isset($this->positionField['entities'][$entity])) {
			return $this->positionField['entities'][$entity];
		} else {
			return $this->positionField['default'];
		}
	}