Browse files

commit

  • Loading branch information...
1 parent c18237c commit 21956ee39bb1bcebad582811f533dc8080ba3e4c @Mparaiso committed Apr 6, 2013
View
5 nbproject/private/private.properties
@@ -0,0 +1,5 @@
+copy.src.files=false
+copy.src.target=C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mparaiso-doctrineormserviceprovider
+index.file=
+run.as=LOCAL
+url=http://localhost/mparaiso-doctrineormserviceprovider/
View
7 nbproject/project.properties
@@ -0,0 +1,7 @@
+include.path=${php.global.include.path}
+php.version=PHP_53
+source.encoding=UTF-8
+src.dir=.
+tags.asp=false
+tags.short=true
+web.root=.
View
9 nbproject/project.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.php.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/php-project/1">
+ <name>mparaiso-doctrineormserviceprovider</name>
+ </data>
+ </configuration>
+</project>
View
61 src/Mparaiso/Doctrine/ORM/PimpleConstraintValidatorFactory.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ *
+ * @author M.Paraiso
+ *
+ */
+
+namespace Mparaiso\Doctrine\ORM;
+
+use Pimple;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\Validator\Constraint;
+use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
+
+/**
+ * Uses a service container to create constraint validators.
+ *
+ */
+class PimpleConstraintValidatorFactory implements ConstraintValidatorFactoryInterface {
+
+ protected $container;
+ protected $validators;
+
+ /**
+ * Constructor.
+ *
+ * @param ContainerInterface $container The service container
+ * @param array $validators An array of validators
+ */
+ public function __construct(Pimple $container, array $validators = array()) {
+ $this->container = $container;
+ $this->validators = $validators;
+ }
+
+ /**
+ * Returns the validator for the supplied constraint.
+ *
+ * @param Constraint $constraint A constraint
+ *
+ * @return Symfony\Component\Validator\ConstraintValidator A validator for the supplied constraint
+ */
+ public function getInstance(Constraint $constraint) {
+
+ $className = $constraint->validatedBy();
+
+ if (!isset($this->validators[$className])) {
+ $this->validators[$className] = new $className();
+ } elseif (is_string($this->validators[$className])) {
+ $this->validators[$className] = $this->container[$this->validators[$className]];
+ }
+
+ return $this->validators[$className];
+ }
+
+ /* GETTER ajouter des validators après l'instanciation */
+ public function getValidators() {
+ return $this->validators;
+ }
+
+}

0 comments on commit 21956ee

Please sign in to comment.