Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brikou/905543 to your computer and use it in GitHub Desktop.
Save brikou/905543 to your computer and use it in GitHub Desktop.
Disable address validation for known customer, in AcmePizzaBundle
<?php
/**
* @param ExecutionContext $context
* @return bool
*/
public function isValidAddress($context)
{
if ($this->knownCustomer) {
$this->address = $this->em->getRepository('AcmePizzaBundle:Address')->findOneBy(array('phone' => $this->knownPhone));
} else {
$context->getGraphWalker()->walkReference(
$this->address,
$context->getGroup(),
$context->getPropertyPath() . ".address",
true
);
}
if (!($this->address instanceof Address)) {
$context->addViolation('Invalid address given', array(), $this->address);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment