getFor example

/** * @param PasswordField $field */
    protected function getConstraints(Field $field): array
    {
        $constraints = [
            new NotBlank(),
            new Type('string'),
        ];

        if ($field->getFor() === null || !\array_key_exists($field->getFor(), self::CONFIG_MIN_LENGTH_FOR)) {
            return $constraints;
        }

        $configKey = self::CONFIG_MIN_LENGTH_FOR[$field->getFor()];

        $minPasswordLength = $this->configService->getInt($configKey);

        if ($minPasswordLength === 0) {
            return $constraints;
        }

        
'custom_password',
            'customPassword',
            \PASSWORD_DEFAULT,
            ['b'],
            PasswordField::FOR_ADMIN
        );

        static::assertSame('custom_password', $field->getStorageName());
        static::assertSame('customPassword', $field->getPropertyName());
        static::assertSame(\PASSWORD_DEFAULT, $field->getAlgorithm());
        static::assertSame(['b']$field->getHashOptions());
        static::assertSame('admin', $field->getFor());
    }
}
Home | Imprint | This part of the site doesn't use cookies.