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


PHP ValidatorInterface::getMetadataFactory方法代碼示例

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


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

示例1: validateXApiValidator

 private function validateXApiValidator(ValidatorInterface $validator)
 {
     $metadataFactory = $validator->getMetadataFactory();
     $this->assertTrue($metadataFactory->hasMetadataFor('\\XApi\\Model\\Activity'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\XApi\\Model\\Agent'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\XApi\\Model\\Activity'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\XApi\\Model\\Activity'));
 }
開發者ID:skedone,項目名稱:experience-api,代碼行數:8,代碼來源:ValidatorTest.php

示例2: validateXApiValidator

 private function validateXApiValidator(ValidatorInterface $validator)
 {
     if ($validator instanceof MetadataFactoryInterface) {
         $metadataFactory = $validator;
     } else {
         $metadataFactory = $validator->getMetadataFactory();
     }
     $this->assertTrue($metadataFactory->hasMetadataFor('\\Xabbuh\\XApi\\Model\\Activity'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\Xabbuh\\XApi\\Model\\Agent'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\Xabbuh\\XApi\\Model\\Activity'));
     $this->assertTrue($metadataFactory->hasMetadataFor('\\Xabbuh\\XApi\\Model\\Activity'));
 }
開發者ID:xabbuh,項目名稱:xapi-validator,代碼行數:12,代碼來源:ValidatorTest.php

示例3: __construct

 /**
  * @param ValidatorInterface|LegacyValidatorInterface $validator
  *
  * @throws UnexpectedTypeException If $validator is invalid
  */
 public function __construct($validator)
 {
     // 2.5 API
     if ($validator instanceof ValidatorInterface) {
         $metadata = $validator->getMetadataFor('Symfony\\Component\\Form\\Form');
         // 2.4 API
     } elseif ($validator instanceof LegacyValidatorInterface) {
         $metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\\Component\\Form\\Form');
     } else {
         throw new UnexpectedTypeException($validator, 'Symfony\\Component\\Validator\\Validator\\ValidatorInterface or Symfony\\Component\\Validator\\ValidatorInterface');
     }
     // Register the form constraints in the validator programmatically.
     // This functionality is required when using the Form component without
     // the DIC, where the XML file is loaded automatically. Thus the following
     // code must be kept synchronized with validation.xml
     /** @var $metadata ClassMetadata */
     $metadata->addConstraint(new Form());
     $metadata->addPropertyConstraint('children', new Valid());
     $this->validator = $validator;
 }
開發者ID:lamzin-andrey,項目名稱:skyengtt.loc,代碼行數:25,代碼來源:ValidatorExtension.php

示例4: __construct

 /**
  * @param ValidatorInterface|LegacyValidatorInterface $validator
  *
  * @throws UnexpectedTypeException If $validator is invalid
  */
 public function __construct($validator)
 {
     // 2.5 API
     if ($validator instanceof ValidatorInterface) {
         $metadata = $validator->getMetadataFor('Symfony\\Component\\Form\\Form');
         // 2.4 API
     } elseif ($validator instanceof LegacyValidatorInterface) {
         @trigger_error('Passing an instance of Symfony\\Component\\Validator\\ValidatorInterface as argument to the ' . __METHOD__ . ' method is deprecated since version 2.8 and will be removed in 3.0. Use an implementation of Symfony\\Component\\Validator\\Validator\\ValidatorInterface instead', E_USER_DEPRECATED);
         $metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\\Component\\Form\\Form');
     } else {
         throw new UnexpectedTypeException($validator, 'Symfony\\Component\\Validator\\Validator\\ValidatorInterface or Symfony\\Component\\Validator\\ValidatorInterface');
     }
     // Register the form constraints in the validator programmatically.
     // This functionality is required when using the Form component without
     // the DIC, where the XML file is loaded automatically. Thus the following
     // code must be kept synchronized with validation.xml
     /* @var $metadata ClassMetadata */
     $metadata->addConstraint(new Form());
     $metadata->addPropertyConstraint('children', new Valid());
     $this->validator = $validator;
 }
開發者ID:Kyra2778,項目名稱:AMR,代碼行數:26,代碼來源:ValidatorExtension.php

示例5: attachInlineValidator

 /**
  * Attach the inline validator to the model metadata, this must be done once per admin.
  */
 protected function attachInlineValidator()
 {
     $admin = $this;
     // add the custom inline validation option
     // TODO: Remove conditional method when bumping requirements to SF 2.5+
     if (method_exists($this->validator, 'getMetadataFor')) {
         $metadata = $this->validator->getMetadataFor($this->getClass());
     } else {
         $metadata = $this->validator->getMetadataFactory()->getMetadataFor($this->getClass());
     }
     $metadata->addConstraint(new InlineConstraint(array('service' => $this, 'method' => function (ErrorElement $errorElement, $object) use($admin) {
         /* @var \Sonata\AdminBundle\Admin\AdminInterface $admin */
         // This avoid the main validation to be cascaded to children
         // The problem occurs when a model Page has a collection of Page as property
         if ($admin->hasSubject() && spl_object_hash($object) !== spl_object_hash($admin->getSubject())) {
             return;
         }
         $admin->validate($errorElement, $object);
         foreach ($admin->getExtensions() as $extension) {
             $extension->validate($admin, $errorElement, $object);
         }
     }, 'serializingWarning' => true)));
 }
開發者ID:andrewtch,項目名稱:SonataAdminBundle,代碼行數:26,代碼來源:Admin.php

示例6: testGetMetadataFactory

 public function testGetMetadataFactory()
 {
     $this->assertSame($this->metadataFactory, $this->validator->getMetadataFactory());
 }
開發者ID:raphael-thibierge,項目名稱:ProgWebServerProject,代碼行數:4,代碼來源:AbstractLegacyApiTest.php

示例7: getFormBuilder

 /**
  * {@inheritdoc}
  */
 public function getFormBuilder()
 {
     $admin = $this;
     // add the custom inline validation option
     $metadata = $this->validator->getMetadataFactory()->getClassMetadata($this->getClass());
     $metadata->addConstraint(new \Sonata\AdminBundle\Validator\Constraints\InlineConstraint(array('service' => $this, 'method' => function (ErrorElement $errorElement, $object) use($admin) {
         /* @var \Sonata\AdminBundle\Admin\AdminInterface $admin */
         // This avoid the main validation to be cascaded to children
         // The problem occurs when a model Page has a collection of Page as property
         if ($admin->hasSubject() && spl_object_hash($object) !== spl_object_hash($admin->getSubject())) {
             return;
         }
         $admin->validate($errorElement, $object);
         foreach ($admin->getExtensions() as $extension) {
             $extension->validate($admin, $errorElement, $object);
         }
     })));
     $this->formOptions['data_class'] = $this->getActiveSubClass() ?: $this->getClass();
     $formBuilder = $this->getFormContractor()->getFormBuilder($this->getUniqid(), $this->formOptions);
     $this->defineFormBuilder($formBuilder);
     return $formBuilder;
 }
開發者ID:natxet,項目名稱:SonataAdminBundle,代碼行數:25,代碼來源:Admin.php

示例8: getMetadataFor

 /**
  * Gets metadata from system using the entity class name
  *
  * @param string $className
  *
  * @return ClassMetadata
  * @codeCoverageIgnore
  */
 protected function getMetadataFor($className)
 {
     return $this->validator->getMetadataFactory()->getMetadataFor($className);
 }
開發者ID:ruijl,項目名稱:JsFormValidatorBundle,代碼行數:12,代碼來源:JsFormValidatorFactory.php

示例9: getMetadataFactory

 public function getMetadataFactory()
 {
     return $this->wrappedValidator->getMetadataFactory();
 }
開發者ID:sysdream,項目名稱:LiipFunctionalTestBundle,代碼行數:4,代碼來源:DataCollectingValidator.php

示例10: __construct

 public function __construct(ValidatorInterface $validator)
 {
     $this->validator = $validator;
     $this->validatorMetadataFactory = $validator->getMetadataFactory();
 }
開發者ID:s001dxp,項目名稱:breeze.server.php,代碼行數:5,代碼來源:ValidatorInterceptor.php


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