-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring to use dependency injection
- Loading branch information
Zoltan
committed
Feb 4, 2019
1 parent
e1fc6f4
commit 479a4b1
Showing
22 changed files
with
503 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace CBX; | ||
|
||
class APIOffline | ||
{ | ||
private $dir = null; | ||
|
||
public function __construct($dir) { | ||
if (file_exists($dir)) { | ||
$this->dir = $dir; | ||
} else { | ||
trigger_error("I18NClass API Error. API directory '{$dir}' is not exists."); | ||
} | ||
} | ||
|
||
public function getURL() { | ||
return $this->dir; | ||
} | ||
|
||
public function fetchConfig($language, $domain) { | ||
return $this->fetch("{$this->dir}/{$language}_{$domain}.json"); | ||
} | ||
|
||
public function fetchCollection($file) { | ||
return $this->fetch($this->dir.'/'.$file); | ||
} | ||
|
||
private function fetch($path) { | ||
if (file_exists($path)) { | ||
$content = file_get_contents($path); | ||
if ($content) { | ||
$json = json_decode(trim($content), true); | ||
if (json_last_error() === 0) { | ||
return $json; | ||
} else { | ||
trigger_error("I18NClass API Error. (JSON) ".json_last_error_msg()); | ||
} | ||
} else { | ||
trigger_error("I18NClass API Error. File '{$path}' is not exists."); | ||
} | ||
} else { | ||
trigger_error("I18NClass API Error. File '{$path}' is not exists."); | ||
} | ||
return false; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.