src/mako/onion/Onion.php
protected function middlewareFactory(string $middleware, array $parameters): object
	{
		// Merge middleware parameters

		$parameters = $this->mergeParameters($parameters, $middleware);

		// Create middleware instance

		$middleware = $this->container->get($middleware, $parameters);

		// Check if the middleware implements the expected interface

		if($this->expectedInterface !== null && ($middleware instanceof $this->expectedInterface) === false)
		{
			throw new OnionException(vsprintf('The Onion instance expects the middleware to be an instance of [ %s ].', [$this->expectedInterface]));
		}

		// Return middleware instance

		return $middleware;
	}
protected function middlewareFactory(string $middleware, array $parameters): object
	{
		// Merge middleware parameters

		$parameters = $this->mergeParameters($parameters, $middleware);

		// Create middleware instance

		$middleware = $this->container->get($middleware, $parameters);

		// Check if the middleware implements the expected interface

		if($this->expectedInterface !== null && ($middleware instanceof $this->expectedInterface) === false)
		{
			throw new OnionException(vsprintf('The Onion instance expects the middleware to be an instance of [ %s ].', [$this->expectedInterface]));
		}

		// Return middleware instance

		return $middleware;
	}
protected function middlewareFactory ( string $ middleware , array $ parameters ) : object { // Merge middleware parameters $ parameters = $ this -> mergeParameters ( $ parameters , $ middleware ) ; // Create middleware instance $ middleware = $ this -> container -> get ( $ middleware , $ parameters ) ; // Check if the middleware implements the expected interface if ( $ this -> expectedInterface !== null && ( $ middleware instanceof $ this -> expectedInterface ) === false ) { throw new OnionException ( vsprintf ( 'The Onion instance expects the middleware to be an instance of [ %s ].' , [ $ this -> expectedInterface ] ) ) ; } // Return middleware instance return $ middleware ; }
Middleware factory.

@param  string                     $middleware Middleware class name
@param  array                      $parameters Middleware parameters
@throws \mako\onion\OnionException
@return object
Middleware factory .