From 591a651efd3b4fde289e566c0ced9614dd0c618b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 1 Mar 2019 20:52:09 +0100 Subject: [PATCH] added refresh() --- src/RobotLoader/RobotLoader.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/RobotLoader/RobotLoader.php b/src/RobotLoader/RobotLoader.php index b1d9e7b..a678518 100644 --- a/src/RobotLoader/RobotLoader.php +++ b/src/RobotLoader/RobotLoader.php @@ -95,7 +95,7 @@ public function tryLoad($type) $missing = &$this->missing[$type]; $missing++; if (!$this->refreshed && $missing <= self::RETRY_LIMIT) { - $this->refresh(); + $this->refreshClasses(); $this->saveCache(); } elseif ($info) { unset($this->classes[$type]); @@ -172,7 +172,7 @@ public function getIndexedClasses() public function rebuild() { $this->classes = $this->missing = []; - $this->refresh(); + $this->refreshClasses(); if ($this->tempDirectory) { $this->saveCache(); } @@ -180,12 +180,26 @@ public function rebuild() /** - * Refreshes class list. + * Refreshes class list cache. * @return void */ - private function refresh() + public function refresh() { - $this->refreshed = true; // prevents calling refresh() or updateFile() in tryLoad() + $this->loadCache(); + if (!$this->refreshed) { + $this->refreshClasses(); + $this->saveCache(); + } + } + + + /** + * Refreshes $classes. + * @return void + */ + private function refreshClasses() + { + $this->refreshed = true; // prevents calling refreshClasses() or updateFile() in tryLoad() $files = []; foreach ($this->classes as $class => $info) { $files[$info['file']]['time'] = $info['time'];