-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatatableBundle.php
More file actions
51 lines (45 loc) · 2.15 KB
/
Copy pathDatatableBundle.php
File metadata and controls
51 lines (45 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace Jul6Art\DatatableBundle;
use Jul6Art\DatatableBundle\DependencyInjection\Compiler\DatatableExportPass;
use Jul6Art\DatatableBundle\DependencyInjection\Compiler\PreferenceControllerPass;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Symfony datatable bundle.
*
* Registering a compiler pass? Override `build()` here — a pass is how you check that a service
* the application may or may not have actually exists, which an extension cannot do (extensions
* run before the other bundles have had their say):
*
* ```php
* #[\Override]
* public function build(ContainerBuilder $container): void
* {
* parent::build($container);
*
* $container->addCompilerPass(new SomethingOptionalPass());
* }
* ```
*/
class DatatableBundle extends Bundle
{
#[\Override]
public function build(ContainerBuilder $container): void
{
parent::build($container);
// ⚠️ La priorité n'est pas décorative. `RegisterControllerArgumentLocatorsPass` de
// FrameworkBundle tourne dans la même phase et, à priorité égale, avant celui-ci puisque
// son bundle est enregistré en premier : il aurait déjà construit le locator d'arguments
// du contrôleur, et le retirer ensuite fait échouer la compilation sur un service
// « inexistant » que plus personne ne réclame explicitement. La leçon est celle
// d'`AppearanceControllerPass` dans `admin-bundle`, payée une fois.
$container->addCompilerPass(new PreferenceControllerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100);
// ⚠️ `DatatableViewExporter` has no controller of its own for `RegisterControllerArgumentLocatorsPass`
// to have already captured — a consumer's own controller calls it — so the priority-100
// hazard the note above documents does not apply here. Same type, default priority: nothing
// else needs to see this service before it is potentially removed.
$container->addCompilerPass(new DatatableExportPass());
}
}