本文整理汇总了PHP中Slim\Http\Request::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::get方法的具体用法?PHP Request::get怎么用?PHP Request::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Http\Request
的用法示例。
在下文中一共展示了Request::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($name)
{
$value = $this->request->get($name);
if ($value === null) {
$value = $this->request->post($name);
}
if ($value === null) {
$value = @$this->defaultValues[$name];
}
return $value;
}
示例2: unpack
/**
* @throws \RuntimeException
*/
public function unpack()
{
// Manual updates do not contain files to overwrite
if (UPDATE_IS_MANUAL) {
Utils::clearOpcodeCache();
$this->toJson(200, $this->resultMapper->toExtJs(new FinishResult(0, 0)));
return;
}
$offset = $this->request->get('offset');
$total = $this->request->get('total');
/** @var FilesystemFactory $factory */
$factory = $this->container->get('filesystem.factory');
$localFilesystem = $factory->createLocalFilesystem();
$remoteFilesystem = $factory->createRemoteFilesystem();
if ($offset == 0) {
$this->validateFilesytems($localFilesystem, $remoteFilesystem);
}
/** @var PathBuilder $pathBuilder */
$pathBuilder = $this->container->get('path.builder');
$debug = false;
$step = new UnpackStep($localFilesystem, $remoteFilesystem, $pathBuilder, $debug);
$result = $step->run($offset, $total);
if ($result instanceof ValidResult) {
Utils::clearOpcodeCache();
}
$this->toJson(200, $this->resultMapper->toExtJs($result));
}
示例3: turorialAction
/**
*
*
* @Route /tutorial
*
*
* @param \Slim\Http\Request $request
* @param \Slim\Http\Response $response
* @param \Slim\Route $route
*/
public function turorialAction($request, $response, $route)
{
$interactive = $this->get('InteractiveManager');
$user = 'public';
if ($this->app->getSecurity()->isAuthenticated()) {
$array = $this->app->getSecurity()->getUser();
$user = $array['username'];
}
$store = json_encode(array('reject' => false, 'tutoriales' => array('interactive' => 'This is interactive')));
if ($this->app->getCookie('Interactive_' . $user, true) == NULL) {
$this->app->setCookie('Interactive_' . $user, $store, strtotime('+30 day'));
} else {
$store = json_decode($this->app->getCookie('Interactive_' . $user, true));
$store->tutoriales->{$request->get('name')} = 0;
$this->app->setCookie('Interactive_' . $user, json_encode($store), strtotime('+30 day'));
}
$interactive->setCurrentData($store);
return $this->JSON($interactive->getTutorial($request->get('name')));
}
示例4: __construct
protected function __construct(\Slim\Http\Request $request)
{
$key = $request->headers('apikey');
if ($key == '') {
$key = $request->post('apikey');
}
if ($key == '') {
$key = $request->get('apikey');
}
if ($key == '') {
return;
}
$this->apiKey = $key;
$this->role = $this->getRoleFromKey($this->apiKey);
}
示例5: bundleInstallerModuleAction
/**
*
*
* @Route /bundle/installer/module
*
*
* @param \Slim\Http\Request $request
* @param \Slim\Http\Response $response
* @param \Slim\Route $route
*/
public function bundleInstallerModuleAction($request)
{
$msg = "";
if ($request->get('name') and $request->get('type') == 'local') {
$dir = \Raptor2\InstallerBundle\Importer\BundleImporter::prepareCache();
$meta = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation($request->get('name'));
if ($meta !== false) {
\Raptor\Util\Files::copy(__DIR__ . '/../BundleStorage/files/' . $meta['file'], $dir);
$msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($dir . '/' . $meta['file']);
}
} elseif ($request->get('name') and $request->get('type') == 'remote' and $request->get('url')) {
$file = \Raptor2\InstallerBundle\Importer\BundleImporter::downloadRemoteFile($request->get('url'));
$msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($file);
}
$local = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation();
$conf = $this->getApp()->getConfigurationLoader()->getConfOption();
if (isset($conf['raptor']['repository'])) {
$remote = \Raptor2\InstallerBundle\Importer\BundleImporter::getRemoteMetainformation($conf['raptor']['repository']);
$local = array_merge($local, $remote);
}
return $this->render('@InstallerBundle/installer/index.html.twig', array('modules' => $local, 'message' => $msg));
}
示例6: createFromRequest
/**
* Creates a page object out of a request object
* @param \Slim\Http\Request $request
* @return Page
*/
public static function createFromRequest(\Slim\Http\Request $request)
{
return new Page($request->get('offset'), $request->get('limit', 10));
}
示例7: extractToken
public function extractToken(Request $request)
{
$tokenHeader = $request->headers('Authorization', false);
$rawTokenHeader = $request->rawHeaders('Authorization', false);
if ($tokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $tokenHeader, $matches)) {
$tokenHeader = $matches[1];
} elseif ($rawTokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $rawTokenHeader, $matches)) {
$tokenHeader = $matches[1];
} else {
$tokenHeader = false;
}
$tokenRequest = $request->post('access_token', false);
$tokenQuery = $request->get('access_token', false);
// At least one (and only one) of client credentials method required.
if (!$tokenHeader && !$tokenRequest && !$tokenQuery) {
throw new Exception('The request is missing a required parameter.', Resource::STATUS_BAD_REQUEST);
} elseif ($tokenHeader && $tokenRequest || $tokenRequest && $tokenQuery || $tokenQuery && $tokenHeader) {
throw new Exception('The request includes multiple credentials.', Resource::STATUS_BAD_REQUEST);
}
$accessToken = $tokenHeader ?: $tokenRequest ?: $tokenQuery;
try {
$tokenDocument = $this->fetchToken($accessToken);
} catch (\Exception $e) {
throw new Exception('Access token invalid.');
}
return $tokenDocument;
}
示例8: getSlimView
public function getSlimView(\Slim\Http\Request $request)
{
if ($request->isAjax() || $request->isXhr() || $request->get('format', '') == 'json' || $request->post('format', '') == 'json') {
return $this->slimViewFactory->getJsonSlimView();
}
return $this->slimViewFactory->getHtmlSlimView();
}