當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ParameterBag::set方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\ParameterBag::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParameterBag::set方法的具體用法?PHP ParameterBag::set怎麽用?PHP ParameterBag::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\ParameterBag的用法示例。


在下文中一共展示了ParameterBag::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: it_should_change_controller_attribute_to_use_service

 /**
  * @test
  */
 public function it_should_change_controller_attribute_to_use_service()
 {
     $this->attributes->set('_controller', 'stdClass::method');
     $this->given_controller_is_annotated_by_injectable_annotation();
     $this->listener->onKernelController($this->getEvent());
     $this->assertEquals('stdClass:method', $this->attributes->get('_controller'));
 }
開發者ID:tomaszhanc,項目名稱:php-di-symfony-bundle,代碼行數:10,代碼來源:ControllerListenerTest.php

示例2: handle

 /**
  * @param Request $request
  * @param int     $type
  * @param bool    $catch
  *
  * @return Response
  * @throws \Exception
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     if ($type === HttpKernelInterface::SUB_REQUEST) {
         return $this->app->handle($request, $type, $catch);
     }
     $parameters = $this->config->get('cookie_parameters');
     if (!isset($parameters[$this->config->get('current_locale')])) {
         throw new \Exception(sprintf('Domain %s not available', $this->config->get('current_locale')));
     }
     $cookieParams = $parameters[$this->config->get('current_locale')];
     $this->config->set('current_cookie_domain', $cookieParams['domain']);
     if (HttpKernelInterface::MASTER_REQUEST !== $type) {
         return $this->app->handle($request, $type, $catch);
     }
     $session = new Session();
     $request->setSession($session);
     $cookies = $request->cookies;
     if ($cookies->has($session->getName())) {
         $session->setId($cookies->get($session->getName()));
     } else {
         //starts the session if no session exists
         $session->start();
         $session->migrate(false);
     }
     $session->start();
     $response = $this->app->handle($request, $type, $catch);
     if ($session && $session->isStarted()) {
         $session->save();
         $params = array_merge(session_get_cookie_params(), $cookieParams);
         $cookie = new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : $request->server->get('REQUEST_TIME') + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
         $response->headers->setCookie($cookie);
     }
     return $response;
 }
開發者ID:evaneos,項目名稱:pyrite,代碼行數:42,代碼來源:SessionMiddleware.php

示例3: setParameter

 protected function setParameter($key, $value)
 {
     if (null !== $this->response) {
         throw new RuntimeException('Request cannot be modified after it has been sent!');
     }
     $this->parameters->set($key, $value);
     return $this;
 }
開發者ID:ericariyanto,項目名稱:omnipay,代碼行數:8,代碼來源:AbstractRequest.php

示例4: addParameter

 /**
  * Adds a parameter
  *
  * @param string $name
  * @param mixed  $value
  *
  * @return $this
  *
  * @throws \Thuata\ComponentBundle\Exception\InvalidParameterTypeException
  */
 public function addParameter(string $name, $value)
 {
     if (!is_scalar($value)) {
         throw new InvalidParameterTypeException(__CLASS__, __METHOD__, 1, 'scalar', gettype($value));
     }
     $this->parameters->set($name, $value);
     return $this;
 }
開發者ID:Thuata,項目名稱:ComponentBundle,代碼行數:18,代碼來源:Action.php

示例5: testSet

 /**
  * @covers Symfony\Component\HttpFoundation\ParameterBag::set
  */
 public function testSet()
 {
     $bag = new ParameterBag(array());
     $bag->set('foo', 'bar');
     $this->assertEquals('bar', $bag->get('foo'), '->set() sets the value of parameter');
     $bag->set('foo', 'baz');
     $this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter');
 }
開發者ID:renegare,項目名稱:symfony,代碼行數:11,代碼來源:ParameterBagTest.php

示例6: addRequestParamForEvent

 private function addRequestParamForEvent(Notifications $notifications, $eventName, ParameterBag $params)
 {
     $event = $notifications->getNotificationEvent($eventName);
     if ($event->isActive()) {
         $params->set('events[' . $eventName . ']', 'true');
     } else {
         $params->set('events[' . $eventName . ']', 'false');
     }
 }
開發者ID:xabbuh,項目名稱:panda-client,代碼行數:9,代碼來源:NotificationsTransformer.php

示例7: handle

 /**
  * @param Request $request
  * @param int     $type
  * @param bool    $catch
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $host = $request->getHttpHost();
     $sites = $this->config->get('default_site_id');
     $site = str_replace('.', '_', $host);
     $sid = isset($sites[$site]) ? $sites[$site] : $sites['default'];
     $this->config->set('side_id', $sid);
     $this->config->set('current_site_id', $sid);
     return $this->app->handle($request, $type, $catch);
 }
開發者ID:evaneos,項目名稱:pyrite,代碼行數:15,代碼來源:MultiSiteMiddleware.php

示例8: handle

 /**
  * {@inheritDoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (!$request->headers->has($this->header)) {
         $uuid = (string) ($uuid = Uuid::uuid4());
         $request->headers->set($this->header, $uuid);
         $this->config->set('request_id', $uuid);
     } else {
         $this->config->set('request_id', (string) $request->headers->get($this->header));
     }
     $response = $this->app->handle($request, $type, $catch);
     $response->headers->set($this->header, (string) $this->config->get('request_id'));
     return $response;
 }
開發者ID:evaneos,項目名稱:pyrite,代碼行數:16,代碼來源:RequestIdMiddleware.php

示例9: configureActionsVars

 public function configureActionsVars(ParameterBag $actionsVars)
 {
     if ($this->container->isScopeActive('request')) {
         $actionsVars->set('batchSelector', new BatchSelector($actionsVars->get('admin_session')));
     }
     $checkIdClosure = $this->getOption('checkIdClosure');
     if (!$checkIdClosure instanceof \Closure) {
         throw new \RuntimeException('The checkIdClosure is not a closure.');
     }
     $container = $this->container;
     $actionsVars->set('batchCheckIdClosure', function ($id) use($checkIdClosure, $container) {
         return call_user_func_array($checkIdClosure, array($id, $container));
     });
 }
開發者ID:richsage,項目名稱:WhiteOctoberAdminBundle,代碼行數:14,代碼來源:BatchAction.php

示例10: transform

 /**
  * @param ParameterBag $item
  *
  * @throws TransformationFailedException
  */
 public function transform(ParameterBag $item)
 {
     if (!$item->has($this->field)) {
         return;
     }
     $value = $item->get($this->field);
     try {
         $newValue = $this->transformer->transform($value);
         $item->set($this->field, $newValue);
     } catch (TransformationFailedException $e) {
         // set the value to null as we couldn't transform it
         $item->set($this->field, null);
         throw new TransformationFailedException(sprintf('Transforming "%s" using "%s" failed with message: %s.', $this->field, get_class($this->transformer), $e->getMessage()), null, $e);
     }
 }
開發者ID:treehouselabs,項目名稱:feeder,代碼行數:20,代碼來源:DataTransformer.php

示例11: checkCopyAddress

 /**
  * Copies billing address to shipping address
  *
  * @param ParameterBag $parameters
  */
 protected function checkCopyAddress(ParameterBag $parameters)
 {
     if (1 === (int) $parameters->get('copyAddress')) {
         $billingAddress = $parameters->get('billingAddress');
         $parameters->set('shippingAddress', ['shippingAddress.firstName' => $billingAddress['billingAddress.firstName'], 'shippingAddress.lastName' => $billingAddress['billingAddress.lastName'], 'shippingAddress.street' => $billingAddress['billingAddress.street'], 'shippingAddress.streetNo' => $billingAddress['billingAddress.streetNo'], 'shippingAddress.flatNo' => $billingAddress['billingAddress.flatNo'], 'shippingAddress.city' => $billingAddress['billingAddress.city'], 'shippingAddress.postCode' => $billingAddress['billingAddress.postCode'], 'shippingAddress.country' => $billingAddress['billingAddress.country']]);
     }
 }
開發者ID:Sywooch,項目名稱:WellCommerce,代碼行數:12,代碼來源:AddressController.php

示例12: boot

 public function boot()
 {
     if (true === $this->booted) {
         return;
     }
     $this->internalConfig = $this->getContainerConfiguration($this->containerConfigPath)->load();
     $this->config = new ParameterBag($this->internalConfig['parameters']);
     $this->config->set('debug', !$this->config->get('production_mode', true));
     if (null === $this->config->get('root_dir')) {
         throw new BadConfigurationException('You should define root_dir in config');
     }
     $logDir = $this->config->get('log_dir');
     if (null === $logDir) {
         $this->config->set('log_dir', $this->config->get('root_dir') . '../log');
     }
     $this->loggerFactory = new LoggerFactory($this->getConfig()->get('debug'), $this->config->get('log_dir'));
     $appLogger = $this->loggerFactory->create('app');
     if (false === $this->config->get('debug')) {
         error_reporting(E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_NOTICE);
         ini_set('display_errors', 'Off');
     } else {
         error_reporting(E_ALL);
         ini_set('display_errors', 'On');
     }
     ErrorHandler::register($appLogger, $this->errorLevelMap);
     $this->booted = true;
 }
開發者ID:evaneos,項目名稱:pyrite,代碼行數:27,代碼來源:PyriteKernel.php

示例13: testRedirect

 /**
  * Tests redirection.
  *
  * @covers ::execute
  */
 public function testRedirect()
 {
     $this->currentPathStack->getPath()->willReturn('some/random/test/path');
     $this->action->setContextValue('url', '/test/url');
     $this->action->execute();
     $this->parameterBag->set('_rules_redirect_action_url', '/test/url')->shouldHaveBeenCalled();
 }
開發者ID:Progressable,項目名稱:openway8,代碼行數:12,代碼來源:SystemPageRedirectTest.php

示例14: set

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function set($key, $value)
 {
     if (!is_array($value) && !$value instanceof Registry) {
         throw new \InvalidArgumentException('Must be an array or an instance of Registry.');
     }
     parent::set($key, $value);
 }
開發者ID:jonasarts,項目名稱:registry-bundle,代碼行數:12,代碼來源:RegistryBag.php

示例15: set

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function set($key, $value)
 {
     if (!is_array($value) && !$value instanceof UploadedFile) {
         throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
     }
     parent::set($key, $this->convertFileInformation($value));
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:12,代碼來源:FileBag.php


注:本文中的Symfony\Component\HttpFoundation\ParameterBag::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。