StalkerClasses
Новичок
В различных примерах идет получение _GET параметров через
"$name = $this->dispatcher->getParam("name");"
:
В других так - _GET-параметры передаются непосредственно в саму функцию:
public function shopsAction(Town $town = null, Department $department = null, $page = 1)
В каких случаях какой подход лучше использовать?
"$name = $this->dispatcher->getParam("name");"
:
Код:
<?php
$router->add(
"/documentation/{chapter}/{name}.{type:[a-z]+}",
array(
"controller" => "documentation",
"action" => "show"
)
);
<?php
use Phalcon\Mvc\Controller;
class DocumentationController extends Controller
{
public function showAction()
{
// Returns "name" parameter
$name = $this->dispatcher->getParam("name");
// Returns "type" parameter
$type = $this->dispatcher->getParam("type");
}
}
public function shopsAction(Town $town = null, Department $department = null, $page = 1)
Код:
/**
* @Route("/shops/{page}", name="shops")
* @Route("/shops/town/{town}/{page}", name="shops_town")
* @Route("/shops/department/{department}/{page}", name="shops_department")
*/
public function shopsAction(Town $town = null, Department $department = null, $page = 1)
{ ... }
Последнее редактирование: