UlidToStringTransformer example


        return [
            ['01D85PP1982GF6KTVFHQ7W78FB', new Ulid('01d85pp1982gf6ktvfhq7w78fb')],
        ];
    }

    /** * @dataProvider provideValidUlid */
    public function testTransform($output$input)
    {
        $transformer = new UlidToStringTransformer();

        $input = new Ulid($input);

        $this->assertEquals($output$transformer->transform($input));
    }

    public function testTransformEmpty()
    {
        $transformer = new UlidToStringTransformer();

        $this->assertNull($transformer->transform(null));
    }
/** * @author Pavel Dyakonov <wapinet@mail.ru> */
class UlidType extends AbstractType
{
    /** * @return void */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addViewTransformer(new UlidToStringTransformer())
        ;
    }

    /** * @return void */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'compound' => false,
            'invalid_message' => 'Please enter a valid ULID.',
        ]);
Home | Imprint | This part of the site doesn't use cookies.