浏览代码

[Validator] Removed duplicate class DependencyInjectionValidatorFactory

Bernhard Schussek 15 年之前
父节点
当前提交
235bdc49e4
共有 1 个文件被更改,包括 0 次插入57 次删除
  1. 0 57
      src/Symfony/Components/Validator/DependencyInjectionValidatorFactory.php

+ 0 - 57
src/Symfony/Components/Validator/DependencyInjectionValidatorFactory.php

@@ -1,57 +0,0 @@
-<?php
-
-namespace Symfony\Components\Validator;
-
-use Symfony\Components\DependencyInjection\ContainerInterface,
-        Symfony\Components\Validator\ConstraintValidatorFactoryInterface,
-        Symfony\Components\Validator\Constraint,
-        Symfony\Components\Validator\ConstraintValidatorInterface;
-
-class DependencyInjectionValidatorFactory implements ConstraintValidatorFactoryInterface
-{
-
-    protected $container;
-
-    /**
-     * @param ContainerInterface $container
-     */
-    public function __construct(ContainerInterface $container)
-    {
-        $this->container = $container;
-    }
-
-    /**
-     * Gets contraint validator service, setting it if it doesn't exist
-     * Throws exception if validator service is not instance of ConstraintValidatorInterface
-     * @param Constraint $constraint
-     * @return ConstraintValidatorInterface
-     * @throws \LogicException
-     */
-    public function getInstance(Constraint $constraint)
-    {
-        $className = $constraint->validatedBy();
-        $id = $this->getServiceIdFromClass($className);
-
-        if (!$this->container->has($id)) {
-            $this->container->set($id, new $className());
-        }
-
-        $validator = $this->container->get($id);
-
-        if (!$validator instanceof ConstraintValidatorInterface)  {
-            throw new \LogicException('Service ' . $id . ' is not instance of ConstraintValidatorInterface');
-        }
-
-        return $validator;
-    }
-
-    /**
-     * Gets service id, corresponding to full class name of ConstraintValidator
-     * @param string $className
-     * @return string
-     */
-    protected function getServiceIdFromClass($className)
-    {
-        return str_replace('\\', '.', $className);
-    }
-}