shivoham/value-object-form-bundle

There is no license information available for the latest version (dev-master) of this package.

dev-master 2016-06-12 15:35 UTC

This package is not auto-updated.

Last update: 2024-12-11 18:40:51 UTC


README

Usage

The Kebab model

class Kebab
{
    private $name;

    public function getName()
    {
        return $this->name;
    }

    public function getIdentity()
    {
        return [
            'name' => $this->name,
        ];
    }

    public function setIdentity(Identity $identity)
    {
        $this->name = $identity->name;
        // ...
    }
}

The "POPO" Kebab identifier

class Identity
{
    public $name;
    
    // ...
}

The Kebab identifier form

use AppBundle\Form\Type\KebabIdentifierType;
use AppBundle\Entity\Kebab;
use AppBundle\Entity\Kebab\Identity;

$this->createForm(KebabIdentifierType::CLASS, $kebab, [
    'object_accessor' => 'getIdentity',
    'object_mutator' => 'setIdentity',
    'value_object_class' => Identity::class
]);