本文整理汇总了PHP中Doctrine\ORM\EntityManagerInterface::getFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::getFilters方法的具体用法?PHP EntityManagerInterface::getFilters怎么用?PHP EntityManagerInterface::getFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getFilters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
/**
* That nested case will be corrected and fully supported
* {% softdeleteable %}
* <span>
* {% softdeleteable 'Acme\Bundle\CoreBundle\Entity\Foo' %}
* {% softdeleteable %}
* {% softdeleteable 'Acme\Bundle\CoreBundle\Entity\Bar' %}
* {{ object.owner.fullName }}
* {% endsoftdeleteable %}
* {% endsoftdeleteable %}
* {% endsoftdeleteable %}
* </span>
* {% endsoftdeleteable %}
* @param null $class
* @return bool
*/
public function enable($class = null)
{
if (!$this->entityManager->getFilters()->isEnabled('softdeleteable')) {
if ($class !== null) {
// Nested tags case.
// {% softdeleteable 'FQCN' %} inside {% softdeleteable %}
// So, just pop classes stack
$this->classStack->pop();
} else {
// When we enable globally we need to restore disabled entities
$this->entityManager->getFilters()->enable('softdeleteable');
// Populate from stack of disabled entities
/** @var SoftDeleteableFilter $filter */
$filter = $this->entityManager->getFilters()->getFilter('softdeleteable');
foreach ($this->classStack as $class) {
$filter->disableForEntity($class);
}
}
} else {
if ($class !== null) {
/** @var SoftDeleteableFilter $filter */
$filter = $this->entityManager->getFilters()->getFilter('softdeleteable');
$filter->enableForEntity($class);
$this->classStack->pop();
}
}
}
示例2: onKernelRequest
/**
* Enables tenantable filter on kernel.request.
*/
public function onKernelRequest()
{
$tenant = $this->tenantContext->getTenant();
if ($tenant && $tenant->getId()) {
$this->entityManager->getFilters()->enable('tenantable')->setParameter('tenantCode', $tenant->getCode());
}
}
示例3: isUsedCode
/**
* @param string $token
*
* @return Boolean
*/
protected function isUsedCode($token)
{
$this->manager->getFilters()->disable('softdeleteable');
$isUsed = null !== $this->repository->findOneBy(array('confirmationToken' => $token));
$this->manager->getFilters()->enable('softdeleteable');
return $isUsed;
}
示例4: generateUniqueToken
/**
* {@inheritDoc}
*/
public function generateUniqueToken()
{
$this->manager->getFilters()->disable('softdeleteable');
do {
$token = $this->generator->generate($this->tokenLength);
} while ($this->isUsedCode($token));
$this->manager->getFilters()->enable('softdeleteable');
return $token;
}
示例5: generateUniqueCode
/**
* {@inheritdoc}
*/
public function generateUniqueCode()
{
$this->manager->getFilters()->disable('softdeleteable');
do {
$hash = sha1(microtime(true));
$code = strtoupper(substr($hash, mt_rand(0, 33), 6));
} while ($this->isUsedCode($code));
$this->manager->getFilters()->enable('softdeleteable');
return $code;
}
示例6: bootExtension
/**
* @param Extension $extension
*/
public function bootExtension(Extension $extension)
{
$extension->addSubscribers($this->evm, $this->em, $this->reader);
if (is_array($extension->getFilters())) {
foreach ($extension->getFilters() as $name => $filter) {
$this->metadata->addFilter($name, $filter);
$this->em->getFilters()->enable($name);
}
}
}
示例7: getSource
/**
* {@inheritdoc}
*/
public function getSource()
{
$this->entityManager->getFilters()->disable('archivable');
$source = new Entity('CSBillInvoiceBundle:Invoice');
/** @var InvoiceRepository $repo */
$repo = $this->entityManager->getRepository('CSBillInvoiceBundle:Invoice');
$queryBuilder = $repo->createQueryBuilder('i');
$queryBuilder->where('i.archived is not null');
$source->initQueryBuilder($queryBuilder);
return $source;
}
示例8: getSource
/**
* {@inheritdoc}
*/
public function getSource()
{
$this->objectManager->getFilters()->disable('softdeleteable');
$source = new Entity('CSBillClientBundle:Client');
/** @var ClientRepository $repo */
$repo = $this->objectManager->getRepository('CSBillClientBundle:Client');
$queryBuilder = $repo->createQueryBuilder('c');
$queryBuilder->where('c.deletedAt is not null');
$source->initQueryBuilder($queryBuilder);
return $source;
}
示例9: setParameter
/**
* Sets a parameter that can be used by the filter.
*
* @param string $name Name of the parameter.
* @param string $value Value of the parameter.
* @param string|null $type The parameter type. If specified, the given value will be run through
* the type conversion of this type. This is usually not needed for
* strings and numeric types.
*
* @return SQLFilter The current SQL filter.
*/
public final function setParameter($name, $value, $type = null)
{
if (null === $type) {
$type = ParameterTypeInferer::inferType($value);
}
$this->parameters[$name] = array('value' => $value, 'type' => $type);
// Keep the parameters sorted for the hash
ksort($this->parameters);
// The filter collection of the EM is now dirty
$this->em->getFilters()->setFiltersStateDirty();
return $this;
}
示例10: setDraftVersionFilter
/**
* Kills the DraftVersionFilter
*/
public function setDraftVersionFilter($enabled = true)
{
if ($this->em->getFilters()->isEnabled('draft') && !$enabled) {
$this->em->getFilters()->disable('draft');
} else {
if (!$this->em->getFilters()->isEnabled('draft') && $enabled) {
$this->em->getFilters()->enable('draft');
}
}
}
示例11: bootExtension
/**
* @param Extension $extension
*/
public function bootExtension(Extension $extension)
{
$hash = spl_object_hash($this->em);
if (isset($this->subscribedExtensions[$hash][get_class($extension)])) {
//This extension is already subscribed to this entity manager.
return;
}
$extension->addSubscribers($this->evm, $this->em, $this->reader);
if (is_array($extension->getFilters())) {
foreach ($extension->getFilters() as $name => $filter) {
$this->metadata->addFilter($name, $filter);
$this->em->getFilters()->enable($name);
}
}
$this->subscribedExtensions[$hash][get_class($extension)] = true;
}
示例12: generateFilterConditionSQL
/**
* Generates the filter SQL for a given entity and table alias.
*
* @param ClassMetadata $targetEntity Metadata of the target entity.
* @param string $targetTableAlias The table alias of the joined/selected table.
*
* @return string The SQL query part to add to a query.
*/
protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
{
$filterClauses = array();
foreach ($this->em->getFilters()->getEnabledFilters() as $filter) {
if ('' !== ($filterExpr = $filter->addFilterConstraint($targetEntity, $targetTableAlias))) {
$filterClauses[] = '(' . $filterExpr . ')';
}
}
$sql = implode(' AND ', $filterClauses);
return $sql ? "(" . $sql . ")" : "";
// Wrap again to avoid "X or Y and FilterConditionSQL"
}
示例13: registerFilters
/**
* @param array $settings
* @param Configuration $configuration
* @param EntityManagerInterface $manager
*/
protected function registerFilters(array $settings = [], Configuration $configuration, EntityManagerInterface $manager)
{
if (isset($settings['filters'])) {
foreach ($settings['filters'] as $name => $filter) {
$configuration->addFilter($name, $filter);
$manager->getFilters()->enable($name);
}
}
}
示例14: getFilters
/**
* {@inheritdoc}
*/
public function getFilters()
{
return $this->wrapped->getFilters();
}
示例15: enableFilter
/**
* @param string $filterName
*/
public function enableFilter($filterName)
{
$this->entityManager->getFilters()->enable($filterName);
}