-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from fduarte42/master
Master
- Loading branch information
Showing
615 changed files
with
84,122 additions
and
206 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* Loading JsonServer | ||
* | ||
* @author Tim Lochmüller | ||
* @author Tito Duarte <duartito@gmail.com> | ||
*/ | ||
|
||
namespace HDNET\Autoloader\Loader; | ||
|
||
use HDNET\Autoloader\Loader; | ||
use HDNET\Autoloader\LoaderInterface; | ||
use HDNET\Autoloader\Utility\ClassNamingUtility; | ||
use HDNET\Autoloader\Utility\FileUtility; | ||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* Loading JsonServer | ||
*/ | ||
class JsonServer implements LoaderInterface | ||
{ | ||
|
||
/** | ||
* Get all the complex data for the loader. | ||
* This return value will be cached and stored in the database | ||
* There is no file monitoring for this cache | ||
* | ||
* @param Loader $autoLoader | ||
* @param int $type | ||
* | ||
* @return array | ||
*/ | ||
public function prepareLoader(Loader $autoLoader, $type) | ||
{ | ||
$servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Json/'; | ||
$serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php'); | ||
|
||
$info = []; | ||
foreach ($serviceClasses as $service) { | ||
$serviceClass = ClassNamingUtility::getFqnByPath( | ||
$autoLoader->getVendorName(), | ||
$autoLoader->getExtensionKey(), | ||
'Service/Json/' . $service | ||
); | ||
$info[lcfirst($service)] = $serviceClass; | ||
} | ||
|
||
return $info; | ||
} | ||
|
||
/** | ||
* Run the loading process for the ext_tables.php file | ||
* | ||
* @param Loader $autoLoader | ||
* @param array $loaderInformation | ||
* | ||
* @return NULL | ||
*/ | ||
public function loadExtensionTables(Loader $autoLoader, array $loaderInformation) | ||
{ | ||
foreach ($loaderInformation as $key => $class) { | ||
$GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$key] = $class; | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Run the loading process for the ext_localconf.php file | ||
* | ||
* @param Loader $autoLoader | ||
* @param array $loaderInformation | ||
* | ||
* @return NULL | ||
*/ | ||
public function loadExtensionConfiguration(Loader $autoLoader, array $loaderInformation) | ||
{ | ||
foreach ($loaderInformation as $key => $class) { | ||
$GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$key] = $class; | ||
} | ||
return null; | ||
} | ||
} |
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,124 @@ | ||
<?php | ||
|
||
/** | ||
* Json server handling | ||
* | ||
* @author Tim Lochmüller | ||
* @author Tito Duarte <duartito@gmail.com> | ||
*/ | ||
|
||
namespace HDNET\Autoloader\Service; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\HttpUtility; | ||
use Zend\Json\Server\Server; | ||
use Zend\Json\Server\Smd; | ||
|
||
|
||
/** | ||
* Json server handling | ||
*/ | ||
class JsonServer | ||
{ | ||
|
||
/** | ||
* Server key | ||
* | ||
* @var string | ||
*/ | ||
protected $serverKey = ''; | ||
|
||
/** | ||
* Server class | ||
* | ||
* @var string | ||
*/ | ||
protected $serverClass = ''; | ||
|
||
/** | ||
* Check if the WSDL should rendered | ||
* | ||
* @var bool | ||
*/ | ||
protected $renderSmd = false; | ||
|
||
/** | ||
* Build up the object | ||
* | ||
* @param string $server | ||
* @param boolean $smd | ||
* @todo move to hook logic | ||
*/ | ||
public function __construct($server, $smd) | ||
{ | ||
$this->serverKey = $server; | ||
if (isset($GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$server])) { | ||
$this->serverClass = $GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$server]; | ||
} | ||
$this->renderSmd = (bool)$smd; | ||
} | ||
|
||
/** | ||
* Handle the request | ||
*/ | ||
public function handle() | ||
{ | ||
header('Content-Type: application/json'); | ||
if (!class_exists($this->serverClass)) { | ||
$server = new Server(); | ||
$server->fault( | ||
'No valid server class name for the given server key: "' . $this->serverClass . '"', | ||
2342358923745 | ||
); | ||
return; | ||
} | ||
if ($this->renderSmd) { | ||
$this->renderSmd(); | ||
} else { | ||
$this->handleRequest(); | ||
} | ||
} | ||
|
||
/** | ||
* Handle the service request | ||
*/ | ||
protected function handleRequest() | ||
{ | ||
$server = new Server(); | ||
|
||
$server->setClass($this->serverClass); | ||
try { | ||
$server->handle(); | ||
} catch (\Exception $ex) { | ||
$server->fault($ex->getMessage(), $ex->getCode()); | ||
} | ||
} | ||
|
||
/** | ||
* Handle the SMD request | ||
*/ | ||
protected function renderSmd() | ||
{ | ||
$server = new Server(); | ||
$server->setClass($this->serverClass); | ||
|
||
$smd = $server->getServiceMap(); | ||
$smd->setTarget($this->getServiceUri()); | ||
$smd->setEnvelope(Smd::ENV_JSONRPC_2); | ||
|
||
echo $smd; | ||
} | ||
|
||
/** | ||
* Get the Service URI | ||
* | ||
* @return string | ||
*/ | ||
protected function getServiceUri() | ||
{ | ||
$uri = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); | ||
$parts = parse_url($uri); | ||
$parts['query'] = 'eID=JsonServer&server=' . $this->serverKey; | ||
return HttpUtility::buildUrl($parts); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
use TYPO3\CMS\Core\Utility\HttpUtility; | ||
use WSDL\WSDLCreator; | ||
|
||
|
||
/** | ||
* Soap server handling | ||
*/ | ||
|
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"require": { | ||
"piotrooo/wsdl-creator": "1.4.2" | ||
"piotrooo/wsdl-creator": "1.4.2", | ||
"zendframework/zend-http": "2.*", | ||
"zendframework/zend-server": "2.*", | ||
"zendframework/zend-json": "2.*" | ||
} | ||
} |
Oops, something went wrong.