ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\NumericFilter::getDescription PHP Method

getDescription() public method

public getDescription ( string $resourceClass ) : array
$resourceClass string
return array
    public function getDescription(string $resourceClass) : array
    {
        $description = [];
        $properties = $this->properties;
        if (null === $properties) {
            $properties = array_fill_keys($this->getClassMetadata($resourceClass)->getFieldNames(), null);
        }
        foreach ($properties as $property => $unused) {
            if (!$this->isPropertyMapped($property, $resourceClass) || !$this->isNumericField($property, $resourceClass)) {
                continue;
            }
            $propertyParts = $this->splitPropertyParts($property);
            $metadata = $this->getNestedMetadata($resourceClass, $propertyParts['associations']);
            $description[$property] = ['property' => $property, 'type' => $this->getType($metadata->getTypeOfField($propertyParts['field'])), 'required' => false];
        }
        return $description;
    }

Usage Example

 public function testGetDescriptionDefaultFields()
 {
     $filter = new NumericFilter($this->managerRegistry, new RequestStack());
     $this->assertEquals(['id' => ['property' => 'id', 'type' => 'int', 'required' => false], 'dummyFloat' => ['property' => 'dummyFloat', 'type' => 'float', 'required' => false], 'dummyPrice' => ['property' => 'dummyPrice', 'type' => 'string', 'required' => false]], $filter->getDescription($this->resourceClass));
 }