bridge: Rename setDir and getDir to setWorkingDir and getWorkingDir
This commit is contained in:
parent
86ac0a4866
commit
6f7b56cba8
2 changed files with 8 additions and 8 deletions
|
@ -26,7 +26,7 @@
|
||||||
* require_once __DIR__ . '/rssbridge.php';
|
* require_once __DIR__ . '/rssbridge.php';
|
||||||
*
|
*
|
||||||
* // Step 1: Set the working directory
|
* // Step 1: Set the working directory
|
||||||
* Bridge::setDir(__DIR__ . '/../bridges/');
|
* Bridge::setWorkingDir(__DIR__ . '/../bridges/');
|
||||||
*
|
*
|
||||||
* // Step 2: Add bridges to the whitelist
|
* // Step 2: Add bridges to the whitelist
|
||||||
* Bridge::setWhitelist(array('GitHubIssue', 'GoogleSearch', 'Facebook', 'Twitter'));
|
* Bridge::setWhitelist(array('GitHubIssue', 'GoogleSearch', 'Facebook', 'Twitter'));
|
||||||
|
@ -40,7 +40,7 @@ class Bridge {
|
||||||
/**
|
/**
|
||||||
* Holds the working directory.
|
* Holds the working directory.
|
||||||
* Do not access this property directly!
|
* Do not access this property directly!
|
||||||
* Use {@see Bridge::setDir()} and {@see Bridge::getDir()} instead.
|
* Use {@see Bridge::setWorkingDir()} and {@see Bridge::getWorkingDir()} instead.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -85,7 +85,7 @@ EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nameBridge = Bridge::sanitizeBridgeName($nameBridge) . 'Bridge';
|
$nameBridge = Bridge::sanitizeBridgeName($nameBridge) . 'Bridge';
|
||||||
$pathBridge = self::getDir() . $nameBridge . '.php';
|
$pathBridge = self::getWorkingDir() . $nameBridge . '.php';
|
||||||
|
|
||||||
if(!file_exists($pathBridge)) {
|
if(!file_exists($pathBridge)) {
|
||||||
throw new \Exception('The bridge you are looking for does not exist. It should be at path '
|
throw new \Exception('The bridge you are looking for does not exist. It should be at path '
|
||||||
|
@ -109,7 +109,7 @@ EOD;
|
||||||
* @throws Exception if the provided path does not exist.
|
* @throws Exception if the provided path does not exist.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function setDir($dirBridge){
|
public static function setWorkingDir($dirBridge){
|
||||||
if(!is_string($dirBridge)) {
|
if(!is_string($dirBridge)) {
|
||||||
throw new \InvalidArgumentException('Dir bridge must be a string.');
|
throw new \InvalidArgumentException('Dir bridge must be a string.');
|
||||||
}
|
}
|
||||||
|
@ -123,12 +123,12 @@ EOD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current working directory.
|
* Returns the current working directory.
|
||||||
* The working directory must be specified with {@see Bridge::setDir()}!
|
* The working directory must be specified with {@see Bridge::setWorkingDir()}!
|
||||||
*
|
*
|
||||||
* @throws LogicException if the working directory was not specified.
|
* @throws LogicException if the working directory was not specified.
|
||||||
* @return string The current working directory.
|
* @return string The current working directory.
|
||||||
*/
|
*/
|
||||||
public static function getDir(){
|
public static function getWorkingDir(){
|
||||||
if(is_null(self::$dirBridge)) {
|
if(is_null(self::$dirBridge)) {
|
||||||
throw new \LogicException(__CLASS__ . ' class need to know bridge path !');
|
throw new \LogicException(__CLASS__ . ' class need to know bridge path !');
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ EOD;
|
||||||
static $listBridge = array(); // Initialized on first call
|
static $listBridge = array(); // Initialized on first call
|
||||||
|
|
||||||
if(empty($listBridge)) {
|
if(empty($listBridge)) {
|
||||||
$dirFiles = scandir(self::getDir());
|
$dirFiles = scandir(self::getWorkingDir());
|
||||||
|
|
||||||
if($dirFiles !== false) {
|
if($dirFiles !== false) {
|
||||||
foreach($dirFiles as $fileName) {
|
foreach($dirFiles as $fileName) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ require_once PATH_LIB_VENDOR . 'php-urljoin/src/urljoin.php';
|
||||||
|
|
||||||
// Initialize static members
|
// Initialize static members
|
||||||
try {
|
try {
|
||||||
Bridge::setDir(PATH_LIB_BRIDGES);
|
Bridge::setWorkingDir(PATH_LIB_BRIDGES);
|
||||||
Format::setDir(PATH_LIB_FORMATS);
|
Format::setDir(PATH_LIB_FORMATS);
|
||||||
Cache::setWorkingDir(PATH_LIB_CACHES);
|
Cache::setWorkingDir(PATH_LIB_CACHES);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
|
Loading…
Reference in a new issue