本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::get方法的具体用法?PHP Request::get怎么用?PHP Request::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
/**
* Perform an action on a Contenttype record.
*
* The action part of the POST request should take the form:
* [
* contenttype => [
* id => [
* action => [field => value]
* ]
* ]
* ]
*
* For example:
* [
* 'pages' => [
* 3 => ['modify' => ['status' => 'held']],
* 5 => null,
* 4 => ['modify' => ['status' => 'draft']],
* 1 => ['delete' => null],
* 2 => ['modify' => ['status' => 'published']],
* ],
* 'entries' => [
* 4 => ['modify' => ['status' => 'published']],
* 1 => null,
* 5 => ['delete' => null],
* 2 => null,
* 3 => ['modify' => ['title' => 'Drop Bear Attacks']],
* ]
* ]
*
* @param Request $request Symfony Request
*
* @return Response
*/
public function action(Request $request)
{
// if (!$this->checkAntiCSRFToken($request->get('bolt_csrf_token'))) {
// $this->app->abort(Response::HTTP_BAD_REQUEST, Trans::__('Something went wrong'));
// }
$contentType = $request->get('contenttype');
$actionData = $request->get('actions');
if ($actionData === null) {
throw new \UnexpectedValueException('No content action data provided in the request.');
}
foreach ($actionData as $contentTypeSlug => $recordIds) {
if (!$this->getContentType($contentTypeSlug)) {
// sprintf('Attempt to modify invalid ContentType: %s', $contentTypeSlug);
continue;
} else {
$this->app['storage.request.modify']->action($contentTypeSlug, $recordIds);
}
}
$referer = Request::create($request->server->get('HTTP_REFERER'));
$taxonomy = null;
foreach (array_keys($this->getOption('taxonomy', [])) as $taxonomyKey) {
if ($referer->query->get('taxonomy-' . $taxonomyKey)) {
$taxonomy[$taxonomyKey] = $referer->query->get('taxonomy-' . $taxonomyKey);
}
}
$options = (new ListingOptions())->setOrder($referer->query->get('order'))->setPage($referer->query->get('page_' . $contentType))->setFilter($referer->query->get('filter'))->setTaxonomies($taxonomy);
$context = ['contenttype' => $this->getContentType($contentType), 'multiplecontent' => $this->app['storage.request.listing']->action($contentType, $options), 'filter' => array_merge((array) $taxonomy, (array) $options->getFilter()), 'permissions' => $this->getContentTypeUserPermissions($contentType, $this->users()->getCurrentUser())];
return $this->render('@bolt/async/record_list.twig', ['context' => $context]);
}
示例2: updateStockItemsByApiAction
/**
* @Route("/stock/api/variation/update/qty")
* @Method("POST")
*/
public function updateStockItemsByApiAction(Request $request)
{
$response = new Response();
$response->headers->set('Content-Type', 'application/json');
$id = (int) $request->get('id');
$newQty = (int) $request->get('qtyStock');
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('HypersitesStockBundle:ProductVariation')->find($id);
if ($entity === null) {
$response->setStatusCode(204, "The requested variation did not exist");
return $response;
}
$oldQtyStock = $entity->getQtyStock();
if ($oldQtyStock > $newQty) {
$diference = $oldQtyStock - $newQty;
$items = $entity->getItems();
} else {
$diference = $newQty - $oldQtyStock;
for ($interations = 0; $interations < $diference; $interations++) {
$item = new Item();
$item->setProductVariation($entity);
$em->persist($item);
}
}
$entity->setQtyStock($newQty);
$em->persist($entity);
$em->flush();
$response->setContent("New quantity is {$entity->getQtyStock()}");
return $response;
}
示例3: processAction
public function processAction(Request $req, Application $app)
{
$template_data = [];
$code = Response::HTTP_OK;
try {
$page = new Login($app['sentry']);
if ($page->authenticate($req->get('email'), $req->get('password'))) {
// This is for redirecting to OAuth endpoint if we arrived
// as part of the Authorization Code Grant flow.
if ($this->app['session']->has('redirectTo')) {
return new RedirectResponse($this->app['session']->get('redirectTo'));
}
return $this->redirectTo('dashboard');
}
$errorMessage = $page->getAuthenticationMessage();
$template_data = ['email' => $req->get('email')];
$code = Response::HTTP_BAD_REQUEST;
} catch (Exception $e) {
$errorMessage = $e->getMessage();
$template_data = ['email' => $req->get('email')];
$code = Response::HTTP_BAD_REQUEST;
}
// Set Success Flash Message
$this->app['session']->set('flash', ['type' => 'error', 'short' => 'Error', 'ext' => $errorMessage]);
$template_data['flash'] = $this->getFlash($app);
return $this->render('login.twig', $template_data, $code);
}
示例4: indexAction
/**
* @Route("/report", name="report", methods={"GET", "POST"} )
*/
public function indexAction(Request $request)
{
$fromDate = $request->get('fromDate') ?: '1 month ago';
$toDate = $request->get('toDate') ?: 'now';
$parameters = array('timeEntriesGroupedByDate' => $this->getDoctrine()->getRepository('AppBundle:TimeEntry')->getTimeEntriesGroupedByDayForDates($fromDate, $toDate), 'fromDate' => new \DateTime($fromDate), 'toDate' => new \DateTime($toDate));
return $this->render('::report.html.twig', $parameters);
}
示例5: getAction
/**
* Get a single product
*
* @param Request $request
* @param string $identifier
*
* @ApiDoc(
* description="Get a single product",
* resource=true
* )
*
* @return Response
*/
public function getAction(Request $request, $identifier)
{
$userContext = $this->get('pim_user.context.user');
$availableChannels = array_keys($userContext->getChannelChoicesWithUserChannel());
$availableLocales = $userContext->getUserLocaleCodes();
$channels = $request->get('channels', $request->get('channel', null));
if ($channels !== null) {
$channels = explode(',', $channels);
foreach ($channels as $channel) {
if (!in_array($channel, $availableChannels)) {
return new Response(sprintf('Channel "%s" does not exist or is not available', $channel), 403);
}
}
}
$locales = $request->get('locales', $request->get('locale', null));
if ($locales !== null) {
$locales = explode(',', $locales);
foreach ($locales as $locale) {
if (!in_array($locale, $availableLocales)) {
return new Response(sprintf('Locale "%s" does not exist or is not available', $locale), 403);
}
}
}
return $this->handleGetRequest($identifier, $channels, $locales);
}
示例6: indexAction
public function indexAction(Request $request, SessionInterface $session)
{
Util::checkUserIsLoggedInAndRedirect();
$clientId = $session->get('client/id');
$workflowId = $request->get('id');
$stepIdFrom = $request->get('step_id_from');
$stepIdTo = $request->get('step_id_to');
$projectId = $request->get('project_id');
$issueId = $request->get('issue_id');
$assignableUsers = $this->getRepository(YongoProject::class)->getUsersWithPermission($projectId, Permission::PERM_ASSIGNABLE_USER);
$projectData = $this->getRepository(YongoProject::class)->getById($projectId);
$issue = $this->getRepository(Issue::class)->getByIdSimple($issueId);
$workflowData = $this->getRepository(Workflow::class)->getDataByStepIdFromAndStepIdTo($workflowId, $stepIdFrom, $stepIdTo);
$screenId = $workflowData['screen_id'];
$allUsers = $this->getRepository(UbirimiUser::class)->getByClientId($session->get('client/id'));
$screenData = $this->getRepository(Screen::class)->getDataById($screenId);
$screenMetadata = $this->getRepository(Screen::class)->getMetaDataById($screenId);
$resolutions = $this->getRepository(IssueSettings::class)->getAllIssueSettings('resolution', $clientId);
$projectComponents = $this->getRepository(YongoProject::class)->getComponents($projectId);
$projectVersions = $this->getRepository(YongoProject::class)->getVersions($projectId);
$htmlOutput = '';
$htmlOutput .= '<table class="modal-table">';
$reporterUsers = $this->getRepository(YongoProject::class)->getUsersWithPermission($projectId, Permission::PERM_CREATE_ISSUE);
$fieldCodeNULL = null;
$fieldData = $this->getRepository(YongoProject::class)->getFieldInformation($projectData['issue_type_field_configuration_id'], $issue['type_id'], 'array');
return $this->render(__DIR__ . '/../../Resources/views/issue/TransitionDialog.php', get_defined_vars());
}
示例7: storeAction
public function storeAction(NotificationConfiguration $notificationConfiguration, Request $request)
{
$this->assertUserRights(UserRole::ROLE_ADMIN);
$notificationConfiguration->setNotificationCondition($request->get('condition'));
if ($request->get('notify_ack') === "true") {
$notificationConfiguration->setNotifyAcknowledge(true);
} else {
$notificationConfiguration->setNotifyAcknowledge(false);
}
if ($request->get('notify_all') === "true") {
$notificationConfiguration->setNotifyAll(true);
$notificationConfiguration->clearConnectedTools();
} else {
$notificationConfiguration->setNotifyAll(false);
$notificationConfiguration->clearConnectedTools();
$tools = $request->get('tools');
if (!is_null($tools)) {
foreach ($tools as $toolId => $value) {
$tool = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:Tool')->find((int) $toolId);
/** @var Tool $tool */
if ($tool->getProject() == $this->getProject()) {
$notificationConfiguration->addConnectedTool($tool);
}
}
}
}
$em = $this->getDoctrine()->getManager();
$em->persist($notificationConfiguration);
$em->flush();
return $this->redirectToRoute('koalamon_notification_alerts_home');
}
示例8: listAction
/**
* {@inheritdoc}
*/
public function listAction(Request $request = null)
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
if ($listMode = $request->get('_list_mode', 'mosaic')) {
$this->admin->setListMode($listMode);
}
$datagrid = $this->admin->getDatagrid();
$filters = $request->get('filter');
// set the default context
if (!$filters || !array_key_exists('context', $filters)) {
$context = $this->admin->getPersistentParameter('context', $this->get('sonata.media.pool')->getDefaultContext());
} else {
$context = $filters['context']['value'];
}
$datagrid->setValue('context', null, $context);
// retrieve the main category for the tree view
$category = $this->container->get('sonata.classification.manager.category')->getRootCategory($context);
if (!$filters) {
$datagrid->setValue('category', null, $category->getId());
}
if ($request->get('category')) {
$contextInCategory = $this->container->get('sonata.classification.manager.category')->findBy(array('id' => (int) $request->get('category'), 'context' => $context));
if (!empty($contextInCategory)) {
$datagrid->setValue('category', null, $request->get('category'));
} else {
$datagrid->setValue('category', null, $category->getId());
}
}
$formView = $datagrid->getForm()->createView();
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render($this->admin->getTemplate('list'), array('action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'root_category' => $category, 'csrf_token' => $this->getCsrfToken('sonata.batch')));
}
示例9: indexAction
/**
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return array
*/
public function indexAction(Request $request)
{
$idPage = $this->castId($request->get(CmsPageTable::REQUEST_ID_PAGE));
$idForm = (int) $request->get(self::ID_FORM);
$type = CmsConstants::RESOURCE_TYPE_PAGE;
$block = $this->getQueryContainer()->queryBlockByIdPage($idPage)->findOne();
$cmsPageEntity = $this->findCmsPageById($idPage);
$localeTransfer = $this->getLocaleTransfer($cmsPageEntity);
$fkLocale = $this->getLocaleByCmsPage($cmsPageEntity);
if ($block === null) {
$title = $cmsPageEntity->getUrl();
} else {
$type = CmsConstants::RESOURCE_TYPE_BLOCK;
$title = $block->getName();
}
$placeholders = $this->findPagePlaceholders($cmsPageEntity);
$glossaryMappingArray = $this->extractGlossaryMapping($idPage, $localeTransfer);
$forms = [];
$formViews = [];
foreach ($placeholders as $place) {
$form = $this->createPlaceholderForm($request, $glossaryMappingArray, $place, $idPage, $fkLocale);
$forms[] = $form;
$formViews[] = $form->createView();
}
if ($idForm !== null && $request->isXmlHttpRequest()) {
return $this->handleAjaxRequest($forms, $idForm, $localeTransfer);
}
return ['idPage' => $idPage, 'title' => $title, 'type' => $type, 'forms' => $formViews, 'localeTransfer' => $localeTransfer];
}
示例10: getStripeTokenAndAmount
/**
* Get token created by Stripe and order amount from the form & save them in session
*/
public function getStripeTokenAndAmount()
{
// Get Stripe token
$this->request->getSession()->set('stripeToken', $this->request->get('thelia_order_payment')['stripe_token']);
// Get order amount
$this->request->getSession()->set('stripeAmount', $this->request->get('thelia_order_payment')['stripe_amount']);
}
示例11: facility
public function facility(Application $app, Request $request)
{
$ret = ['tasks' => []];
$job = new RecordMoverJob(null, null, $this->translator);
switch ($request->get('ACT')) {
case 'CALCTEST':
$sxml = simplexml_load_string($request->get('xml'));
if (isset($sxml->tasks->task)) {
foreach ($sxml->tasks->task as $sxtask) {
$ret['tasks'][] = $job->calcSQL($app, $sxtask, false);
}
}
break;
case 'PLAYTEST':
$sxml = simplexml_load_string($request->get('xml'));
if (isset($sxml->tasks->task)) {
foreach ($sxml->tasks->task as $sxtask) {
$ret['tasks'][] = $job->calcSQL($app, $sxtask, true);
}
}
break;
case 'CALCSQL':
$sxml = simplexml_load_string($request->get('xml'));
if (isset($sxml->tasks->task)) {
foreach ($sxml->tasks->task as $sxtask) {
$ret['tasks'][] = $job->calcSQL($app, $sxtask, false);
}
}
break;
default:
throw new NotFoundHttpException('Route not found.');
}
return $app->json($ret);
}
示例12: getConfig
/**
* @param Request $request
*
* @return array
* @throws LibratoException
*/
protected function getConfig(Request $request)
{
$name = $request->get('name');
if (empty($name)) {
throw new LibratoException('Empty chart name');
}
$apiUser = $request->get('apiUser');
if (empty($apiUser)) {
throw new LibratoException('Empty apiUser');
}
$apiToken = $request->get('apiToken');
if (empty($apiToken)) {
throw new LibratoException('Empty apiToken');
}
$action = $request->get('action');
if (empty($action)) {
throw new LibratoException('Empty action');
}
$begin = $request->get('begin', '-30minutes');
if (!isset($this->methodsMap[$action])) {
throw new LibratoException('Unrecognized action');
}
$method = $this->methodsMap[$action]['method'];
$template = $this->methodsMap[$action]['template'];
if (!method_exists($this->libratoService, $method)) {
throw new LibratoException('Unrecognized method');
}
return ['name' => $name, 'apiUser' => $apiUser, 'apiToken' => $apiToken, 'method' => $method, 'template' => $template, 'begin' => $begin];
}
示例13: generateFromRequest
/**
* @param Request $request
* @param array $mapping
*
* @return PaginateFinderConfiguration
*/
public static function generateFromRequest(Request $request, array $mapping = array())
{
$configuration = new static();
$configuration->setSearch($request->get('search'));
$configuration->setPaginateConfiguration($request->get('order'), $request->get('start'), $request->get('length'), $mapping);
return $configuration;
}
示例14: download
public function download(Request $request)
{
$startdate = $request->get("startdate");
$enddate = $request->get("enddate");
if (!$startdate) {
throw new \Exception("startdate parameter is required");
}
if (!$enddate) {
throw new \Exception("enddate parameter is required");
}
$records = $this->storageInterface->between($startdate, $enddate);
$headerSent = false;
$output = "";
foreach ($records as $row) {
if ($row["data"] == 'null') {
continue;
}
$data = json_decode($row["data"], true);
ksort($data);
$outputData = ["datetime" => $row["datetime"]];
$outputData = array_merge($outputData, $data);
if (!$headerSent) {
$output .= "\"" . implode("\",\"", array_keys($outputData)) . "\"\n";
$headerSent = true;
}
$output .= "\"" . implode("\",\"", array_values($outputData)) . "\"\n";
}
return new Response($output, 200, ["Content-Type" => "application/octet-stream", "Content-Disposition" => "attachment; filename=\"boiler.csv\""]);
}
示例15: updateToolAction
/**
* @Rest\View
* @Rest\Patch("/tools/{id}")
*/
public function updateToolAction($id, Request $request)
{
/** @var $currentUser User */
$currentUser = $this->container->get('security.context')->getToken()->getUser();
$em = $this->getDoctrine()->getManager();
/** @var $tool Tool */
$tool = $em->find('AcmeEdelaBundle:Tool', $id);
if (!$tool) {
return $this->createNotFoundException();
}
$userTool = $tool->getUserTools()->matching(Criteria::create()->where(Criteria::expr()->eq('user', $currentUser)))->first();
if (!$userTool) {
$userTool = new UserTool();
$userTool->setUser($currentUser)->setTool($tool);
}
if ($request->get('is_enabled')) {
if ($userTool->getIsAvailable() || !$tool->getCost() && $currentUser->getLevel() > $tool->getMinLevel()) {
$userTool->setIsAvailable(true);
$currentEnable = $userTool->getIsEnabled();
$userTool->setIsEnabled(!$currentEnable);
}
}
if ($request->get('buy_exp')) {
if (!$userTool->getIsAvailable() && $currentUser->getExpBill() >= $tool->getCost() && $currentUser->getLevel() >= $tool->getMinLevel()) {
$em->getRepository('AcmeUserBundle:User')->spendExp($currentUser, $tool->getCost());
$userTool->setIsAvailable(true);
}
}
$em->persist($userTool);
$em->flush();
$serializer = $this->get('jms_serializer');
$toolArray = json_decode($serializer->serialize($tool, 'json'), true);
$userToolArray = json_decode($serializer->serialize($userTool, 'json'), true);
return ['success' => true, 'data' => array_merge($toolArray, $userToolArray)];
}