本文整理汇总了PHP中Doctrine\ORM\EntityRepository::getClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::getClassName方法的具体用法?PHP EntityRepository::getClassName怎么用?PHP EntityRepository::getClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::getClassName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (!$value) {
return null;
}
$entity = $this->repository->findOneBy(array($this->identifier => $value));
if (null === $entity) {
throw new TransformationFailedException(sprintf('Entity "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
}
return $entity;
}
示例2: filterIn
/**
* @param mixed $value
*
* @throws BadRequestException
*
* @return object
*/
public function filterIn($value)
{
if (!is_object($value)) {
$entity = $this->repository->find($value);
} elseif ($value instanceof QueryInterface) {
$entity = $value->getEntity($this->repository);
}
$class = $this->repository->getClassName();
if (!$entity instanceof $class) {
throw new BadRequestException('Desired entity of type \'' . $this->repository->getClassName() . '\' could not be found.');
}
return $entity;
}
示例3: findOneFolderByPath
public function findOneFolderByPath($path)
{
//Find a folder entity in db
$folder = $this->folderRepo->findOneByPath($path);
if (!$folder) {
$class = $this->folderRepo->getClassName();
$folder = new $class();
$folder->setName(basename($path));
$folder->setPath($path);
$this->em->persist($folder);
}
return $folder;
}
示例4: transform
/**
* @param mixed $entity
* @return mixed|null
*/
public function transform($entity)
{
if (null === $entity) {
return null;
}
$className = $this->repository->getClassName();
if (!$entity instanceof $className) {
throw new TransformationFailedException(sprintf('Object must be instance of %s, instance of %s has given.', $className, get_class($entity)));
}
$methodName = 'get' . ucfirst($this->property);
if (!method_exists($entity, $methodName)) {
throw new InvalidConfigurationException(sprintf('There is no getter for property "%s" in class "%s".', $this->property, $this->class));
}
return $entity->{$methodName}();
}
示例5: total
public function total()
{
$metadata = $this->em->getClassMetadata($this->repository->getClassName());
$identifiers = $metadata->getIdentifierFieldNames();
$id = $identifiers[0];
return $this->repository->createQueryBuilder("q")->select("COUNT(q.{$id})")->getQuery()->getSingleScalarResult();
}
示例6: getOrderTypeEntityById
/**
* Returns OrderType entity with given id.
*
* @param int $typeId
*
* @throws EntityNotFoundException
*
* @return null|OrderType
*/
public function getOrderTypeEntityById($typeId)
{
// Get desired status.
$typeEntity = $this->orderTypeRepository->find($typeId);
if (!$typeEntity) {
throw new EntityNotFoundException($this->orderTypeRepository->getClassName(), $typeId);
}
return $typeEntity;
}
示例7: create
/**
* @return mixed
*/
public function create()
{
$className = $this->source->getClassName();
return new $className();
}
示例8: getClassName
/**
* @return string
*/
public function getClassName()
{
return parent::getClassName();
}
示例9: __construct
public function __construct(EntityRepository $repository)
{
$this->repository = $repository;
$this->entity = $repository->getClassName();
}
示例10: batchUpdate
/**
* @param $entities
* @param $params
* @param $method
* @return bool
*/
public function batchUpdate($entities, $params, $method)
{
$className = $this->repository->getClassName();
return $this->formHandler->batchProcessForm(new EntitiesHolder($entities), ['entities' => $params], $method, new $className());
}
示例11: getClassName
/**
* Returns the class name of the object managed by the repository.
*
* @return string
*/
public function getClassName()
{
return $this->repository->getClassName();
}
示例12: addElement
/**
* @param int $id
* @param EntityRepository $repository
*
* @param null $label
*
* @return bool
* @throws \Doctrine\ORM\NoResultException
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function addElement($id = 0, EntityRepository $repository, $label = NULL)
{
$em = $this->getEntityManager();
$qb = $repository->createQueryBuilder('a');
$class = $repository->getClassName();
/* @var TreeInterface $entry */
$entry = new $class();
if (!empty($label)) {
$entry->setLabel($label);
}
if ($id == 0) {
// get max_right
$query = $qb->select('MAX(a.rgt) as max_rgt')->getQuery()->getSingleResult();
if (isset($query['max_rgt'])) {
$lft = $query['max_rgt'];
$rgt = $lft + 1;
/* @var TreeInterface $entry */
$entry->setLft($lft)->setRgt($rgt)->setDepth(1);
$em->persist($entry);
$em->flush();
return $entry->getId();
}
// add to parent
} else {
/* @var TreeInterface|NULL $parent */
$parent = $repository->find($id);
//dump($parent);
if ($parent !== NULL) {
$lft = $parent->getRgt();
$rgt = $lft + 1;
$queries = array();
// update rgt
$queries[] = $qb->update()->set('a.rgt', 'a.rgt + 2')->where('a.rgt >= :lft')->setParameter('lft', $lft)->getQuery()->getResult();
// update lft
$queries[] = $qb->update()->set('a.lft', 'a.lft + 2')->where('a.lft > :lft')->setParameter('lft', $lft)->getQuery()->getResult();
// set entry
$entry->setLft($lft)->setRgt($rgt)->setParent($parent)->setDepth($parent->getDepth() + 1);
$em->persist($entry);
$em->flush();
return $entry->getId();
}
}
return false;
}
示例13: deleteTranslatableEntities
/**
* Deletes the translatable entities for locale
*
* @param EntityRepository $repository
* @param LocaleInterface $locale
* @param OutputInterface $output
*/
protected function deleteTranslatableEntities(EntityRepository $repository, LocaleInterface $locale, OutputInterface $output)
{
$entityManager = $this->getDoctrineHelper()->getEntityManager();
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('locale', $locale->getCode()));
$collection = $repository->matching($criteria);
$collection->map(function (LocaleAwareInterface $entity) use($entityManager) {
$entityManager->remove($entity);
});
$output->write(sprintf('Deleted <info>%s</info> entities <info>%s</info>', $collection->count(), $repository->getClassName()), true);
}
示例14: truncate
protected function truncate(EntityRepository $repository)
{
$classMetaData = $this->entityManager->getClassMetadata($repository->getClassName());
$connection = $this->entityManager->getConnection();
$dbPlatform = $connection->getDatabasePlatform();
$sql = $dbPlatform->getTruncateTableSql($classMetaData->getTableName());
$connection->executeUpdate($sql);
}