Переглянути джерело

[Validator] Made GraphWalker::validateReference() method public

Bernhard Schussek 14 роки тому
батько
коміт
55a97ec78e

+ 1 - 1
src/Symfony/Component/Validator/GraphWalker.php

@@ -133,7 +133,7 @@ class GraphWalker
         }
     }
 
-    protected function walkReference($value, $group, $propertyPath, $traverse)
+    public function walkReference($value, $group, $propertyPath, $traverse)
     {
         if (null !== $value) {
             if (!is_object($value) && !is_array($value)) {

+ 35 - 0
src/Symfony/Component/Validator/Mapping/Cache/ApcCache.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Symfony\Components\Validator\Mapping\Cache;
+
+use Symfony\Components\Validator\Mapping\ClassMetadata;
+
+class ApcCache implements CacheInterface
+{
+    public function has($class)
+    {
+        apc_delete($this->computeCacheKey($class));
+        apc_fetch($this->computeCacheKey($class), $exists);
+
+        return $exists;
+    }
+
+    public function read($class)
+    {
+        if (!$this->has($class)) {
+            // TODO exception
+        }
+
+        return apc_fetch($this->computeCacheKey($class));
+    }
+
+    public function write(ClassMetadata $metadata)
+    {
+        apc_store($this->computeCacheKey($metadata->getClassName()), $metadata);
+    }
+
+    protected function computeCacheKey($class)
+    {
+        return 'Symfony\Components\Validator:'.$class;
+    }
+}