Ejemplo n.º 1
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $validator = $rpHelper->getValidator();
     $validator->required('uuid')->uuid();
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($attributes), $httpRequest);
 }
Ejemplo n.º 2
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $this->helper->addPathFilter($rpHelper->getFilter(), 'path');
     $this->helper->addPathValidator($rpHelper->getValidator(), 'path');
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($attributes), $httpRequest);
 }
Ejemplo n.º 3
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $validator = $rpHelper->getValidator();
     $validator->required('token')->uuid();
     $validator->required('pass_code')->length(40);
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate(['token' => $httpRequest->getHeaderLine('Authentication-Token'), 'pass_code' => $httpRequest->getHeaderLine('Authentication-Pass-Code')]), $httpRequest);
 }
Ejemplo n.º 4
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $validator = $rpHelper->getValidator();
     $validator->required('data.type')->equals('users');
     $validator->required('data.id')->email();
     $validator->required('data.attributes.password');
     $data = $rpHelper->filterAndValidate((array) $httpRequest->getParsedBody())['data'];
     return new Request(self::MESSAGE, ['email_address' => $data['id'], 'password' => $data['attributes']['password']], $httpRequest);
 }
Ejemplo n.º 5
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $filter = $rpHelper->getFilter();
     $this->helper->addPathFilter($filter, 'path');
     $this->helper->addFileNameFilter($filter, 'filename');
     $validator = $rpHelper->getValidator();
     $this->helper->addFullPathValidator($validator, 'path');
     $this->helper->addFileNameValidator($validator, 'filename');
     $data = ['path' => $attributes['path'], 'filename' => $httpRequest->getParsedBody()['filename']];
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($data), $httpRequest);
 }
Ejemplo n.º 6
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $this->helper->addPathFilter($rpHelper->getFilter(), 'path');
     $validator = $rpHelper->getValidator();
     $this->helper->addPathValidator($validator, 'path');
     $validator->required('files')->callback(function ($array) {
         return is_array($array) && count($array) > 0;
     });
     $data = ['path' => $attributes['path'], 'files' => $httpRequest->getUploadedFiles()];
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($data), $httpRequest);
 }
Ejemplo n.º 7
0
 /** {@inheritdoc} */
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $filter = $rpHelper->getFilter();
     $filter->values(['data.attributes.title', 'data.attributes.slug', 'data.attributes.short_title'])->trim()->stripHtml();
     $filter->value('data.attributes.sort_order')->int();
     $validator = $rpHelper->getValidator();
     $validator->required('data.type')->equals('pages');
     $validator->required('data.attributes.title')->lengthBetween(1, 512);
     $validator->required('data.attributes.slug')->lengthBetween(1, 48)->regex('#^[a-z0-9\\-]+$#');
     $validator->required('data.attributes.short_title')->lengthBetween(1, 48);
     $validator->optional('data.attributes.parent_uuid')->uuid();
     $validator->required('data.attributes.sort_order')->integer();
     $validator->required('data.attributes.status')->inArray(PageStatusValue::getValidStatuses(), true);
     $data = (array) $httpRequest->getParsedBody();
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($data)['data']['attributes'], $httpRequest);
 }
Ejemplo n.º 8
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $filter = $rpHelper->getFilter();
     $validator = $rpHelper->getValidator();
     $this->helper->addPathFilter($filter, 'path');
     $this->helper->addFullPathValidator($validator, 'path');
     $data = $httpRequest->getQueryParams();
     $data['path'] = $attributes['path'];
     $this->parseOperationResize($validator, $filter, $data);
     $this->parseOperationCrop($validator, $filter, $data);
     $this->parseOperationRotate($validator, $filter, $data);
     $this->parseOperationNegative($validator, $filter, $data);
     $this->parseOperationGamma($validator, $filter, $data);
     $this->parseOperationGreyscale($validator, $filter, $data);
     $this->parseOperationBlur($validator, $filter, $data);
     return new Request($this->messageName, $rpHelper->filterAndValidate($data), $httpRequest);
 }
Ejemplo n.º 9
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $filter = $rpHelper->getFilter();
     $filter->values(['data.attributes.type', 'data.attributes.location'])->string()->trim();
     $filter->value('data.attributes.sort_order')->int();
     $validator = $rpHelper->getValidator();
     $validator->required('data.id')->uuid();
     $validator->required('data.type')->equals('pageBlocks');
     $validator->required('data.attributes.type')->lengthBetween(1, 48)->regex('#^[a-z0-9\\-]+$#');
     $validator->optional('data.attributes.parameters');
     $validator->required('data.attributes.location')->lengthBetween(1, 48)->regex('#^[a-z0-9\\-]+$#');
     $validator->required('data.attributes.sort_order')->integer();
     $validator->required('data.attributes.status')->inArray(PageStatusValue::getValidStatuses(), true);
     $parameters = (array) $httpRequest->getParsedBody();
     $parameters['data']['id'] = $attributes['page_uuid'];
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($parameters)['data'], $httpRequest);
 }
Ejemplo n.º 10
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $rpHelper->getFilter()->value('data.attributes.sort_order')->int();
     $validator = $rpHelper->getValidator();
     $validator->required('data.type')->equals('pageBlocks');
     $validator->required('data.id')->uuid();
     $validator->required('data.attributes.page_uuid')->uuid();
     $validator->optional('data.attributes.parameters');
     $validator->optional('data.attributes.sort_order')->integer();
     $validator->optional('data.attributes.status')->inArray([PageStatusValue::CONCEPT, PageStatusValue::PUBLISHED], true);
     $data = (array) $httpRequest->getParsedBody();
     $data['data']['id'] = $attributes['uuid'];
     $data['data']['attributes']['page_uuid'] = $attributes['page_uuid'];
     $request = new Request(self::MESSAGE, $rpHelper->filterAndValidate($data)['data']['attributes'], $httpRequest);
     $request['uuid'] = $data['data']['id'];
     return $request;
 }
Ejemplo n.º 11
0
 public function parseHttpRequest(ServerHttpRequest $httpRequest, array $attributes) : RequestInterface
 {
     $rpHelper = new HttpRequestParserHelper($httpRequest);
     $rpHelper->getValidator()->optional('parent_uuid')->uuid();
     return new Request(self::MESSAGE, $rpHelper->filterAndValidate($httpRequest->getQueryParams()), $httpRequest);
 }