Пример #1
0
 public function testEscapeParamValue()
 {
     $propertyObject = new ParameterBag();
     $this->assertEquals('test string', $propertyObject->escapeParamValue('test string'), 'No escaping nessesary');
     $this->assertEquals('"Containing \\"double-quotes\\""', $propertyObject->escapeParamValue('Containing "double-quotes"'), 'Text contins double quotes');
     $this->assertEquals('"Containing forbidden chars like a ;"', $propertyObject->escapeParamValue('Containing forbidden chars like a ;'), 'Text with semicolon');
 }
Пример #2
0
 public function merge(ParameterBag $bag)
 {
     foreach ($bag->all() as $key => $value) {
         $this->set($key, $value);
     }
     return $this;
 }
 /**
  * Quick entity pager based on configured name
  * 
  * @remote
  * @Secure("ROLE_ADMIN")
  *
  * @param ParameterBag $params 
  */
 public function listAction($params)
 {
     $lists = $this->container->getParameter('hatimeria_ext_js.exposed_lists');
     if (isset($lists[$params->get('name')])) {
         $class = $lists[$params->get('name')]['class'];
     } else {
         return new Failure("No exposed lists with name: " . $params->get('name'));
     }
     return $this->get('hatimeria_extjs.pager')->fromEntity($class, $params);
 }
Пример #4
0
 /**
  * Populate $input variable with Request
  */
 private function populateInput()
 {
     // If already populate, return
     if ($this->input) {
         return;
     }
     if ($this->isJson()) {
         $json = new ParameterBag((array) json_decode($this->getContent(), true));
         $this->input = $json->all();
     }
     // GET
     $get = $this->query->all();
     // POST
     $post = $this->request->all();
     $this->input = array_merge($get, $post);
 }
Пример #5
0
 public function resolveParameter($key, ParameterBag $input)
 {
     $value = $this->parameter->getValue($key);
     //echo "ORGVALUE: $value";
     $pattern = '/\\{\\{(.*?)\\}\\}/';
     preg_match_all($pattern, $value, $matches, PREG_SET_ORDER, 0);
     foreach ($matches as $m) {
         $container = $m[0];
         $content = $m[1];
         $data = $input->getValue($content);
         //echo "New data: $content=$data\n";
         //print_r($this->parameter);
         $value = str_replace($container, $data, $value);
         //echo "content: " . $content . "::container=$container\n";
     }
     return $value;
 }
Пример #6
0
 public function __construct(array $parameters = [])
 {
     parent::__construct($parameters);
     $this->parameters = [];
     foreach ($parameters as $key => $parameter) {
         $this->parameters[$key] = new UploadedFile($parameter);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function set($key, $regex)
 {
     $regex = (string) $regex;
     if ('' !== $regex) {
         // Remove first (^) and last ($) regex pattern.
         $regex = preg_replace('/^\\^(.*)\\$$/', '$1', $regex);
     }
     return parent::set($key, $regex);
 }
Пример #8
0
 public function testToArray()
 {
     $bag = new ParameterBag();
     $this->assertEquals([], $bag->toArray());
     $bag = new ParameterBag(['foo' => 'bar', 'baz' => $std = new \stdClass()]);
     $this->assertEquals(['foo' => 'bar', 'baz' => $std], $bag->toArray());
 }
Пример #9
0
 /**
  * store the current state of scope values.
  *
  * @param $scope string
  * @param $value ParameterBag
  * @return void
  */
 public function store(string $scope, ParameterBag $values)
 {
     $mapper = Database::connect()->mapper('Tiimber\\Memory\\Sql');
     $entity = $mapper->build(['scope' => $scope, 'values' => $values->serialize()]);
     $mapper->save($entity);
 }
Пример #10
0
 /**
  * @return array
  */
 public function all()
 {
     return array_merge_recursive($this->query->all(), $this->request->all());
 }
Пример #11
0
 /**
  * Checks if this is an XHR request.
  *
  * @return bool
  */
 public function isXhr()
 {
     return $this->server->get('X_REQUESTED_WITH') == 'XMLHttpRequest';
 }
Пример #12
0
 /**
  * Overrides the PHP global variables according to this request instance.
  *
  * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE.
  * $_FILES is never overridden, see rfc1867
  */
 public function overrideGlobals()
 {
     $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), NULL, '&')));
     $_GET = $this->query->all();
     $_POST = $this->request->all();
     $_SERVER = $this->server->all();
     $_COOKIE = $this->cookies->all();
     foreach ($this->headers->all() as $key => $value) {
         $key = strtoupper(str_replace('-', '_', $key));
         if (in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
             $_SERVER[$key] = implode(', ', $value);
         } else {
             $_SERVER['HTTP_' . $key] = implode(', ', $value);
         }
     }
     $request = ['g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE];
     $requestOrder = ini_get('request_order') ?: ini_get('variables_order');
     $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
     $_REQUEST = [];
     foreach (str_split($requestOrder) as $order) {
         $_REQUEST = array_merge($_REQUEST, $request[$order]);
     }
 }
Пример #13
0
 /**
  * Returns the HTTP method of this request.
  *
  * @return string The HTTP method of the request
  */
 public function getMethod()
 {
     return $this->server->get('REQUEST_METHOD', 'GET');
 }
Пример #14
0
 /**
  * Expands a flattened array to a new ParameterBag .
  *
  * @param array $flat
  *
  * @return ParameterBag
  **/
 public static function expand(array $flat)
 {
     $bag = new ParameterBag();
     foreach ($flat as $key => $value) {
         $bag->set($key, $value);
     }
     return $bag;
 }
Пример #15
0
 public function __construct(ParameterBag $parameters, ObjectBag $objects)
 {
     $this->parameters = $parameters->toArray();
     $this->objects = $objects->toArray();
 }