/** * @param string $identifier * @param RepositoryInterface $repository * @param string $className * * @return object|null */ private function tryToFindEntity($identifier, RepositoryInterface $repository, $className) { if ('slug' === $this->routeConfigs[$className]['field']) { return $repository->findOneBySlug($identifier); } if ('name' === $this->routeConfigs[$className]['field']) { return $repository->findOneByName($identifier); } if ('permalink' === $this->routeConfigs[$className]['field']) { return $repository->findOneByPermalink($identifier); } return $repository->findOneBy([$this->routeConfigs[$className]['field'] => $identifier]); }