Skip to content

Instantly share code, notes, and snippets.

@pablofmorales
Created April 10, 2013 18:38
Show Gist options
  • Save pablofmorales/5357255 to your computer and use it in GitHub Desktop.
Save pablofmorales/5357255 to your computer and use it in GitHub Desktop.
Ejemplo de uso de Validator
<?php
namespace Services;
use Models\CountryMapper;
use Billing\Services\ServiceValidator;
use Symfony\Component\Validator\Constraints\NotNull;
class Country
{
private $_countryMapper;
private $_validator;
public function __construct(ServiceValidator $validator,
CountryMapper $countryMapper)
{
$this->_countryMapper = $countryMapper;
$this->_validator = $validator;
}
public function getAction($params)
{
$this->_validator->validate(
$params, array(
"siteId" => new NotNull(),
"countryId" => new NotNull()
)
);
return $this->_countryMapper->getConfig(
$params["siteId"],
$params["countryId"]
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment