Created
May 29, 2012 15:19
-
-
Save tristanbes/2829001 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
[...] | |
class Car | |
{ | |
/** | |
* @ORM\OneToMany(targetEntity="Condition", mappedBy="Car", cascade={"all"}, orphanRemoval=true) | |
*/ | |
private $conditions; | |
public function setConditions($conditions) | |
{ | |
$this->conditions = $conditions; | |
} | |
public function getConditions() | |
{ | |
return $this->conditions; | |
} | |
public function addCondition($condition) | |
{ | |
$this->conditions->add($condition); | |
$condition->setCar($this); | |
} | |
public function removeCondition($condition) | |
{ | |
$this->conditions->remove($condition); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
[...] | |
$builder->add('conditions', 'collection', array( | |
'type' => new ConditionType(), | |
'allow_add' => true, | |
'single_control' => false, | |
'allow_delete' => true, | |
'show_legend' => false, | |
'prototype' => true, | |
'options' => array( | |
'data_class' => 'Condition', | |
'label_render' => false, | |
'required' => false, | |
'widget_control_group' => false | |
) | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
[...] | |
class Condition | |
{ | |
/** | |
* @var integer $id | |
* | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
private $id; | |
/** | |
* @var string $name | |
* | |
* @ORM\Column(name="name", type="string", length=255) | |
*/ | |
private $name; | |
/** | |
* @var integer $car | |
* | |
* @ORM\ManyToOne(targetEntity="Car", inversedBy="conditions") | |
*/ | |
private $car; | |
[getters and setters] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ConditionType extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder->add('name'); | |
} | |
public function getName() | |
{ | |
return 'condition'; | |
} | |
public function getDefaultOptions() | |
{ | |
return array('data_class' => '[...]\Condition'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment