本文整理汇总了PHP中Doctrine\ORM\EntityRepository::matching方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::matching方法的具体用法?PHP EntityRepository::matching怎么用?PHP EntityRepository::matching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::matching方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
public function count(array $criteria)
{
$criteriaObj = new Criteria();
foreach ($criteria as $field => $value) {
$criteriaObj->where($criteriaObj->expr()->eq($field, $value));
}
return $this->repository->matching($criteriaObj)->count();
}
示例2: matching
/**
* Select all elements from a selectable that match the expression and
* return a new collection containing these elements.
*
* @param Criteria $criteria
* @return \Doctrine\Common\Collections\Collection
* @throws \LogicException
*/
public function matching(Criteria $criteria)
{
if (!$this->baseRepository instanceof Selectable) {
throw new \LogicException('The base repository does not implement Selectable.');
}
return $this->baseRepository->matching($criteria);
}
示例3: getAllAsArray
/**
*
* @return array
*/
public function getAllAsArray(Organisation $organisation = null)
{
$list = array();
if ($organisation) {
$criteria = Criteria::create()->where(Criteria::expr()->eq('organisation', $organisation));
$list = parent::matching($criteria);
} else {
$list = parent::findAll();
}
$res = array();
foreach ($list as $element) {
$res[$element->getId()] = $element->getName();
}
return $res;
}
示例4: getAllAsArray
/**
*
* @return array
*/
public function getAllAsArray($criteria = null)
{
$list = array();
if ($criteria === null) {
$list = parent::findAll();
} else {
if ($criteria instanceof Criteria) {
$list = parent::matching($criteria);
} else {
$list = parent::findBy($criteria);
}
}
$res = array();
foreach ($list as $element) {
$res[$element->getId()] = $element->getName();
}
return $res;
}
示例5: findTranslatableEntities
protected function findTranslatableEntities(EntityRepository $repository, LocaleInterface $locale) : Collection
{
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('locale', $locale->getCode()));
$collection = $repository->matching($criteria);
return $collection;
}
示例6: totalNumberOfFilteredRecords
/**
* @param Criteria $criteria
* @return int
*/
public function totalNumberOfFilteredRecords(Criteria $criteria)
{
return parent::matching($criteria)->count();
}
示例7: matching
/** {@inheritdoc} @override */
public function matching(Criteria $criteria)
{
if (null !== ($config = $this->getConfig()) && $config->get('multitenant.enabled')) {
$criteria->andWhere($criteria->expr()->eq($config->get('multitenant.keymap'), $config->get('app.key')));
}
return parent::matching($criteria);
}
示例8: 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);
}