From d20cb75212e273a64c158ef35f6f61674a691621 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Sat, 21 Feb 2015 16:51:19 +0800 Subject: [PATCH] This time for real... --- Services/CacheUpdater.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Services/CacheUpdater.php b/Services/CacheUpdater.php index a913df3..e40709f 100644 --- a/Services/CacheUpdater.php +++ b/Services/CacheUpdater.php @@ -4,18 +4,25 @@ namespace Services; use Services\ICacheUpdater; use Domain\Entities\StepMania\IPack; +use DataAccess\StepMania\IPackRepository; use Domain\Util; class CacheUpdater implements ICacheUpdater { private $_json; + private $_packRepository; - public function __construct() { + public function __construct(IPackRepository $packRepository) { $this->_json = json_decode(file_get_contents('../SimfileCache/simfiles.json'), true); + $this->_packRepository = $packRepository; } public function insert(IPack $pack) { + //XXX: Tricky, when the pack comes in it may not be fully populated + //we are interested in keeping the cache in sync with the DB, so + //reload it from the DB to ensure we have everything. + $pack = $this->_packRepository->findById($pack->getId()); $this->_json['packs'][] = Util::packToArray($pack); return $this; } -- 2.11.0