mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge branch 'master' into calendar/docgen-add-generation
This commit is contained in:
@@ -14,6 +14,8 @@ namespace Chill\DocGeneratorBundle\Controller;
|
||||
use Chill\DocGeneratorBundle\Context\ContextManager;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@@ -84,4 +86,16 @@ class AdminDocGeneratorTemplateController extends CRUDController
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $query
|
||||
*
|
||||
* @return QueryBuilder|mixed
|
||||
*/
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
return $query->addSelect('JSON_EXTRACT(e.name, :lang) AS HIDDEN name_lang')
|
||||
->setParameter('lang', $request->getLocale())
|
||||
->addOrderBy('name_lang', 'ASC');
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,18 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
final class DocGeneratorTemplateRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
private RequestStack $requestStack;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, RequestStack $requestStack)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(DocGeneratorTemplate::class);
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
public function countByEntity(string $entity): int
|
||||
@@ -71,7 +75,10 @@ final class DocGeneratorTemplateRepository implements ObjectRepository
|
||||
$builder
|
||||
->where('t.entity LIKE :entity')
|
||||
->andWhere($builder->expr()->eq('t.active', "'TRUE'"))
|
||||
->setParameter('entity', addslashes($entity));
|
||||
->setParameter('entity', addslashes($entity))
|
||||
->addSelect('JSON_EXTRACT(t.name, :lang) AS HIDDEN name_lang')
|
||||
->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale())
|
||||
->addOrderBy('name_lang', 'ASC');
|
||||
|
||||
return $builder
|
||||
->getQuery()
|
||||
|
@@ -2,6 +2,14 @@
|
||||
|
||||
{% block title 'docgen.Generate a document'|trans %}
|
||||
|
||||
{% block js %}
|
||||
{{ encore_entry_script_tags('mod_pickentity_type') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_pickentity_type') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-md-10 col-xxl">
|
||||
<h1>{{ block('title') }}</h1>
|
||||
|
@@ -77,6 +77,19 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
}
|
||||
|
||||
public function testNormalizableBooleanPropertyOrMethodOnNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]);
|
||||
|
||||
$expected = [
|
||||
'foo' => null,
|
||||
'thing' => null,
|
||||
'isNull' => true,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizationBasic()
|
||||
{
|
||||
$scope = new Scope();
|
||||
@@ -93,6 +106,22 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $normalized, 'test normalization fo a scope');
|
||||
}
|
||||
|
||||
public function testNormalizeBooleanPropertyOrMethod()
|
||||
{
|
||||
$testable = new TestableClassWithBool();
|
||||
$testable->foo = false;
|
||||
|
||||
$actual = $this->normalizer->normalize($testable, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]);
|
||||
|
||||
$expected = [
|
||||
'foo' => false,
|
||||
'thing' => true,
|
||||
'isNull' => false,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizeNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => Scope::class]);
|
||||
@@ -170,3 +199,19 @@ class TestableChildClass
|
||||
*/
|
||||
public string $foo = 'bar';
|
||||
}
|
||||
|
||||
class TestableClassWithBool
|
||||
{
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
*/
|
||||
public bool $foo;
|
||||
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
*/
|
||||
public function getThing(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user