本文整理汇总了PHP中Symfony\Component\Validator\ExecutionContextInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface类的具体用法?PHP ExecutionContextInterface怎么用?PHP ExecutionContextInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExecutionContextInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkValidDiaporama
public function checkValidDiaporama($value, ExecutionContextInterface $context)
{
$value = intval($value);
if (is_null(DiaporamaQuery::create()->findOneById($value))) {
$context->addViolation($this->trans('diaporama.delete.invalid_diaporama %diaporama_id', array('diaporama_id' => $value)));
}
}
示例2: isValid
public function isValid(ExecutionContextInterface $context)
{
$is_valid = $this->start <= $this->end;
if (!$is_valid) {
$context->addViolationAt('end', 'bladetester_calendar.validation.event_dates', array(), null);
}
}
示例3: verifyExistingEmail
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::getCustomerByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
}
}
示例4: verifyExistingEmail
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = NewsletterQuery::create()->filterByUnsubscribed(false)->findOneByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("You are already registered!"));
}
}
示例5: verifyCountry
public function verifyCountry($value, ExecutionContextInterface $context)
{
$address = CountryQuery::create()->findPk($value);
if (null === $address) {
$context->addViolation(Translator::getInstance()->trans("Country ID not found"));
}
}
示例6: verifyCountryList
public function verifyCountryList($value, ExecutionContextInterface $context)
{
$jsonType = new JsonType();
if (!$jsonType->isValid($value)) {
$context->addViolation(Translator::getInstance()->trans("Country list is not valid JSON"));
}
$countryList = json_decode($value, true);
foreach ($countryList as $countryItem) {
if (is_array($countryItem)) {
$country = CountryQuery::create()->findPk($countryItem[0]);
if (null === $country) {
$context->addViolation(Translator::getInstance()->trans("Country ID %id not found", ['%id' => $countryItem[0]]));
}
if ($countryItem[1] == "0") {
continue;
}
$state = StateQuery::create()->findPk($countryItem[1]);
if (null === $state) {
$context->addViolation(Translator::getInstance()->trans("State ID %id not found", ['%id' => $countryItem[1]]));
}
} else {
$context->addViolation(Translator::getInstance()->trans("Wrong country definition"));
}
}
}
示例7: verifyExistingEmail
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if (null === $customer) {
$context->addViolation(Translator::getInstance()->trans("This email does not exists"));
}
}
示例8: verifyExistingLogin
public function verifyExistingLogin($value, ExecutionContextInterface $context)
{
$administrator = AdminQuery::create()->findOneByLogin($value);
if ($administrator !== null) {
$context->addViolation("This login already exists");
}
}
示例9:
function it_does_not_validate_a_non_existent_channel($channelManager, Channel $constraint, ExecutionContextInterface $context)
{
$channelManager->getChannelChoices()->willReturn(['mobile' => 'mobile']);
$context->addViolation(Argument::cetera())->shouldBeCalled();
$this->initialize($context);
$this->validate('Magento', $constraint);
}
示例10: validateSlug
public function validateSlug($blog, ExecutionContextInterface $context)
{
$unique = $this->getDoctrineRepo('AppBundle:Blog')->isSlugUnique($blog->getSlug(), $blog->getId());
if (!$unique) {
$context->buildViolation('The slug is not unique')->addViolation();
}
}
示例11: isDataValid
public function isDataValid(ExecutionContextInterface $context)
{
// valid only on first call
if (++self::$validationCalls > 1) {
$context->addViolation('Take this!');
}
}
示例12: checkDate
/**
* Validate a date entered with the current edition Language date format.
*
* @param string $value
* @param ExecutionContextInterface $context
*/
public function checkDate($value, ExecutionContextInterface $context)
{
$format = self::PHP_DATE_FORMAT;
if (!empty($value) && false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(Translator::getInstance()->trans("Date '%date' is invalid, please enter a valid date using %fmt format", ['%fmt' => self::MOMENT_JS_DATE_FORMAT, '%date' => $value]));
}
}
示例13: verifyEmailField
public function verifyEmailField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (isset($data["email_confirm"]) && $data["email"] != $data["email_confirm"]) {
$context->addViolation(Translator::getInstance()->trans("email confirmation is not the same as email field"));
}
}
示例14: checkCityName
public function checkCityName($value, ExecutionContextInterface $context)
{
$isValid = InseeGeoMunicipalityQuery::create()->findOneById($value);
if (!isset($isValid)) {
$context->addViolation(Translator::getInstance()->trans('city.error', [], INSEEGeo::DOMAIN_NAME));
}
}
示例15: verifyTaxList
public function verifyTaxList($value, ExecutionContextInterface $context)
{
$jsonType = new JsonType();
if (!$jsonType->isValid($value)) {
$context->addViolation(Translator::getInstance()->trans("Tax list is not valid JSON"));
}
$taxList = json_decode($value, true);
/* check we have 2 level max */
foreach ($taxList as $taxLevel1) {
if (is_array($taxLevel1)) {
foreach ($taxLevel1 as $taxLevel2) {
if (is_array($taxLevel2)) {
$context->addViolation(Translator::getInstance()->trans("Bad tax list JSON"));
} else {
$taxModel = TaxQuery::create()->findPk($taxLevel2);
if (null === $taxModel) {
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
}
}
}
} else {
$taxModel = TaxQuery::create()->findPk($taxLevel1);
if (null === $taxModel) {
$context->addViolation(Translator::getInstance()->trans("Tax ID not found in tax list JSON"));
}
}
}
}