本文整理汇总了PHP中Zend\Mvc\Router\RouteMatch::getParam方法的典型用法代码示例。如果您正苦于以下问题:PHP RouteMatch::getParam方法的具体用法?PHP RouteMatch::getParam怎么用?PHP RouteMatch::getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\RouteMatch
的用法示例。
在下文中一共展示了RouteMatch::getParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVersionFromRouteMatch
/**
* Retrieve the version from the route match.
*
* The route prototype sets "version", while the Content-Type listener sets
* "zf_ver_version"; check both to obtain the version, giving priority to the
* route prototype result.
*
* @param RouteMatch $routeMatches
* @return int|false
*/
protected function getVersionFromRouteMatch(RouteMatch $routeMatches)
{
$version = $routeMatches->getParam('zf_ver_version', false);
if ($version) {
return $version;
}
return $routeMatches->getParam('version', false);
}
示例2: getResponse
public function getResponse()
{
$response = $this->siteAccess->dispatch($this->routeMatch->getParam('path'))->getResponse();
// Calc total run time
$this->getServiceLocator()->get('accumulator')->start('Total', SCRIPT_START);
$this->getServiceLocator()->get('accumulator')->stop('Total');
$this->getServiceLocator()->get('accumulator')->memory_usage('Before sending response');
$this->addDebugOutput($response);
return $response;
}
示例3: getAllowedRoles
protected function getAllowedRoles(RouteMatch $routeMatch)
{
$controller = strtolower($routeMatch->getParam('controller'));
$action = strtolower($routeMatch->getParam('action'));
$restAction = strtolower($routeMatch->getParam('restAction'));
$rolesByAction = @$this->rules[$controller] ?: [];
$roles = @$rolesByAction[$action] ?: @$rolesByAction[$restAction];
$roles = $roles ?: @$rolesByAction['*'];
return $roles;
}
示例4: resolveController
public static function resolveController(RouteMatch $routeMatch)
{
if (($extension = $routeMatch->getParam('extension')) && ($manifestName = $routeMatch->getParam('manifestName'))) {
if ($endpoint = $routeMatch->getParam('endpoint')) {
$routeMatch->setParam('controller', implode('.', [$extension, $manifestName, $endpoint]));
} else {
$routeMatch->setParam('controller', implode('.', [$extension, $manifestName]));
}
}
}
示例5: injectRouteMatches
/**
* Inject regex matches into the route matches
*
* @param RouteMatch $routeMatches
*/
protected function injectRouteMatches(RouteMatch $routeMatches, $matches)
{
if (!class_exists('\\ZF\\Apigility\\Admin\\Module', false)) {
$vendor = $matches['zf_ver_vendor'];
$version = $matches['zf_ver_version'];
$controllerTest = $vendor . '\\V' . $version;
if (strpos($routeMatches->getParam('controller'), $controllerTest) !== 0) {
$controllerParts = explode('\\', $routeMatches->getParam('controller'));
$controllerParts[0] = $vendor;
$controllerParts[1] = 'V' . $version;
$controller = implode('\\', $controllerParts);
$routeMatches->setParam('controller', $controller);
}
}
}
示例6: prepareSubResource
/**
* Prepares the REST Request object with values appropriate for a sub-resource request.
*
* @param \BedRest\Rest\Request\Request $restRequest
* @param \Zend\Http\Request $httpRequest
* @param \Zend\Mvc\Router\RouteMatch $routeMatch
*/
protected function prepareSubResource(RestRequest $restRequest, HttpRequest $httpRequest, RouteMatch $routeMatch)
{
$id = $routeMatch->getParam('id', null);
$restRequest->setParameter('identifier', $id);
$resourceName = $routeMatch->getParam('__CONTROLLER__');
$subResourceName = $routeMatch->getParam('subresource', null);
$restRequest->setResource($resourceName . '/' . $subResourceName);
$subId = $routeMatch->getParam('subresource_id', null);
if (!empty($subId)) {
$restRequest->setParameter('subresource_identifier', $subId);
}
$method = strtoupper($httpRequest->getMethod());
if (!empty($method)) {
if (empty($subId) && $method !== RestRequestType::METHOD_POST) {
$method .= '_COLLECTION';
}
$restRequest->setMethod(constant('BedRest\\Rest\\Request\\Type::METHOD_' . $method));
}
}
示例7: resolveController
public static function resolveController(RouteMatch $routeMatch)
{
if ($routeMatch->getMatchedRouteName() != 'rest') {
return;
}
if ($endpoint = $routeMatch->getParam('endpoint')) {
$routeMatch->setParam('controller', 'shard.rest.' . $endpoint);
} else {
$routeMatch->setParam('controller', 'shard.rest');
}
}
示例8: setRouteVariables
protected function setRouteVariables(RouteMatch $routeMatch)
{
$controller = $routeMatch->getParam('controller');
$controller = strtolower(substr($controller, strrpos($controller, '\\') + 1));
$action = $routeMatch->getParam('action');
$route = $routeMatch->getMatchedRouteName();
$setArray = ['route' => $route, 'controller' => $controller, 'action' => $action];
$alias = $routeMatch->getParam('alias');
if ($alias) {
$setArray['alias'] = $alias;
}
$id = $routeMatch->getParam('id');
if ($id) {
$setArray['id'] = $id;
}
$page = $routeMatch->getParam('page');
if ($page) {
$setArray['page'] = $page;
}
return $setArray;
}
示例9: getModelResource
/**
* Create the modelResource that will be used in ACL checks
* @param \Zend\Mvc\Router\RouteMatch $routeMatch
* @param Request $request
* @param type $resourceString
* @return \Application\Authorization\ModelResource
*/
private function getModelResource(\Zend\Mvc\Router\RouteMatch $routeMatch, Request $request, $resourceString)
{
$controller = $routeMatch->getParam('controller', false);
$identifierName = $this->restControllers[$controller];
$id = $this->getIdentifier($identifierName, $routeMatch, $request);
$model = $this->config['zf-rest'][$controller]['entity_class'];
// If we are trying to create a new relation object, then we need to get ACL
// from the pre-existing objects in DB, so we adapt a few things
if (array_key_exists($resourceString, $this->mapping)) {
$mapping = $this->mapping[$resourceString];
$model = $mapping['model'];
$id = $this->getId($request, $mapping['id']);
}
return new ModelResource($resourceString, $model, $id);
}
示例10: staticGetParam
/**
* Mimics zf1 Request::getParam behavior
*
* Route match -> GET -> POST
*/
public static function staticGetParam(RouteMatch $routeMatch, Request $request, $param = null, $default = null)
{
if ($param === null) {
$params = (array) $routeMatch->getParams();
if ($request instanceof ConsoleRequest) {
return $params + (array) $request->getParams();
}
return $params + $request->getQuery()->toArray() + $request->getPost()->toArray();
}
if ($request instanceof ConsoleRequest) {
$default = $request->getParam($param, $default);
} else {
$default = $request->getQuery($param, $request->getPost($param, $default));
}
return $routeMatch->getParam($param, $default);
}
示例11: checkParams
/**
* Check if we should cache the request based on the params in the routematch
*
* @param RouteMatch $match
* @param array $routeConfig
* @return bool
*/
protected function checkParams(RouteMatch $match, $routeConfig)
{
if (!isset($routeConfig['params'])) {
return true;
}
$params = (array) $routeConfig['params'];
foreach ($params as $name => $value) {
$param = $match->getParam($name, null);
if (null === $param) {
continue;
}
if (!$this->checkParam($param, $value)) {
return false;
}
}
return true;
}
示例12: getIdentifier
/**
* Retrieve the identifier, if any
*
* Attempts to see if an identifier was passed in either the URI or the
* query string, returning if if found. Otherwise, returns a boolean false.
*
* @param \Zend\Mvc\Router\RouteMatch $routeMatch
* @param Request $request
* @return false|mixed
*/
protected function getIdentifier($routeMatch, $request)
{
$id = $routeMatch->getParam('id', false);
if ($id) {
return $id;
}
$id = $request->getQuery()->get('id', false);
if ($id) {
return $id;
}
return false;
}
示例13: forgetSavedDestinationWhenNotAuthenticating
/**
* this is a weird one
*
* i noticed a use case during testing where if an unauthenticated user attempts
* to navigate to a protected route and the destination is saved,
* they could click on anything else an avoid the authentication process
* and since the saved destination information is never consumed, it persists
* and if that user does authenitcate later, it will send them to that
* initial route whether they had requested it or not
*
* this removes that saved information as soon as the user selects a route that does
* not have the same controller that is used to
* @param RouteMatch $routeMatch
*/
private function forgetSavedDestinationWhenNotAuthenticating(RouteMatch $routeMatch)
{
/*
* run dependency check
*/
$this->checkDependencies();
$routeForwardingContainer = $this->routeForwardingContainer;
$controller = $routeMatch->getParam('controller');
if ($controller != self::UNAUTHENTICATED_CONTROLLER) {
$routeForwardingContainer->offsetUnset(self::ROUTE_FORWARDING_SESSION_KEY);
}
}
示例14: getIdentifier
protected function getIdentifier(RouteMatch $routeMatch, RequestInterface $request)
{
$identifier = $this->getIdentifierName();
$id = $routeMatch->getParam($identifier, false);
if ($id !== false) {
return $id;
}
if ($request instanceof Request) {
$id = $request->getQuery()->get($identifier, false);
if ($id !== false) {
return $id;
}
}
return false;
}
示例15: getKey
/**
* @param RouteMatch $routeMatch
* @return string
*/
public static function getKey(RouteMatch $routeMatch)
{
return $routeMatch->getParam('controller') . self::KEY_SEPARATOR . $routeMatch->getParam('action');
}