Set hasRepository

@param boolean $hasRepository

@return Entity

@throws \InvalidArgumentException
343372
public function setHasRepository($hasRepository)
    {
        if (!is_bool($hasRepository)) {
            throw new \InvalidArgumentException('The attribute hasRepository on the class Entity has to be boolean (' . gettype($hasRepository) . ('object' === gettype($hasRepository) ? ' ' . get_class($hasRepository) : '') . ' given).');
        }

        $this->hasRepository = $hasRepository;

        return $this;
    }
674451
public function setEntityLoaderRepository($entityLoaderRepository)
    {
        // force mode
        $this->setEntityLoaderMode(self::ENTITY_LOADER_REPOSITORY);

        $this->entityLoaderRepository = $entityLoaderRepository;

        return $this;
    }
571250
public function setRepository(Repository $model, $default = null, callable $handler = null, $customName = null)
    {
        // B/C
        if (is_string($handler)) {
            $customName = $handler;
        } elseif (is_callable($handler)) {
            $handler($model, $this);
        }

        $this->repository->setRepository($model, $default, $customName);

        return $this;
    }
436672
public function setBase(UriInterface $uri)
    {
        if (! $this->parser->isAbsolute($uri)) {
            throw new InvalidArgumentException('The base URI must be absolute.');
        }

        $this->base = $uri;

        return $this;
    }
1302263
public function addRepositories($repositories)
    {
        if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' .
                ' "%s" given',
                is_object($repositories) ? get_class($repositories) : gettype($repositories)
            ));
        }
        foreach ($repositories as $repo) {
            $this->addRepository($repo);
        }
    }
626719
public function setIsValid($isValid)
    {
        if (is_bool($isValid)) {
            $this->isValid = $isValid;
        } else {
            throw new \InvalidArgumentException(
                "Invalid value '" . $isValid . "' for argument 'isValid' given."
            );
        }

        return $this;
    }
1208108
protected function getRepository(): AbstractRepository
    {
        return $this->getRepositoryFactory()->getRepositoryForEntity(
            AbstractRepository::getEntityNameFromClassName($this->getEntityClassName()),
            $this->connectionName
        );
    }
883509
private function setAssociatedEntities(array $repositories)
    {
        $newEntities = [];

        foreach ($repositories as $repositoryName => $findMethods) {
            foreach ($findMethods as $findMethod => $groupedBySortAssociatedEntitiesToWarm) {
                foreach ($groupedBySortAssociatedEntitiesToWarm as $orderByToken => $groupedAssociatedEntitiesToWarm) {
                    $associatedEntitiesToWarm = $groupedAssociatedEntitiesToWarm['entitiesToWarm'];

                    //Extract ids to search
                    $idsToSearch = array_map(function ($associatedEntityToWarm) {
                        return $associatedEntityToWarm->getEntityId();
                    }, $associatedEntitiesToWarm);

                    $orderBy = [];
                    if ($orderByToken !== 'unsorted') {
                        foreach ($groupedAssociatedEntitiesToWarm['orderBy'] as $orderAttribut => $order) {
                            $orderBy[$orderAttribut] = $order;
                        }
                    }

                    //Find by id for ManyToOne associations based on target entity id
                    //Find by mappedBy value for OneToMany associations based on owner entity id
                    $foundEntities = $this->em->getRepository($repositoryName)->findBy([
                        $findMethod => array_values($idsToSearch),
                    ], $orderBy);

                    /* @var AssociatedEntityToWarm[] $associatedEntitiesToWarm */
                    foreach ($associatedEntitiesToWarm as $associatedEntityToWarm) {
                        foreach ($foundEntities as $foundEntity) {
                            if ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_MANY_TO_ONE
                                && $foundEntity->getId() === $associatedEntityToWarm->getEntityId()
                            ) {
                                $inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
                                $inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();
                                $this->accessor->setValue($inheritorEntity, $inheritorPropertyName, $foundEntity);
                                continue;
                            } elseif ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_ONE_TO_MANY
                                && $this->accessor->getValue($foundEntity, $findMethod) === $associatedEntityToWarm->getInheritorEntity()
                            ) {
                                $inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
                                $inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();

                                //Don't use Collection getter directly and override Collection
                                //default behaviour to avoid useless query
                                $getter = 'get'.ucwords($inheritorPropertyName);
                                $inheritorEntity->$getter()->add($foundEntity);
                                $inheritorEntity->$getter()->setDirty(false);
                                $inheritorEntity->$getter()->setInitialized(true);

                                //Store new entities to warm if necessary
                                $newEntities[] = $foundEntity;
                                continue;
                            }
                        }
                    }
                }
            }
        }

        return $newEntities;
    }
629203
public function setModelType($modelType)
    {
        if ($modelType !== self::MODELTYPE_ENTITY && $modelType !== self::MODELTYPE_VALUEOBJECT) {
            throw new \InvalidArgumentException('"' . $modelType . '" is an invalid model type.', 1212519195);
        }
        $this->modelType = $modelType;
        if ($modelType === self::MODELTYPE_VALUEOBJECT) {
            $this->identityProperties = [];
            $this->repositoryClassName = null;
        }
    }
1327950
public function setRepositoryReference(RepositoryReference $repositoryReference)
    {
        parent::setRepositoryReference($repositoryReference);
        $this
            ->repository
            ->setRepositoryReference($repositoryReference);
    }
702241
public function setRepository(DocumentRepository $repository)
    {
        $this->repository = $repository;
        $this->manager = $repository->getDocumentManager();
        return $this;
    }
1154301
protected function callRepositoryMethod(string $method, ...$args)
    {
        $om = $this->getManager();
        $repo = $om->getRepository($this->getEntity());

        if (!method_exists($repo, $method) || !is_callable([$repo, $method])) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Method "%s" doesn\'t exist or isn\'t callable in EntityRepository "%s"',
                    $method,
                    get_class($repo)
                )
            );
        }

        return $repo->$method(...$args);
    }
812635
public function setInstitution($institution)
    {
        if (
                !is_string($institution)
             && !is_null($institution)
        ) {
            throw new \InvalidArgumentException(
                __CLASS__ . ' ' . __METHOD__ . ': Not a string'
            );
        }

        $this->institution = $institution;

        return $this;
    }
1182493
private function setEntityRepository()
    {
        try {
            $this->_repository = $this->_em->getRepository(self::ENTITY_CLASSNAME);
        } catch (\Exception $e) {
            throw new CacheException('Enable to load the cache entity repository', null, $e);
        }

        return $this;
    }
64039
public function setData($data)
    {
        if ($data instanceof Collection || $data instanceof Model) {
            $this->data = $data->toArray();
        } elseif (is_array($data) || $data instanceof Repository) {
            $this->data = $data;
        } else {
            throw new \InvalidArgumentException('Data must be an array, a Collection, a Model or a Repository');
        }
    }
1023477
public function hasOne($hasOne = null)
    {
        if ($hasOne === null)
        {
            return $this->_hasOne;
        }
        $this->_hasOne = $hasOne;

        return $this;
    }
1260446
public function setCentrifuge($centrifuge = array())
    {
        if (is_array($centrifuge) && $centrifuge) {
            $this->centrifuge = $centrifuge;
            return true;
        }
        throw new InvalidArgumentException('Invalid argument given');
    }