本文整理汇总了PHP中Zend\Mvc\Router\RouteMatch::setParam方法的典型用法代码示例。如果您正苦于以下问题:PHP RouteMatch::setParam方法的具体用法?PHP RouteMatch::setParam怎么用?PHP RouteMatch::setParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\RouteMatch
的用法示例。
在下文中一共展示了RouteMatch::setParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNoRolesAllowed
public function testNoRolesAllowed()
{
$this->routeMatch->setParam('action', 'noRoles');
$listener = new Authorized();
$listener->onDispach($this->event);
$this->assertNull($this->event->getParam('exception'));
}
示例2: 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]));
}
}
}
示例3: testResizeActionFileNotFound
public function testResizeActionFileNotFound()
{
$this->routeMatch->setParam('action', 'resize');
$this->routeMatch->setParam('file', 'img/test/fileNotFound');
$this->routeMatch->setParam('extension', 'jpg');
$this->routeMatch->setParam('command', 'thumb,80,40');
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
$this->assertEquals(404, $response->getStatusCode());
}
示例4: 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');
}
}
示例5: setUp
protected function setUp()
{
$serviceManagerGrabber = new ServiceManagerGrabber();
$this->serviceManager = $serviceManagerGrabber->getServiceManager();
$this->serviceManager->setAllowOverride(true);
$this->serviceManager->setService('doctrine.entitymanager.orm_default', $this->getEntityManagerMock());
$config = $this->serviceManager->get('Config');
$this->request = new PhpEnviromentRequest();
$this->router = HttpRouter::factory(isset($config['router']) ? $config['router'] : array());
$this->routeMatch = new RouteMatch(array('controller' => 'index'));
$this->routeMatch->setParam('lang', 'it');
$this->event = new MvcEvent();
$this->event->setRouter($this->router);
$this->event->setRouteMatch($this->routeMatch);
}
示例6: testCanSearchProjects
/**
* @covers \Project\Controller\ProjectController::searchAction
*/
public function testCanSearchProjects()
{
$this->routeMatch->setParam('action', 'search');
$queryParams = new Parameters(['search_item' => 'test', 'max_rows' => 12]);
$this->request->setQuery($queryParams);
$this->controller->dispatch($this->request, $this->response);
$this->assertEquals(200, $this->controller->getResponse()->getStatusCode());
}
示例7: testUpdateWrongIdeaDescriptionGives404
/**
* @covers \Project\Controller\IdeaController::updateDescriptionAction
*/
public function testUpdateWrongIdeaDescriptionGives404()
{
$this->routeMatch->setParam('action', 'update-description');
$queryParams = new Parameters(['id' => 'description-0', 'value' => 'This is the new description']);
$this->request->setPost($queryParams);
$this->controller->dispatch($this->request, $this->response);
$this->assertEquals(404, $this->controller->getResponse()->getStatusCode());
}
示例8: testDeleteCategory
/**
* @depends testGetCategory
* @param int $id
*/
public function testDeleteCategory($id)
{
$this->getRequest()->setMethod(Request::METHOD_DELETE);
$this->routeMatch->setParam('id', $id);
$jsonModel = $this->dispatchRequest();
$this->assertEquals(200, $this->controller->getResponse()->getStatusCode());
$this->assertEquals('success', $jsonModel->getVariable('message')['type']);
}
示例9: testDeleteListing
/**
* @depends testGetListing
*
* @param int $id
*/
public function testDeleteListing($id)
{
$this->getRequest()->setMethod(Request::METHOD_POST);
$this->routeMatch->setParam('action', 'deleteAjax');
$this->getRequest()->getPost()->fromArray(['ids' => $id]);
$jsonModel = $this->dispatchRequest();
$this->assertEquals(200, $this->controller->getResponse()->getStatusCode());
$this->assertEquals('success', $jsonModel->getVariable('message')['type']);
}
示例10: testIsActiveReturnsFalseWhenMatchingRouteButNonMatchingParams
public function testIsActiveReturnsFalseWhenMatchingRouteButNonMatchingParams()
{
$page = new Page\Mvc(array('label' => 'foo', 'route' => 'bar', 'action' => 'baz'));
$routeMatch = new RouteMatch(array());
$routeMatch->setMatchedRouteName('bar');
$routeMatch->setParam('action', 'qux');
$page->setRouteMatch($routeMatch);
$this->assertFalse($page->isActive());
}
示例11: testCanAllowAccess
public function testCanAllowAccess()
{
$eventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface');
$eventManager->expects($this->never())->method('trigger');
$application = $this->getMock('Zend\\Mvc\\Application', array(), array(), '', false);
$application->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
$routeMatch = new RouteMatch(array());
$routeMatch->setParam("controller", "index");
$routeMatch->setParam("action", "update");
$event = new MvcEvent();
$event->setRouteMatch($routeMatch);
$event->setApplication($application);
$controllerGuardMock = $this->getMockBuilder('UghAuthorization\\Guards\\Guard', array('isGranted'))->disableOriginalConstructor()->getMock();
$controllerGuardMock->expects($this->any())->method('isGranted')->will($this->returnValue(true));
$controllerGuardListener = new ControllerGuardListener($controllerGuardMock);
$controllerGuardListener->onGuard($event);
$this->assertFalse($event->propagationIsStopped());
$this->assertEmpty($event->getError());
}
示例12: testListActionWithFilledConfiguration
public function testListActionWithFilledConfiguration()
{
$this->markTestIncomplete();
$configuration = array('name_to_configuration_path' => array('locator_one' => __FILE__, 'locator_two' => __FILE__));
$console = $this->console;
$console->shouldReceive('writeLine')->with('locator: locator_one with configuration file "' . __FILE__ . '"')->once();
$console->shouldReceive('writeLine')->with('locator: locator_two with configuration file "' . __FILE__ . '"')->once();
$this->controller->setConfiguration($configuration);
$this->routeMatch->setParam('action', 'list');
$this->controller->dispatch($this->request);
}
示例13: onDispatchError
public function onDispatchError(MvcEvent $e)
{
if ($e->getError() !== Zf2Application::ERROR_ROUTER_NO_MATCH) {
return;
}
$routeMatch = new RouteMatch(array());
$routeMatch->setParam('controller', 'Zf1Module\\DispatchController');
$e->setError(null);
$e->setRouteMatch($routeMatch);
return $routeMatch;
}
示例14: testPageCheckControllerGetMethodWithExistingPage
/**
* Test Page Check Controller with Existing Page
*
* @return void
*
* @covers \Rcm\Controller\PageCheckController
*/
public function testPageCheckControllerGetMethodWithExistingPage()
{
$this->mockPageValidator->expects($this->any())->method('isValid')->will($this->returnValue(false));
$this->mockPageValidator->expects($this->any())->method('getMessages')->will($this->returnValue(["pageExists" => 'Page Exists']));
$this->routeMatch->setParam('pageId', 'page-exists');
/** @var \Zend\View\Model\JsonModel $result */
$result = $this->controller->dispatch($this->request);
$this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $result);
$response = $this->controller->getResponse();
$this->assertEquals(409, $response->getStatusCode());
$result = $result->getVariables();
$expected = ['valid' => false, 'error' => ['pageExists' => 'Page Exists']];
$this->assertEquals($expected, $result);
}
示例15: 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);
}
}
}