當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ExecutionContextInterface::getRoot方法代碼示例

本文整理匯總了PHP中Symfony\Component\Validator\ExecutionContextInterface::getRoot方法的典型用法代碼示例。如果您正苦於以下問題:PHP ExecutionContextInterface::getRoot方法的具體用法?PHP ExecutionContextInterface::getRoot怎麽用?PHP ExecutionContextInterface::getRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Validator\ExecutionContextInterface的用法示例。


在下文中一共展示了ExecutionContextInterface::getRoot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: verifyEmailField

 public function verifyEmailField($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if ($data["email"] != $data["email_confirm"]) {
         $context->addViolation(Translator::getInstance()->trans("email confirmation is not the same as email field"));
     }
 }
開發者ID:margery,項目名稱:thelia,代碼行數:7,代碼來源:CustomerCreateForm.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:alex63530,項目名稱:thelia,代碼行數:7,代碼來源:CustomerCreateForm.php

示例3: checkAtLeastOnePhoneNumberIsDefined

 public function checkAtLeastOnePhoneNumberIsDefined($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (empty($data["phone"]) && empty($data["cellphone"])) {
         $context->addViolationAt("phone", Translator::getInstance()->trans("Please enter a home or mobile phone number"));
     }
 }
開發者ID:thelia-modules,項目名稱:ForcePhone,代碼行數:7,代碼來源:ForcePhoneEventListener.php

示例4: 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:margery,項目名稱:thelia,代碼行數:8,代碼來源:ProductModificationForm.php

示例5: __construct

 public function __construct(ExecutionContextInterface $context, $message, array $parameters)
 {
     $this->context = $context;
     $this->message = $message;
     $this->parameters = $parameters;
     $this->root = $context->getRoot();
     $this->invalidValue = $context->getValue();
 }
開發者ID:iurkidi,項目名稱:nmarcajunto,代碼行數:8,代碼來源:LegacyConstraintViolationBuilder.php

示例6:

 function it_validates_deprecated_context($constraint, DeprecatedContext $context)
 {
     $context->getGroup()->shouldBeCalled();
     $context->getRoot()->shouldBeCalled();
     $context->validateValue('some value', $constraint->constraints, Argument::any(), Argument::any())->shouldBeCalled();
     $this->initialize($context);
     $this->validate('some value', $constraint);
 }
開發者ID:bcastellano,項目名稱:symfony-validator-conditional,代碼行數:8,代碼來源:ConditionalValidatorSpec.php

示例7: let

 function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productManager);
     $product->getValue('sku')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
開發者ID:vpetrovych,項目名稱:pim-community-dev,代碼行數:9,代碼來源:UniqueValueValidatorSpec.php

示例8: 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:GuiminZHOU,項目名稱:thelia,代碼行數:10,代碼來源:AdministratorModificationForm.php

示例9: 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:margery,項目名稱:thelia,代碼行數:13,代碼來源:CustomerLogin.php

示例10: checkStock

 public function checkStock($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (null === $data["product_sale_elements_id"]) {
         $context->addViolationAt("quantity", 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:badelas,項目名稱:thelia,代碼行數:13,代碼來源:CartAdd.php

示例11: 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");
     }
     if (strlen($data["password"]) < 4) {
         $context->addViolation("password must be composed of at least 4 characters");
     }
 }
開發者ID:margery,項目名稱:thelia,代碼行數:13,代碼來源:AdministratorCreationForm.php

示例12: checkEmails

 public function checkEmails($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     $value = trim($value);
     if ("" === trim($value) && !empty($data["enabled"])) {
         $context->addViolation($this->trans("The Emails can not be empty", ["%id" => $value]));
     }
     $emails = explode(',', $value);
     foreach ($emails as $email) {
         if (false === filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $context->addViolation($this->trans("'%email' is not a valid email address", ["%email" => $email]));
         }
     }
 }
開發者ID:Mertiozys,項目名稱:StockAlert,代碼行數:14,代碼來源:StockAlertConfig.php

示例13: 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:zorn-v,項目名稱:thelia,代碼行數:15,代碼來源:AddressCountryValidationTrait.php

示例14:

 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)
 {
     $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->addViolation($constraint->message, Argument::any())->shouldBeCalled();
     $this->validate("my_value", $constraint)->shouldReturn(null);
 }
開發者ID:jacko972,項目名稱:pim-community-dev,代碼行數:15,代碼來源:UniqueValueValidatorSpec.php

示例15: 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:margery,項目名稱:thelia,代碼行數:15,代碼來源:ModuleHookCreationForm.php


注:本文中的Symfony\Component\Validator\ExecutionContextInterface::getRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。