当前位置: 首页>>代码示例>>PHP>>正文


PHP ExecutionContextInterface::getRoot方法代码示例

本文整理汇总了PHP中Symfony\Component\Validator\Context\ExecutionContextInterface::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::getRoot方法的具体用法?PHP ExecutionContextInterface::getRoot怎么用?PHP ExecutionContextInterface::getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Validator\Context\ExecutionContextInterface的用法示例。


在下文中一共展示了ExecutionContextInterface::getRoot方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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"));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:7,代码来源:CustomerUpdateForm.php

示例2: verifyPasswordField

 public function verifyPasswordField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["password"] != $data["password_confirm"]) {
         $context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:7,代码来源:CustomerPasswordUpdateForm.php

示例3: checkDuplicateRef

 public function checkDuplicateRef($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     $count = ProductQuery::create()->filterById($data['id'], Criteria::NOT_EQUAL)->filterByRef($value)->count();
     if ($count > 0) {
         $context->addViolation(Translator::getInstance()->trans("A product with reference %ref already exists. Please choose another reference.", array('%ref' => $value)));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:8,代码来源:ProductModificationForm.php

示例4: verifyExistingEmail

 /**
  * If the user select "I'am a new customer", we make sure is email address does not exit in the database.
  */
 public function verifyExistingEmail($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["account"] == 0) {
         $customer = CustomerQuery::create()->findOneByEmail($value);
         if ($customer) {
             $context->addViolation(Translator::getInstance()->trans("A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password."));
         }
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:13,代码来源:CustomerLogin.php

示例5: verifyPasswordField

 public function verifyPasswordField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["password"] != $data["password_confirm"]) {
         $context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
     }
     if ($data["password"] !== '' && strlen($data["password"]) < 4) {
         $context->addViolation(Translator::getInstance()->trans("password must be composed of at least 4 characters"));
     }
 }
开发者ID:gillesbourgeat,项目名称:core,代码行数:10,代码来源:AdministratorModificationForm.php

示例6: checkCodeUnicity

 public function checkCodeUnicity($code, ExecutionContextInterface $context)
 {
     $type = $context->getRoot()->getData()['type'];
     $query = HookQuery::create()->filterByCode($code)->filterByType($type);
     if ($this->form->has('id')) {
         $query->filterById($this->form->getRoot()->getData()['id'], Criteria::NOT_EQUAL);
     }
     if ($query->count() > 0) {
         $context->addViolation(Translator::getInstance()->trans("A Hook with code %name already exists. Please choose another code.", array('%name' => $code)));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:11,代码来源:HookCreationForm.php

示例7: checkStock

 public function checkStock($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (null === $data["product_sale_elements_id"]) {
         $context->buildViolation(Translator::getInstance()->trans("Invalid product_sale_elements"));
     } else {
         $productSaleElements = ProductSaleElementsQuery::create()->filterById($data["product_sale_elements_id"])->filterByProductId($data["product"])->findOne();
         $product = $productSaleElements->getProduct();
         if ($productSaleElements->getQuantity() < $value && $product->getVirtual() === 0 && ConfigQuery::checkAvailableStock()) {
             $context->addViolation(Translator::getInstance()->trans("quantity value is not valid"));
         }
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:13,代码来源:CartAdd.php

示例8: verifyPasswordField

 public function verifyPasswordField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["password"] === '' && $data["password_confirm"] === '') {
         $context->addViolation("password can't be empty");
     }
     if ($data["password"] != $data["password_confirm"]) {
         $context->addViolation("password confirmation is not the same as password field");
     }
     $minLength = ConfigQuery::getMinimuAdminPasswordLength();
     if (strlen($data["password"]) < $minLength) {
         $context->addViolation("password must be composed of at least {$minLength} characters");
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:14,代码来源:AdminCreatePassword.php

示例9:

 function it_adds_violation_with_non_unique_value_from_form_data_and_value_comes_from_memory($uniqueValuesSet, ProductRepositoryInterface $productRepository, ProductValueInterface $uniqueValue, AttributeInterface $uniqueAttribute, ExecutionContextInterface $context, UniqueValue $constraint, ProductInterface $product, Form $form, ConstraintViolationBuilderInterface $violation)
 {
     $context->getRoot()->willReturn($form);
     $form->getData()->willReturn($product);
     $product->getValue('unique_attribute')->willReturn($uniqueValue);
     $uniqueValue->getAttribute()->willReturn($uniqueAttribute);
     $uniqueValue->getProduct()->willReturn($product);
     $uniqueAttribute->isUnique()->willReturn(true);
     $uniqueValue->getData()->willReturn('a content');
     $uniqueAttribute->getCode()->willReturn('unique_attribute');
     $productRepository->valueExists($uniqueValue)->willReturn(false);
     $uniqueValuesSet->addValue($uniqueValue)->willReturn(false);
     $context->buildViolation($constraint->message, Argument::any())->shouldBeCalled()->willReturn($violation);
     $this->validate("my_value", $constraint)->shouldReturn(null);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:UniqueValueValidatorSpec.php

示例10: verifyState

 public function verifyState($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (null !== ($country = CountryQuery::create()->findPk($data['country']))) {
         if ($country->getHasStates()) {
             if (null !== ($state = StateQuery::create()->findPk($data['state']))) {
                 if ($state->getCountryId() !== $country->getId()) {
                     $context->addViolation(Translator::getInstance()->trans("This state doesn't belong to this country."));
                 }
             } else {
                 $context->addViolation(Translator::getInstance()->trans("You should select a state for this country."));
             }
         }
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:15,代码来源:AddressCountryValidationTrait.php

示例11: checkRequirementField

 public function checkRequirementField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     $type = $data["type"];
     if (false !== strpos($context->getPropertyPath(), $type)) {
         // extract requirement type
         if (preg_match('@\\:(.+)\\]@', $context->getPropertyPath(), $matches)) {
             $requirementType = $matches[1];
             if (isset(self::$typeList[$requirementType])) {
                 /** @var TypeInterface $typeClass */
                 $typeClass = self::$typeList[$requirementType];
                 $typeClass->verifyForm($value, $context);
                 return;
             }
         }
         $context->addViolation(Translator::getInstance()->trans("Impossible to check value `%value` for `%type` type", ['%value' => $value, '%type' => $type]));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:18,代码来源:TaxCreationForm.php

示例12: validateIncludeLangUrl

 public function validateIncludeLangUrl($val, ExecutionContextInterface $context)
 {
     if ($val) {
         return;
     }
     $entityManager = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager');
     /** @var Office $object */
     $object = $this->getSubject();
     /** @var Form $form */
     $form = $context->getRoot();
     $host = $form->get('host')->getData();
     /** @var Office[] $offices */
     $offices = $entityManager->getRepository('OctavaMuiBundle:Office')->getOfficesByHost($host, $object->getId());
     foreach ($offices as $office) {
         if (!$office->getIncludeLangInUrl()) {
             $context->buildViolation($this->trans('admin.error.office_host_exists', ['{host}' => $host, '{alias}' => $office->getAlias()]))->addViolation();
             break;
         }
     }
 }
开发者ID:octava,项目名称:cms,代码行数:20,代码来源:OfficeAdmin.php

示例13: getViolation

 private function getViolation()
 {
     return new ConstraintViolation(null, $this->message, $this->parameters, $this->context->getRoot(), $this->propertyPath, $this->invalidValue, $this->plural, $this->code, $this->constraint, $this->cause);
 }
开发者ID:ABaldwinHunter,项目名称:symfony-clone,代码行数:4,代码来源:AbstractConstraintValidatorTest.php

示例14: verifyTemplates

 /**
  * Check if method is the right one if we want to use automatic inserted templates .
  *
  * @param $value
  * @param  ExecutionContextInterface $context
  *
  * @return bool
  */
 public function verifyTemplates($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (!empty($data['templates']) && $data['method'] !== BaseHook::INJECT_TEMPLATE_METHOD_NAME) {
         $context->addViolation($this->trans("If you use automatic insert templates, you should use the method %method%", ['%method%' => BaseHook::INJECT_TEMPLATE_METHOD_NAME]));
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:15,代码来源:ModuleHookCreationForm.php


注:本文中的Symfony\Component\Validator\Context\ExecutionContextInterface::getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。