예제 #1
0
파일: Validator.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionClass $class, Entity $entity)
 {
     $parts = explode(' ', $tag->getValue(), 2);
     $validator = $this->resolveValidator($parts[0], $entity);
     $message = isset($parts[1]) ? $parts[1] : null;
     $message = $message ?: 'Entity "' . $class->getName() . '" is not valid.';
     $entity->addValidator($message, $validator);
 }
예제 #2
0
파일: Configure.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionProperty $property, Entity $entity)
 {
     $configurator = $tag->getValue();
     if (!class_exists($configurator)) {
         throw new InvalidArgumentException(sprintf('Cannot configure property "%s" for entity "%s" because the configuration class "%s" does not exist.', $property->getName(), get_class($entity), $configurator));
     }
     $configurator = new $configurator();
     $configurator->__invoke($entity);
 }
예제 #3
0
파일: Filter.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionClass $class, Entity $entity)
 {
     $info = $this->parseFilterInformation($tag->getValue());
     if ($info['direction'] === 'to') {
         $entity->addExportFilter($info['name'], new $info['class']());
     } else {
         $entity->addImportFilter($info['name'], new $info['class']());
     }
 }
예제 #4
0
파일: Ensure.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionMethod $method, RepositoryAbstract $repository)
 {
     $cacheKey = $method->getDeclaringClass()->getName() . $method->getName();
     if (!isset(self::$cache[$cacheKey])) {
         self::$cache[$cacheKey] = $this->generateFilter($tag->getValue(), $repository);
     }
     if (is_callable(self::$cache[$cacheKey])) {
         $repository->setReturnValueFilter($method->getName(), self::$cache[$cacheKey]);
     }
 }
예제 #5
0
파일: Cache.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionMethod $method, RepositoryAbstract $repository)
 {
     $cacheKey = $method->getDeclaringClass()->getName() . $method->getName() . $tag->getValue();
     if (!isset(self::$cache[$cacheKey])) {
         self::$cache[$cacheKey] = $this->generateCacheDriverInfo($tag->getValue());
     }
     if (!self::$cache[$cacheKey]['driver']) {
         return;
     }
     if (!$repository->hasCacheDriver(self::$cache[$cacheKey]['driver'])) {
         throw new InvalidArgumentException(sprintf('Cannot apply cache driver "%s" to method "%s" in repository "%s" using the doc tag "%s" because that cache driver was not set.', self::$cache[$cacheKey]['driver'], $method->getName(), get_class($repository), $tag->getName()));
     }
     $repository->setCacheDriverFor($method->getName(), self::$cache[$cacheKey]['driver'], self::$cache[$cacheKey]['lifetime']);
 }
예제 #6
0
파일: Vo.php 프로젝트: devco/model
 private function generateClass(DocTagInterface $tag, Entity $entity)
 {
     $parts = preg_split('/\\s+/', $tag->getValue(), 2);
     $class = function () use($parts) {
         if (isset($parts[1])) {
             $class = eval('return new ' . $parts[0] . '(' . $parts[1] . ');');
         } else {
             $class = new $parts[0]();
         }
         return $class;
     };
     $class = $class->bindTo($entity);
     $class = $class();
     return $class;
 }
예제 #7
0
파일: Mapper.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionClass $class, Entity $entity)
 {
     $parts = explode(' ', $tag->getValue());
     $name = array_shift($parts);
     $key = $class->getName() . $name;
     if (isset(self::$cache[$key])) {
         $entity->setMapper($name, self::$cache[$key]);
         return;
     }
     $mapArr = new MapperArray();
     foreach ($parts as $class) {
         if ($class = trim($class)) {
             $mapArr->add(new $class());
         }
     }
     $entity->setMapper($name, $mapArr);
     self::$cache[$key] = $mapArr;
 }
예제 #8
0
파일: Autoload.php 프로젝트: devco/model
 public function __invoke(DocTagInterface $tag, ReflectionProperty $property, Entity $entity)
 {
     $entity->setAutoloader($property->getName(), $tag->getValue());
 }