/** * @param Http\Request\Parameters\Fields $fields */ protected function filterOutResourceFields(Fields $fields) { if (false === $fields->isEmpty()) { foreach ($fields->get() as $type => $properties) { foreach ($this->serializationStrategy->getMappings() as $mapping) { if ($mapping->getClassAlias() === $type) { $mapping->setFilterKeys($properties); } } } } }
/** * Build the URL. * * @param string $route * @param int $pageNumber * @param int $pageSize * @param Fields $fields * @param Sorting $sorting * @param Included $included * @param array $filters * * @return string */ protected function pagePaginatedRoute($route, $pageNumber, $pageSize, Fields $fields, Sorting $sorting, Included $included, $filters) { $fieldKeys = []; if (false === $fields->isEmpty()) { $fieldKeys = $fields->get(); foreach ($fieldKeys as &$v) { $v = implode(',', $v); } } $queryParams = urldecode(http_build_query(array_filter(['page' => array_filter(['number' => $pageNumber, 'size' => $pageSize]), 'fields' => $fieldKeys, 'filter' => $filters, 'sort' => $sorting->get(), 'include' => $included->get()]))); $expression = $route[strlen($route) - 1] === '?' || $route[strlen($route) - 1] === '&' ? '%s%s' : '%s?%s'; return sprintf($expression, $route, $queryParams); }
public function testItWillReturnAllFieldData() { $expected = ['employee' => ['name', 'surname']]; $this->assertEquals($expected, $this->fields->get()); }