Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix symfony 4.4 deprecation notice #163

Merged
merged 3 commits into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Adapter/Doctrine/FetchJoinORMAdapter.php
Expand Up @@ -16,14 +16,14 @@
use Doctrine\ORM\Tools\Pagination\Paginator;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
use Omines\DataTablesBundle\Adapter\Doctrine\Event\ORMAdapterQueryEvent;
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapterEvents;
use Omines\DataTablesBundle\Column\AbstractColumn;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Similar to ORMAdapter this class allows to access objects from the doctrine ORM.
* Unlike the default ORMAdapter supports Fetch Joins (additional entites are fetched from DB via joins) using
* the Doctrine Paginator.
*
* @author Jan Böhmer
*/
class FetchJoinORMAdapter extends ORMAdapter
Expand All @@ -43,7 +43,7 @@ protected function configureOptions(OptionsResolver $resolver)
//Enforce object hydration mode (fetch join only works for objects)
$resolver->addAllowedValues('hydrate', Query::HYDRATE_OBJECT);

/**
/*
* Add the possibility to replace the query for total entity count through a very simple one, to improve performance.
* You can only use this option, if you did not apply any criteria to your total count.
*/
Expand Down Expand Up @@ -120,6 +120,7 @@ public function getResults(AdapterQuery $query): \Traversable
public function getCount(QueryBuilder $queryBuilder, $identifier)
{
$paginator = new Paginator($queryBuilder);

return $paginator->count();
}

Expand All @@ -130,6 +131,7 @@ protected function getSimpleTotalCount(QueryBuilder $queryBuilder)
*/
/** @var Query\Expr\From $from_expr */
$from_expr = $queryBuilder->getDQLPart('from')[0];

return $this->manager->getRepository($from_expr->getFrom())->count([]);
}
}
}
6 changes: 5 additions & 1 deletion src/Adapter/Doctrine/ORMAdapter.php
Expand Up @@ -12,10 +12,10 @@

namespace Omines\DataTablesBundle\Adapter\Doctrine;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Omines\DataTablesBundle\Adapter\AbstractAdapter;
use Omines\DataTablesBundle\Adapter\AdapterQuery;
use Omines\DataTablesBundle\Adapter\Doctrine\Event\ORMAdapterQueryEvent;
Expand Down Expand Up @@ -222,6 +222,7 @@ protected function createQueryBuilder(DataTableState $state): QueryBuilder

/**
* @param $identifier
*
* @return int
*/
protected function getCount(QueryBuilder $queryBuilder, $identifier)
Expand All @@ -245,6 +246,7 @@ protected function getCount(QueryBuilder $queryBuilder, $identifier)
/**
* @param $identifier
* @param Query\Expr\GroupBy[] $gbList
*
* @return bool
*/
protected function hasGroupByPart($identifier, array $gbList)
Expand All @@ -260,6 +262,7 @@ protected function hasGroupByPart($identifier, array $gbList)

/**
* @param string $field
*
* @return string
*/
protected function mapFieldToPropertyPath($field, array $aliases = [])
Expand Down Expand Up @@ -315,6 +318,7 @@ protected function configureOptions(OptionsResolver $resolver)

/**
* @param callable|QueryBuilderProcessorInterface $provider
*
* @return QueryBuilderProcessorInterface
*/
private function normalizeProcessor($provider)
Expand Down