Reputation: 5
I am trying to build an extension. In this extension, I'm trying to connect to the database of TYPO3 but I can't access this class and any class is always not found
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class rpc {
/**
*
* @var string
*/
public $tsc_Endpoint = '';
/**
*
* @var string
*/
public $tsc_tokenID = '';
/**
* The main method of the backend module
*/
public function main(){
$connection = GeneralUtility::makeInstance(
ConnectionPool::class)
->getConnectionForTable('gpi_configurations');
$queryBuilder = $connection->createQueryBuilder();
$query = $queryBuilder
->select('*')
->from('gpi_configurations')
->where('config_name = tsc_Endpoint');
$rows = $query->execute->fetchRows();
print_r($rows);
$client = GeneralUtility::makeInstance(GpiClient::class);
try {
$server = GeneralUtility::makeInstance(JsonRpc::class)->__construct($client);
} catch (\Exception $e) {
}
echo $server->process();
}
}
$q = new rpc();
$q->main();
I want to mention something this bulk of code in a file called rpc.php
Is there a way to access TYPO3 functionality on rpc.php? I did many searches but I did not find any useful help.
Upvotes: 0
Views: 1296
Reputation: 1313
From our conversation below, I think what you need is a Middleware
to provide an endpoint. This endpoint reads data from the TYPO3-database passes them your your rpc-service and returns some JSON as $response
.
Classes/
folder.namespace Mazen\YourExtensionName\...
in your Classes.Classes/Service/
but I might not know enough about your application.TYPO3 Doctrine
, especially the part about the WHERE clause
.The Service API it self is deprecated, but you still can group some parts of your application into service ans load them with Dependency Injection from everywhere you need them.
Upvotes: 1