@param string $action
@param array $params

@return string
975798
public function toRoute($action, $params=[])
    {
        $params = (array)$params;
        $url = URL::route($this->routePrefix . '.' . $action, $params);

        if ($passThruParams = $this->getPassThruParams()) {
            $url .= '?' . http_build_query($passThruParams);
        }

        return $url;

    }
239043
public function amOnAction($action, $params = [])
    {
        $route = $this->getRouteByAction($action);
        $absolute = !is_null($route->domain());
        $url = $this->app['url']->action($action, $params, $absolute);

        $this->amOnPage($url);
    }
744264
public function perPage(string $action = null): string
    {
        return $this->htmlRenderer->perPage($this->request, $action);
    }
321006
public function invokeAction($action, $params = [])
    {

        //var_dump($this->request->getAttributes());

        //Will throw an exception if the method does not exists;
        $method = new ReflectionMethod($this, $action);

        if (!$method->isPublic()) {
            throw new Exception('Attempting to call a private method');
        }

        return $method->invokeArgs($this, $params);

    }
695820
protected function getTemplateFile(string $action = null) : string
    {
        $path = '/controller/' . lcfirst($this->getControllerName()) . '/';

        return $path . ($action ? $action : $this->getActionName());
    }
882853
protected function template($action, $params = null) {
		
		if(false === is_string($action)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($action)), E_USER_ERROR);
		}
		
		if(null !== $params && false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		$functions = TemplateData :: getTemplateFunctions();

		if(false === isset($functions[$action])) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be a valid callable template function, "%s" given', __METHOD__, $action), E_USER_ERROR);
		}

		return call_user_func_array($functions[$action], $params);
	}
909887
private function buildOobLink($param, $action) {
    $code = $this->rpcHelper->getOobCode($param);
    $separator = parse_url($this->widgetUrl, PHP_URL_QUERY) ? '&' : '?';
    return $this->widgetUrl . $separator  .
        http_build_query(array('mode' => $action, 'oobCode' => $code));
  }
221536
protected function soapCall($action, $parameters = null)
    {
        // deep black magic
        $stfu = error_reporting();
        error_reporting(0);
        $response = $this->soap->$action($parameters);
        error_reporting($stfu);
        $response = \Metaclassing\Utility::encodeJson($response);
        $response = \Metaclassing\Utility::decodeJson($response);
        $this->log[] = [
                        'request' => [
                                    'action'     => $action,
                                    'parameters' => $parameters,
                                    //'xml' => \Metaclassing\Utility::xmlPrettyPrint($this->soap->__getLastRequest()),
                                    ],
                        'response' => [
                                    'response' => $response,
                                    //'xml' => \Metaclassing\Utility::xmlPrettyPrint( $this->soap->__getLastResponse() ),
                                    ],
                        ];

        return $response;
    }
696452
protected function resolve($action, $params)
    {
        if ($action instanceof Closure) {

            return $action($params);
        }

        list($controller, $method) = $action;

        $reflect = new ReflectionClass($controller);

        foreach (array_filter($reflect->getMethod($method)->getParameters(), $this->getParams()) as $param) {
            array_unshift($params, $this->registry->make(
                $param->getClass()->getName()
            ));
        }

        return $reflect->getMethod($method)->invokeArgs(
            $this->registry->make($controller),
            $params
        );
    }
949650
public function webform($action, $params, $friends = array()) {
        $url = self::WEBFORM_URL . $action;
 
        $header = sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthenticationString()));
        $header .= "Content-type: application/x-www-form-urlencoded\r\n";
        $params = http_build_query($params);

        // If we have any friends present:
        if (!empty($friends)) {
            // Loop through them.
            foreach ($friends as $friend) {
                // Add each one to the query string.
                $params .= '&friends[]=' . $friend;                
            }
        }

        $opts = array(
            'http' => array(
                'method'  => 'POST',
                'header'  => $header,
                'content' => $params,
            )
        );
 
        $context = stream_context_create($opts);
        return file_get_contents($url, false, $context);
    }
455342
public function requestApi($action = '', $params = array(), $method = 'POST')
    {
        $curlOpts = array(
            CURLOPT_URL => $this->_apiUrl . $action,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_USERAGENT => 'Paymill-php/0.0.2',
            CURLOPT_SSL_VERIFYPEER => true
        );

        // Add extra options to cURL if defined.
        if (!empty($this->_extraOptions)) {
            $curlOpts = $this->_extraOptions + $curlOpts;
        }

        if ('GET' === $method || 'DELETE' === $method) {
            if (0 !== count($params)) {
                $curlOpts[CURLOPT_URL] .= false === strpos($curlOpts[CURLOPT_URL], '?') ? '?' : '&';
                $curlOpts[CURLOPT_URL] .= http_build_query($params, null, '&');
            }
        } else {
            $curlOpts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
        }

        if ($this->_apiKey) {
            $curlOpts[CURLOPT_USERPWD] = $this->_apiKey . ':';
        }
        $curl = curl_init();
        $this->_curlOpts($curl, $curlOpts);
        $responseBody = $this->_curlExec($curl);
        $responseInfo = $this->_curlInfo($curl);

        if ($responseBody === false) {
            $responseBody = array('error' => $this->_curlError($curl));
        }
        curl_close($curl);

        if ('application/json' === $responseInfo['content_type']) {
            $responseBody = json_decode($responseBody, true);
        } elseif (strpos(strtolower($responseInfo['content_type']), 'text/csv') !== false
            && !isset($responseBody['error'])
        ) {
            return $responseBody;
        }

        $result = array(
            'header' => array(
                'status' => $responseInfo['http_code'],
                'reason' => null,
            ),
            'body' => $responseBody
        );

        return $result;
    }
263213
protected function parseAction($action)
    {
        // Remove namespace
        $parts         = explode('\\', $action['uses']);
        $ctrlAndAction = end($parts);

        // Split controller and action
        $parts      = explode('@', $ctrlAndAction);
        $controller = $parts[0];
        $action     = end($parts);
        $resource   = strtolower(str_replace('Controller', '', $controller));

        return [
            'action'          => $action,
            'resource'        => $resource
        ];
    }
988833
private function _action($params)
    {
        // Shift and get the method
        $method = array_shift($params);

        // Behavior
        if ($this->behaviors[$method]) {
            $this->behaviors[$method]();
        }

        if (!isset($this->routes[$method])) {
            $this->_defaultAction();
        }

        // Get corresponding method name
        $method = $this->routes[$method];

        if (!method_exists($this, $method)) {
            $this->_defaultAction();
        }

        return call_user_func_array([$this, $method], $params);
    }
491559
protected function action($action)
    {
        $action = in_array($action, $this->actions) ? $action : null;
        $action = array_key_exists($action, $this->aliases) ? $this->aliases[$action] : $action;

        return $action;
    }
120488
public static function dispatch($action, array $parameters = [])
    {
        if (isset(static::$listeners[$action])) {
            foreach (static::$listeners[$action] as $callback) {
                $response = call_user_func_array($callback, $parameters);

                if ($response !== null) {
                    return $response;
                }
            }
        }
    }
127810
public function soap(string $service, string $action, array $params = [])
    {
        switch ($service) {
            case "AVTransport":
            case "RenderingControl":
                $path = "MediaRenderer";
                break;
            case "ContentDirectory":
                $path = "MediaServer";
                break;
            case "AlarmClock":
            case "DeviceProperties":
            case "ZoneGroupTopology":
                $path = null;
                break;
            default:
                throw new \InvalidArgumentException("Unknown service: {$service}");
        }

        $location = "http://{$this->ip}:1400/";
        if (is_string($path)) {
            $location .= "{$path}/";
        }
        $location .= "{$service}/Control";

        $this->logger->info("sending soap request to: {$location}", $params);

        $soap = new \SoapClient(null, [
            "location"  =>  $location,
            "uri"       =>  "urn:schemas-upnp-org:service:{$service}:1",
            "trace"     =>  true,
        ]);

        $soapParams = [];
        $params["InstanceID"] = 0;
        foreach ($params as $key => $val) {
            $soapParams[] = new \SoapParam(new \SoapVar($val, \XSD_STRING), $key);
        }

        try {
            $result = $soap->__soapCall($action, $soapParams);
            $this->logger->debug("REQUEST: " . $soap->__getLastRequest());
            $this->logger->debug("RESPONSE: " . $soap->__getLastResponse());
        } catch (\SoapFault $e) {
            $this->logger->debug("REQUEST: " . $soap->__getLastRequest());
            $this->logger->debug("RESPONSE: " . $soap->__getLastResponse());
            throw new SoapException($e, $soap);
        }

        return $result;
    }
358815
public function generateUrl(AdminInterface $admin, $action, $params = [])
    {
        $routeName = $this->getRouteName($admin, $action);

        return $this->router->generate($routeName, $params);
    }