1313use Api \App \Exception \UnauthorizedException ;
1414use Dot \Mail \Exception \MailException ;
1515use Exception ;
16- use Fig \Http \Message \RequestMethodInterface ;
1716use Fig \Http \Message \StatusCodeInterface ;
18- use Mezzio \Hal \Metadata \MetadataMap ;
19- use Mezzio \Hal \Metadata \RouteBasedCollectionMetadata ;
2017use Mezzio \Hal \ResourceGenerator \Exception \OutOfBoundsException ;
21- use Mezzio \Router \RouteResult ;
2218use Psr \Http \Message \ResponseInterface ;
2319use Psr \Http \Message \ServerRequestInterface ;
2420use RuntimeException ;
2521
26- use function array_key_exists ;
27- use function assert ;
28- use function is_array ;
2922use function method_exists ;
3023use function sprintf ;
3124use function strtolower ;
@@ -41,10 +34,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
4134 {
4235 try {
4336 $ method = strtolower ($ request ->getMethod ());
44- if ($ this ->isGetCollectionRequest ($ request , $ this ->config )) {
45- $ method = 'getCollection ' ;
46- }
47-
4837 if (! method_exists ($ this , $ method )) {
4938 throw new MethodNotAllowedException (
5039 sprintf ('Method %s is not implemented for the requested resource. ' , $ method )
@@ -70,37 +59,4 @@ public function handle(ServerRequestInterface $request): ResponseInterface
7059 return $ this ->errorResponse ($ exception ->getMessage ());
7160 }
7261 }
73-
74- /**
75- * @throws RuntimeException
76- */
77- private function isGetCollectionRequest (ServerRequestInterface $ request , array $ config ): bool
78- {
79- if ($ request ->getMethod () !== RequestMethodInterface::METHOD_GET ) {
80- return false ;
81- }
82-
83- if (! array_key_exists (MetadataMap::class, $ config )) {
84- throw new RuntimeException (
85- sprintf ('Unable to load %s from config. ' , MetadataMap::class)
86- );
87- }
88-
89- $ routeResult = $ request ->getAttribute (RouteResult::class);
90- assert ($ routeResult instanceof RouteResult);
91-
92- $ routeName = $ routeResult ->getMatchedRouteName ();
93-
94- $ halConfig = null ;
95- foreach ($ config [MetadataMap::class] as $ cfg ) {
96- if ($ cfg ['route ' ] === $ routeName ) {
97- $ halConfig = $ cfg ;
98- break ;
99- }
100- }
101-
102- return is_array ($ halConfig )
103- && array_key_exists ('__class__ ' , $ halConfig )
104- && $ halConfig ['__class__ ' ] === RouteBasedCollectionMetadata::class;
105- }
10662}
0 commit comments