本文整理汇总了PHP中Drupal\Core\TypedData\TypedDataManager::setValidationConstraintManager方法的典型用法代码示例。如果您正苦于以下问题:PHP TypedDataManager::setValidationConstraintManager方法的具体用法?PHP TypedDataManager::setValidationConstraintManager怎么用?PHP TypedDataManager::setValidationConstraintManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\TypedData\TypedDataManager
的用法示例。
在下文中一共展示了TypedDataManager::setValidationConstraintManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$cache_backend = new NullBackend('cache');
$namespaces = new \ArrayObject(['Drupal\\Core\\TypedData' => $this->root . '/core/lib/Drupal/Core/TypedData', 'Drupal\\Core\\Validation' => $this->root . '/core/lib/Drupal/Core/Validation']);
$module_handler = $this->getMockBuilder('Drupal\\Core\\Extension\\ModuleHandlerInterface')->disableOriginalConstructor()->getMock();
$class_resolver = $this->getMockBuilder('Drupal\\Core\\DependencyInjection\\ClassResolverInterface')->disableOriginalConstructor()->getMock();
$this->typedDataManager = new TypedDataManager($namespaces, $cache_backend, $module_handler, $class_resolver);
$this->typedDataManager->setValidationConstraintManager(new ConstraintManager($namespaces, $cache_backend, $module_handler));
// Typed data definitions access the manager in the container.
$container = new ContainerBuilder();
$container->set('typed_data_manager', $this->typedDataManager);
\Drupal::setContainer($container);
$translator = new IdentityTranslator();
$this->contextFactory = new ExecutionContextFactory($translator);
$this->validatorFactory = new ConstraintValidatorFactory();
$this->recursiveValidator = new RecursiveValidator($this->contextFactory, $this->validatorFactory, $this->typedDataManager);
}