1 | <?php |
||
29 | class AuditBlockService extends AbstractBlockService |
||
30 | { |
||
31 | /** |
||
32 | * @var AuditReader |
||
33 | */ |
||
34 | protected $auditReader; |
||
35 | |||
36 | /** |
||
37 | * NEXT_MAJOR: Allow only Environment|EngineInterface for argument 1 and AuditReader for argument 2. |
||
38 | * |
||
39 | * @param Environment|EngineInterface|string $templatingOrDeprecatedName |
||
40 | * @param EngineInterface|AuditReader $templatingOrAuditReader |
||
41 | */ |
||
42 | public function __construct($templatingOrDeprecatedName, object $templatingOrAuditReader, ?AuditReader $auditReader = null) |
||
43 | { |
||
44 | if ($templatingOrAuditReader instanceof EngineInterface) { |
||
45 | @trigger_error(sprintf( |
||
|
|||
46 | 'Passing %s as argument 2 to %s() is deprecated since sonata-project/doctrine-orm-admin-bundle 3.x' |
||
47 | .' and will throw a \TypeError in version 4.0. You must pass an instance of %s instead.', |
||
48 | EngineInterface::class, |
||
49 | __METHOD__, |
||
50 | AuditReader::class |
||
51 | ), E_USER_DEPRECATED); |
||
52 | |||
53 | if (null === $auditReader) { |
||
54 | throw new \TypeError(sprintf( |
||
55 | 'Passing null as argument 3 to %s() is not allowed when %s is passed as argument 2.' |
||
56 | .' You must pass an instance of %s instead.', |
||
57 | __METHOD__, |
||
58 | EngineInterface::class, |
||
59 | AuditReader::class |
||
60 | )); |
||
61 | } |
||
62 | |||
63 | parent::__construct($templatingOrDeprecatedName, $templatingOrAuditReader); |
||
64 | |||
65 | $this->auditReader = $auditReader; |
||
66 | } elseif ($templatingOrAuditReader instanceof AuditReader) { |
||
67 | if (!$templatingOrDeprecatedName instanceof Environment |
||
68 | && !$templatingOrDeprecatedName instanceof EngineInterface |
||
69 | ) { |
||
70 | throw new \TypeError(sprintf( |
||
71 | 'Argument 1 passed to %s() must be either an instance of %s or preferably %s, %s given.', |
||
72 | __METHOD__, |
||
73 | EngineInterface::class, |
||
74 | Environment::class, |
||
75 | \is_object($templatingOrDeprecatedName) ? \get_class($templatingOrDeprecatedName) : \gettype($templatingOrDeprecatedName) |
||
76 | )); |
||
77 | } |
||
78 | |||
79 | parent::__construct($templatingOrDeprecatedName); |
||
80 | |||
81 | $this->auditReader = $templatingOrAuditReader; |
||
82 | } else { |
||
83 | throw new \TypeError(sprintf( |
||
84 | 'Argument 2 passed to %s() must be either an instance of %s or preferably %s, %s given.', |
||
85 | __METHOD__, |
||
86 | EngineInterface::class, |
||
87 | AuditReader::class, |
||
88 | \get_class($templatingOrAuditReader) |
||
89 | )); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | public function execute(BlockContextInterface $blockContext, ?Response $response = null) |
||
110 | |||
111 | public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void |
||
114 | |||
115 | public function getName() |
||
119 | |||
120 | public function configureSettings(OptionsResolver $resolver): void |
||
127 | } |
||
128 |
If you suppress an error, we recommend checking for the error condition explicitly: