Created
December 31, 2012 13:30
-
-
Save aderuwe/4419771 to your computer and use it in GitHub Desktop.
Using a data_class for the heck of it?
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 | |
namespace Comforce\Bundle\ImmoforceBundle\Model; | |
use Comforce\Bundle\GeoPostcodeBundle\Entity\Province; | |
class ProvinceSelector | |
{ | |
private $province; | |
/** | |
* @param Province $province | |
* @return $this | |
*/ | |
public function setProvince(Province $province) | |
{ | |
$this->province = $province; | |
return $this; | |
} | |
/** | |
* @return Province|null | |
*/ | |
public function getProvince() | |
{ | |
return $this->province; | |
} | |
} | |
/* | |
Just to be able to do: | |
$selector = new ProvinceSelector(); | |
$form = $this->createForm(new ProspectingProvinceType(), $selector); | |
if ($request->isMethod('post')) { | |
$form->bind($request); | |
if ($form->isValid()) { | |
$province = $selector->getProvince() | |
} | |
} | |
*/ | |
/* | |
Alternatively, I could skip the class and do: | |
$form = $this->createForm(new ProspectingProvinceType()); | |
if ($request->isMethod('post')) { | |
$form->bind($request); | |
if ($form->isValid()) { | |
$data = $form->getData(); | |
$province = $data['province']; | |
} | |
} | |
But I feel this is ugly... | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment