当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityRepository::getClassName方法代码示例

本文整理汇总了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;
 }
开发者ID:sfblaauw,项目名称:pulsar,代码行数:14,代码来源:EntityToIdentifierTransformer.php

示例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;
 }
开发者ID:arachne,项目名称:doctrine,代码行数:20,代码来源:FilterIn.php

示例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;
 }
开发者ID:jca,项目名称:AlbumBundle,代码行数:13,代码来源:Folder.php

示例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}();
 }
开发者ID:kwuerl,项目名称:EntityHiddenTypeBundle,代码行数:19,代码来源:ObjectToIdTransformer.php

示例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();
 }
开发者ID:rmukras,项目名称:coffee,代码行数:7,代码来源:Repository.php

示例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;
 }
开发者ID:sulu,项目名称:sulu-sales,代码行数:18,代码来源:OrderManager.php

示例7: create

 /**
  * @return mixed
  */
 public function create()
 {
     $className = $this->source->getClassName();
     return new $className();
 }
开发者ID:auamarto,项目名称:crud-bundle,代码行数:8,代码来源:DataProvider.php

示例8: getClassName

 /**
  * @return string
  */
 public function getClassName()
 {
     return parent::getClassName();
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:7,代码来源:EntityTermRepository.php

示例9: __construct

 public function __construct(EntityRepository $repository)
 {
     $this->repository = $repository;
     $this->entity = $repository->getClassName();
 }
开发者ID:neiron486k,项目名称:s2auth,代码行数:5,代码来源:UserProvider.php

示例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());
 }
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:11,代码来源:BaseHandler.php

示例11: getClassName

 /**
  * Returns the class name of the object managed by the repository.
  *
  * @return string
  */
 public function getClassName()
 {
     return $this->repository->getClassName();
 }
开发者ID:illuminate3,项目名称:laravel-doctrine-tenancy,代码行数:9,代码来源:TenantAwareRepository.php

示例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;
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:54,代码来源:Tree.php

示例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);
 }
开发者ID:WellCommerce,项目名称:LocaleBundle,代码行数:18,代码来源:DeleteLocaleCommand.php

示例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);
 }
开发者ID:contao-community-alliance,项目名称:usage-statistic-server,代码行数:8,代码来源:StatisticGenerator.php


注:本文中的Doctrine\ORM\EntityRepository::getClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。