From 88ab8855ad392ca30f3451a74d3941cb666479e4 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 22 Feb 2017 14:34:07 +1300 Subject: [PATCH] API Use symfony/cache See https://github.com/silverstripe/silverstripe-framework/issues/6252 --- code/Controllers/CMSMain.php | 11 +++++------ tests/controller/CMSMainTest.php | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index 4022ff31ba..fd8427ebaf 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -21,7 +21,7 @@ use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injector; -use SilverStripe\Core\Cache; +use Psr\SimpleCache\CacheInterface; use SilverStripe\Forms\DateField; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldGroup; @@ -59,7 +59,6 @@ use SilverStripe\View\ArrayData; use SilverStripe\View\Requirements; use Translatable; -use Zend_Cache; use InvalidArgumentException; /** @@ -556,12 +555,12 @@ public function SiteTreeHints() } // Generate basic cache key. Too complex to encompass all variations - $cache = Cache::factory('CMSMain_SiteTreeHints'); + $cache = Injector::inst()->get(CacheInterface::class . '.CMSMain_SiteTreeHints'); $cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes)))); if ($this->getRequest()->getVar('flush')) { - $cache->clean(Zend_Cache::CLEANING_MODE_ALL); + $cache->clear(); } - $json = $cache->load($cacheKey); + $json = $cache->get($cacheKey); if (!$json) { $def['Root'] = array(); $def['Root']['disallowedChildren'] = array(); @@ -608,7 +607,7 @@ public function SiteTreeHints() $this->extend('updateSiteTreeHints', $def); $json = Convert::raw2json($def); - $cache->save($json, $cacheKey); + $cache->set($cacheKey, $json); } return $json; } diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index 3ac91a7bd4..946ca72b1f 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -1,5 +1,6 @@ get(CacheInterface::class . '.CMSMain_SiteTreeHints'); // Login as user with root creation privileges $user = $this->objFromFixture('SilverStripe\\Security\\Member', 'rootedituser'); $user->logIn(); - $cache->clean(Zend_Cache::CLEANING_MODE_ALL); + $cache->clear(); $rawHints = singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->SiteTreeHints(); $this->assertNotNull($rawHints);