ikucheriavenko
3/16/2017 - 2:30 PM

Get property's constraints

Get property's constraints

$validator = $this->getConfigurationPool()->getContainer()->get('validator');
        $meta = $validator->getMetadataFor(get_class($this->getSubject()));

        $allowableTypes = null;
        $maxSize = null;
        foreach ($meta->properties['resumeFile']->getConstraints() as $constraint) {
            if ($constraint instanceof File) {
                $allowableTypes = $constraint->mimeTypes;
                $allowableTypes = implode(', ', $allowableTypes);

                $maxSize = $constraint->maxSize/pow(10, 3);
            }
        }