本文整理汇总了PHP中Router::getParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getParam方法的具体用法?PHP Router::getParam怎么用?PHP Router::getParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::getParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterFind
public function afterFind($results, $primary = false)
{
if (!in_array(Router::getParam('action'), ['editar'])) {
$results = $this->formatDateFields($results, $this->datesToLoad, "%d/%m/%Y %H:%M");
}
return $results;
}
示例2: afterFind
public function afterFind($results, $primary = false)
{
parent::afterFind($results, $primary);
if (Router::getParam('action') !== 'editar') {
return $this->formatDateFields($results, $this->datesToLoad, "%a - %d/%m/%Y %H:%M");
}
}
示例3: beforeFind
/**
* Adiciona sempre a condição excluído = false para todas as consultas
* (non-PHPdoc)
* @see Model::beforeFind()
*/
public function beforeFind($queryData)
{
if (Router::getParam('controller') != 'autenticacao' && $this->name != "Conta" && $this->name != "Pessoa") {
$queryData["conditions"][$this->name . ".conta_id = "] = CakeSession::read("Auth.Indicadores.Conta.id");
}
$queryData["conditions"][$this->name . ".status != "] = 0;
return $queryData;
}
示例4: checkAuthorization
public final function checkAuthorization($user)
{
$controller = Inflector::camelize(Router::getParam());
if (is_callable(array($this, 'check' . $controller . 'Authorization'))) {
return $this->{'check' . $controller . 'Authorization'}($user);
} else {
return false;
}
}
示例5: beforeValidate
/**
* Called during validation operations, before validation. Please note that custom
* validation rules can be defined in $validate.
*
* @param array $options Options passed from Model::save().
*
* @return boolean True if validate operation should continue, false to abort
* @see Model::save()
*/
public function beforeValidate($options = [])
{
parent::beforeValidate($options);
if (Router::getParam('action') == 'admin_profile') {
if ($this->data['User']['password'] == "" && $this->data['User']['confirm_password'] == "") {
unset($this->data['User']['password']);
unset($this->data['User']['confirm_password']);
}
}
}
示例6: beforeSave
function beforeSave($data)
{
/* caso a ação seja adicionar, aplica a criptografia a senha */
if (Router::getParam('action') == 'adicionar') {
if (!empty($this->data['Usuario']['senha'])) {
$this->data['Usuario']['senha'] = AuthComponent::password($this->data['Usuario']['senha']);
}
}
return true;
}
示例7: getListAccountOfCurrentUser
/**
* [getListAccountOfCurrentUser description]
* @return [type] [description]
*/
public function getListAccountOfCurrentUser()
{
$prefix = Router::getParam('prefix', true);
if ($prefix === 'advisor') {
$conditions = array('BankAccount.advisor_id' => AuthComponent::user('id'));
} else {
$conditions = array('BankAccount.user_id' => AuthComponent::user('id'));
}
return $this->find('all', array('recursive' => -1, 'conditions' => $conditions));
}
示例8: beforeFilter
public function beforeFilter()
{
parent::beforeFilter();
if (Router::getParam('prefix', true) == 'api') {
$this->Auth->allow('api_getTweets');
}
if ($this->Auth->user() != NULL) {
$this->Auth->allow();
$this->layout = "default_admin";
}
}
示例9: __construct
public function __construct($request = null, $response = null)
{
$page_title = Router::getParam('plugin');
if (empty($page_title)) {
$page_title = Router::getParam('controller');
}
$this->set('page_title', __(Inflector::humanize($page_title)));
$this->set('meta_title', Configure::read('App.default_meta_title_prefix') . __(Inflector::humanize(Router::getParam('controller'))) . Configure::read('App.default_meta_title_surfix'));
$this->set('meta_keywords', Configure::read('App.default_meta_keywords'));
$this->set('meta_description', Configure::read('App.default_meta_description'));
$this->set('plugin', Router::getParam('plugin'));
$this->set('controller', Router::getParam('controller'));
$this->set('action', Router::getParam('action'));
return parent::__construct($request, $response);
}
示例10: afterFind
public function afterFind($results, $primary = false)
{
array_walk($results, function (&$item) {
if (isset($item[$this->alias])) {
$item[$this->alias]['evento'] = html_entity_decode($item[$this->alias]['evento'], ENT_QUOTES, 'UTF-8');
}
});
if (in_array(Router::getParam('action'), ['cadastrar', 'index'])) {
return $this->formatDateFields($results, $this->datesToLoad, "%a - %d/%m/%Y %H:%M");
}
if (Router::getParam('action') === 'exportar') {
return $this->formatDateFields($results, $this->datesToLoad, "%d/%m/%Y %H:%M:%S");
}
return $results;
}
示例11: __construct
/**
* Constructor method
*
* @param [type] $route [description]
* @param [type] $module [description]
* @param [type] $adapter [description]
* @param [type] $method [description]
* @param [type] $requestMethod [description]
* @param [type] $regEx [description]
*/
public final function __construct($route, $module, $adapter, $method, $requestMethod, $regEx = [])
{
$this->route = $route;
$this->module = $module;
$this->adapter = $adapter;
$this->method = $method;
$this->parts = Router::getURLParts($route);
$this->requestMethods = $requestMethod;
$this->requestMethod = $_SERVER['REQUEST_METHOD'];
$this->params = [];
foreach ($this->parts as $part) {
if (Router::isParam($part)) {
$param = Router::getParam($part);
$this->regEx[$param] = isset($regEx[$param]) ? $regEx[$param] : NULL;
}
}
}
示例12: validates
function validates($options = array())
{
// copy the data over from a custom var, otherwise
$actionSet = 'validate' . Inflector::camelize(Router::getParam('action'));
if (isset($this->validationSet)) {
$temp = $this->validate;
$param = 'validate' . $validationSet;
$this->validate = $this->{$param};
} elseif (isset($this->{$actionSet})) {
$temp = $this->validate;
$param = $actionSet;
$this->validate = $this->{$param};
}
$errors = $this->invalidFields($options);
// copy it back
if (isset($temp)) {
$this->validate = $temp;
unset($this->validationSet);
}
if (is_array($errors)) {
return count($errors) === 0;
}
return $errors;
}
示例13: testGetParams
/**
* testGetParams
*
* @return void
*/
public function testGetParams()
{
$paths = array('base' => '/', 'here' => '/products/display/5', 'webroot' => '/webroot');
$params = array('param1' => '1', 'param2' => '2');
Router::setRequestInfo(array($params, $paths));
$expected = array('plugin' => null, 'controller' => false, 'action' => false, 'param1' => '1', 'param2' => '2');
$this->assertEquals(Router::getParams(), $expected);
$this->assertEquals(Router::getParam('controller'), false);
$this->assertEquals(Router::getParam('param1'), '1');
$this->assertEquals(Router::getParam('param2'), '2');
Router::reload();
$params = array('controller' => 'pages', 'action' => 'display');
Router::setRequestInfo(array($params, $paths));
$expected = array('plugin' => null, 'controller' => 'pages', 'action' => 'display');
$this->assertEquals(Router::getParams(), $expected);
$this->assertEquals(Router::getParams(true), $expected);
}
示例14: allowAuth
/**
* Allow authorization
*
* @param null|array|string $methods
*
* @return bool
*/
public static function allowAuth($methods = null)
{
if (is_null($methods)) {
return true;
}
$methods = array($methods);
if (is_array($methods)) {
if (in_array(Router::getParam("action"), $methods)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例15: handshake
/**
* Handshake, define relationship between chat resource_id and web authentication_id
*
*/
public function handshake()
{
$prefix = 'USER';
if (Router::getParam('prefix', true) == 'advisor') {
$prefix = 'ADVISOR';
} else {
if (Router::getParam('prefix', true) == 'admin') {
$prefix = 'ADMIN';
}
}
$authId = $prefix . '-' . AuthComponent::user('id');
$success = $this->ChatResource->handshake($authId, $this->controller->request->data('resource_id'));
if ($success) {
return array('type' => 'handshake', 'resource_id' => $this->controller->request->data('resource_id'), 'auth_id' => $authId);
}
return array();
}