public function beforeCommand($name, $params = null) { $storageDir = Settings::get(Settings::PATH); if (!is_dir($storageDir) || !is_readable($storageDir) || !is_writable($storageDir)) { throw new Exception(sprintf('Directory %s is not accessible', $storageDir)); } $attempts = 3; while (--$attempts) { if (!$this->isLocked()) { return parent::beforeCommand($name, $params); } usleep(2); } throw new Exception('Could Not Attempt lock'); }
protected static function doCommand(Request $request, AbsractStorage $storage, AbstractResponse $response) { $result = $storage->command($request->getCommandName(), $request->getCommandParams()); $response->setData($result); }