@@ -95,8 +95,8 @@ public function __construct(
9595 ?LoggerInterface $ logger = null ,
9696 $ translator = null ,
9797 ?ContainerInterface $ templateRegistries = null ,
98- ? AuthorizationCheckerInterface $ securityChecker = null ,
99- ?PropertyAccessorInterface $ propertyAccessor = null
98+ $ propertyAccessorOrSecurityChecker = null ,
99+ ?AuthorizationCheckerInterface $ securityChecker = null
100100 ) {
101101 // NEXT_MAJOR: make the translator parameter required, move TranslatorInterface check to method signature
102102 // and remove this block
@@ -125,23 +125,51 @@ public function __construct(
125125 }
126126
127127 // NEXT_MAJOR: Remove this block.
128- if (null === $ propertyAccessor ) {
128+ if (!$ propertyAccessorOrSecurityChecker instanceof PropertyAccessorInterface
129+ && !$ propertyAccessorOrSecurityChecker instanceof AuthorizationCheckerInterface
130+ && null !== $ propertyAccessorOrSecurityChecker
131+ ) {
132+ throw new \TypeError (sprintf (
133+ 'Argument 5 must be an instance of "%s" or "%s" or null, "%s given" ' ,
134+ PropertyAccessorInterface::class,
135+ AuthorizationCheckerInterface::class,
136+ \is_object ($ propertyAccessorOrSecurityChecker ) ? \get_class ($ propertyAccessorOrSecurityChecker ) : \gettype ($ propertyAccessorOrSecurityChecker )
137+ ));
138+ }
139+
140+ // NEXT_MAJOR: Remove this block and extract the else part outside.
141+ if ($ propertyAccessorOrSecurityChecker instanceof AuthorizationCheckerInterface) {
142+ @trigger_error (sprintf (
143+ 'Passing an instance of "%s" the argument 5 for "%s()" is deprecated since sonata-project/admin-bundle '
144+ .' 3.x and will throw a \TypeError in version 4.0. You MUST pass an instance of "%s" instead and pass '
145+ .' the instance of "%s" as 6 argument. ' ,
146+ AuthorizationCheckerInterface::class,
147+ __METHOD__ ,
148+ PropertyAccessorInterface::class,
149+ AuthorizationCheckerInterface::class
150+ ), E_USER_DEPRECATED );
151+
152+ $ this ->securityChecker = $ propertyAccessorOrSecurityChecker ;
153+ $ this ->propertyAccessor = $ pool ->getPropertyAccessor ();
154+ } elseif (null === $ propertyAccessorOrSecurityChecker ) {
129155 @trigger_error (sprintf (
130- 'Omitting the argument 6 for "%s()" or passing "null" is deprecated since sonata-project/admin-bundle '
156+ 'Omitting the argument 5 for "%s()" or passing "null" is deprecated since sonata-project/admin-bundle '
131157 .' 3.x and will throw a \TypeError in version 4.0. You must pass an instance of %s instead. ' ,
132158 __METHOD__ ,
133159 PropertyAccessorInterface::class
134160 ), E_USER_DEPRECATED );
135161
136- $ propertyAccessor = $ pool ->getPropertyAccessor ();
162+ $ this ->propertyAccessor = $ pool ->getPropertyAccessor ();
163+ $ this ->securityChecker = $ securityChecker ;
164+ } else {
165+ $ this ->securityChecker = $ securityChecker ;
166+ $ this ->propertyAccessor = $ propertyAccessorOrSecurityChecker ;
137167 }
138168
139169 $ this ->pool = $ pool ;
140170 $ this ->logger = $ logger ;
141171 $ this ->translator = $ translator ;
142172 $ this ->templateRegistries = $ templateRegistries ;
143- $ this ->securityChecker = $ securityChecker ;
144- $ this ->propertyAccessor = $ propertyAccessor ;
145173 }
146174
147175 /**
0 commit comments