本文整理汇总了PHP中Psr\Http\Message\RequestInterface::getParams方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getParams方法的具体用法?PHP RequestInterface::getParams怎么用?PHP RequestInterface::getParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::getParams方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param RequestInterface $request A PSR-7 compatible Request instance.
* @param ResponseInterface $response A PSR-7 compatible Response instance.
* @return ResponseInterface
*/
public function run(RequestInterface $request, ResponseInterface $response)
{
$params = $request->getParams();
$this->setData($params);
$obj = $this->obj();
$revNum = $params['rev_num'];
$ret = $obj->revertToRevision($revNum);
if ($ret) {
$this->setSuccess(true);
$this->addFeedback('success', 'Object was succesfully reverted to revision.');
return $response;
} else {
$this->setSuccess(false);
$this->addFeedback('error', 'Could not revert to revision');
return $response->withStatus(404);
}
}
示例2: run
/**
* @param RequestInterface $request A PSR-7 compatible Request instance.
* @param ResponseInterface $response A PSR-7 compatible Response instance.
* @return ResponseInterface
*/
public function run(RequestInterface $request, ResponseInterface $response)
{
try {
$this->setData($request->getParams());
// Create or load object (From `ObjectContainerTrait`)
$obj = $this->obj();
$saveData = $this->saveData();
$obj->setFlatData($this->saveData());
$valid = $obj->validate();
if (!$valid) {
$this->setSuccess(false);
$this->addFeedbackFromValidation($obj);
if (!$this->hasFeedbacks()) {
$this->addFeedback('error', 'Failed to create object: validation error(s).');
}
return $response->withStatus(404);
}
$authorIdent = $this->authorIdent();
if (!$obj->lastModifiedBy()) {
$obj->setLastModifiedBy($authorIdent);
}
if (!$obj->createdBy()) {
$obj->setCreatedBy($authorIdent);
}
$ret = $obj->save();
if ($ret) {
$this->setObj($obj);
$this->setSuccess(true);
$this->addFeedback('success', 'Object was successfully created');
$this->addFeedbackFromValidation($obj, ModelValidator::NOTICE);
return $response;
} else {
$this->setObj(null);
$this->setSuccess(false);
$this->addFeedback('error', 'Could not create objet. Unknown error');
$this->addFeedbackFromValidation($obj);
return $response->withStatus(404);
}
} catch (Exception $e) {
$this->setObj(null);
$this->setSuccess(false);
$this->addFeedback('error', $e->getMessage());
return $response->withStatus(404);
}
}
示例3: run
/**
* @param RequestInterface $request A PSR-7 compatible Request instance.
* @param ResponseInterface $response A PSR-7 compatible Response instance.
* @return ResponseInterface
*/
public function run(RequestInterface $request, ResponseInterface $response)
{
$params = $request->getParams();
if (!isset($params['obj_type'])) {
$this->setSuccess(false);
return $response->withStatus(404);
}
// Does this do anything?
$this->setMode('csv');
$exporter = new Exporter(['logger' => $this->logger, 'factory' => $this->modelFactory(), 'obj_type' => $params['obj_type'], 'propertyFactory' => $this->propertyFactory]);
if (isset($params['ident'])) {
$exporter->setExportIdent($params['ident']);
}
$exporter->process();
// Kind of always true unless there are no keywords defined.
$this->setSuccess(true);
return $response;
}
示例4: init
/**
* Retrieve options from Request's parameters (GET).
*
* @param RequestInterface $request The PSR7 request.
* @return boolean
*/
public function init(RequestInterface $request)
{
$params = $request->getParams();
if (isset($params['obj_type'])) {
$this->objType = filter_var($params['obj_type'], FILTER_SANITIZE_STRING);
}
if (isset($params['obj_id'])) {
$this->objId = filter_var($params['obj_id'], FILTER_SANITIZE_STRING);
}
if (isset($params['property'])) {
$this->propertyIdent = filter_var($params['property'], FILTER_SANITIZE_STRING);
}
if (isset($params['assets'])) {
$this->showAssets = !!$params['assets'];
}
if (isset($params['callback'])) {
$this->callbackIdent = filter_var($params['callback'], FILTER_SANITIZE_STRING);
}
if (isset($this->elfinderConfig['translations'])) {
$this->setLocalizations(array_replace_recursive($this->defaultLocalizations(), $this->elfinderConfig['translations']));
}
return true;
}
示例5: init
/**
* Template's init method is called automatically from `charcoal-app`'s Template Route.
*
* For admin templates, initializations is:
*
* - to start a session, if necessary
* - to authenticate
* - to initialize the template data with `$_GET`
*
* @param RequestInterface $request The request to initialize.
* @return boolean
* @see \Charcoal\App\Route\TemplateRoute::__invoke()
*/
public function init(RequestInterface $request)
{
if (!session_id()) {
session_cache_limiter(false);
session_start();
}
if ($this->authRequired() !== false) {
// This can reset headers / die if unauthorized.
if (!$this->authenticator()->authenticate()) {
header('HTTP/1.0 403 Forbidden');
exit;
}
// Initialize data with GET / POST parameters.
$this->setData($request->getParams());
// Test template vs. ACL roles
$authUser = $this->authenticator()->authenticate();
if (!$this->authorizer()->userAllowed($authUser, $this->requiredAclPermissions())) {
header('HTTP/1.0 403 Forbidden');
exit;
}
} else {
// Initialize data with GET / POST parameters.
$this->setData($request->getParams());
}
return parent::init($request);
}