-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move vendor/Joomla to src/Joomla. Update necessary paths.
- Loading branch information
0 parents
commit 0a5405f
Showing
16 changed files
with
6,120 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor/ | ||
composer.phar | ||
composer.lock | ||
phpunit.xml |
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,106 @@ | ||
<?php | ||
/** | ||
* Part of the Joomla Framework Http Package | ||
* | ||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Joomla\Http; | ||
|
||
use Joomla\Registry\Registry; | ||
|
||
/** | ||
* HTTP factory class. | ||
* | ||
* @since 1.0 | ||
*/ | ||
class Factory | ||
{ | ||
/** | ||
* Method to recieve Http instance. | ||
* | ||
* @param Registry $options Client options object. | ||
* @param mixed $adapters Adapter (string) or queue of adapters (array) to use for communication. | ||
* | ||
* @return Http Joomla Http class | ||
* | ||
* @since 1.0 | ||
*/ | ||
public static function getHttp(Registry $options = null, $adapters = null) | ||
{ | ||
if (empty($options)) | ||
{ | ||
$options = new Registry; | ||
} | ||
|
||
return new Http($options, self::getAvailableDriver($options, $adapters)); | ||
} | ||
|
||
/** | ||
* Finds an available http transport object for communication | ||
* | ||
* @param Registry $options Option for creating http transport object | ||
* @param mixed $default Adapter (string) or queue of adapters (array) to use | ||
* | ||
* @return TransportInterface Interface sub-class | ||
* | ||
* @since 1.0 | ||
*/ | ||
public static function getAvailableDriver(Registry $options, $default = null) | ||
{ | ||
if (is_null($default)) | ||
{ | ||
$availableAdapters = self::getHttpTransports(); | ||
} | ||
else | ||
{ | ||
settype($default, 'array'); | ||
$availableAdapters = $default; | ||
} | ||
|
||
// Check if there is at least one available http transport adapter | ||
if (!count($availableAdapters)) | ||
{ | ||
return false; | ||
} | ||
|
||
foreach ($availableAdapters as $adapter) | ||
{ | ||
$class = '\\Joomla\\Http\\Transport\\' . ucfirst($adapter); | ||
|
||
if ($class::isSupported()) | ||
{ | ||
return new $class($options); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Get the http transport handlers | ||
* | ||
* @return array An array of available transport handlers | ||
* | ||
* @since 1.0 | ||
*/ | ||
public static function getHttpTransports() | ||
{ | ||
$names = array(); | ||
$iterator = new \DirectoryIterator(__DIR__ . '/Transport'); | ||
|
||
foreach ($iterator as $file) | ||
{ | ||
$fileName = $file->getFilename(); | ||
|
||
// Only load for php files. | ||
if ($file->isFile() && $file->getExtension() == 'php') | ||
{ | ||
$names[] = substr($fileName, 0, strrpos($fileName, '.')); | ||
} | ||
} | ||
|
||
return $names; | ||
} | ||
} |
Oops, something went wrong.