Browse Source

Adding verbose output back to the OrmCacheShell

Florian Krämer 8 years ago
parent
commit
41f0ed87e1
3 changed files with 15 additions and 7 deletions
  1. 4 4
      src/ORM/OrmCache.php
  2. 10 2
      src/Shell/OrmCacheShell.php
  3. 1 1
      tests/TestCase/Shell/OrmCacheShellTest.php

+ 4 - 4
src/ORM/OrmCache.php

@@ -49,7 +49,7 @@ class OrmCache
      * Build metadata.
      *
      * @param string|null $name The name of the table to build cache data for.
-     * @return bool
+     * @return array Returns a list build table caches
      */
     public function build($name = null)
     {
@@ -62,14 +62,14 @@ class OrmCache
             $this->_schema->describe($table, ['forceRefresh' => true]);
         }
 
-        return true;
+        return $tables;
     }
 
     /**
      * Clear metadata.
      *
      * @param string|null $name The name of the table to clear cache data for.
-     * @return bool
+     * @return array Returns a list of cleared table caches
      */
     public function clear($name = null)
     {
@@ -84,7 +84,7 @@ class OrmCache
             Cache::delete($key, $configName);
         }
 
-        return true;
+        return $tables;
     }
 
     /**

+ 10 - 2
src/Shell/OrmCacheShell.php

@@ -46,7 +46,11 @@ class OrmCacheShell extends Shell
     public function build($name = null)
     {
         $cache = $this->_getOrmCache();
-        $cache->build($name);
+        $tables = $cache->build($name);
+
+        foreach ($tables as $table) {
+            $this->verbose(sprintf('Cached "%s"', $table));
+        }
 
         $this->out('<success>Cache build complete</success>');
 
@@ -62,7 +66,11 @@ class OrmCacheShell extends Shell
     public function clear($name = null)
     {
         $cache = $this->_getOrmCache();
-        $cache->clear($name);
+        $tables = $cache->clear($name);
+
+        foreach ($tables as $table) {
+            $this->verbose(sprintf('Cleared "%s"', $table));
+        }
 
         $this->out('<success>Cache clear complete</success>');
 

+ 1 - 1
tests/TestCase/Shell/OrmCacheShellTest.php

@@ -47,7 +47,7 @@ class OrmCacheShellTest extends TestCase
         $this->cache->expects($this->any())
             ->method('init')
             ->will($this->returnValue(true));
-        Cache::getConfig('orm_cache', $this->cache);
+        Cache::setConfig('orm_cache', $this->cache);
 
         $ds = ConnectionManager::get('test');
         $ds->cacheMetadata('orm_cache');