Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-13502

controller resolver should handle callable functions and objects

    Details

    • Type: Improvement
    • Status: Unverified Fix (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.0-dev
    • Fix Version/s: 3.2.0-RC1
    • Component/s: None
    • Labels:
      None

      Description

      Implementing Symfony kernel's kernel.controller allows client to change the controller as needed.

      If the method calls

      $event->setController(function() use ($e) {
                 return new Response($e->getMessage());
      });
      

      Then an error is generated because \phpbb\controller\resolver::getArguments expects controller to be an array rather than any callable, which is functionality that Symfony supports.

      The following code fixes this issue:

      public function getArguments(Request $request, $controller)
      	{
      		// At this point, $controller should be a callable
      		if (is_array($controller))
      		{
      			list($object, $method) = $controller;
      			$mirror = new \ReflectionMethod($object, $method);
      		} else if (is_object($controller) && !$controller instanceof \Closure)
      		{
      			$mirror = new \ReflectionObject($controller);
      			$mirror = $mirror->getMethod('__invoke');
      		} else {
      			$mirror = new \ReflectionFunction($controller);
      		}
      

        Attachments

          Activity

            People

            • Assignee:
              Marc Marc
              Reporter:
              rfdy rfdy [X] (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: