1. Go to this page and download the library: Download openeuropa/epoetry-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
openeuropa / epoetry-client example snippets
namespace App\Controller;
use Http\Discovery\Psr17Factory;
use OpenEuropa\EPoetry\NotificationServerFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
class TranslationController extends AbstractController
{
private NotificationServerFactory $factory;
/**
* @param \OpenEuropa\EPoetry\NotificationServerFactory $factory
*/
public function __construct(NotificationServerFactory $factory) {
$this->factory = $factory;
}
/**
* @Route("/translation", name="translation_get", methods={"GET"})
*/
public function getWsdl(Request $request): Response
{
$response = new Response($this->factory->getWsdl());
$response->headers->set('Content-Type', 'application/xml');
return $response;
}
/**
* @Route("/translation", name="translation_post", methods={"POST"})
*/
public function handleNotification(Request $request): Response
{
$psr17Factory = new Psr17Factory();
$psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
$response = $this->factory->handle($psrHttpFactory->createRequest($request));
return (new HttpFoundationFactory())->createResponse($response);
}
}
use OpenEuropa\EPoetry\RequestClientFactory;
use OpenEuropa\EPoetry\Console\Command\EvaluateRequestReturn;
return function(): EvaluateRequestReturn {
// Build $object here...
$request = (new CreateLinguisticRequest())
->setRequestDetails($requestDetails)
->setApplicationName('FOO')
->setTemplateName('WEBTRA');
return new EvaluateRequestReturn($request, 'createLinguisticRequest');
};