get one publication

This commit is contained in:
aina esokia
2020-09-18 11:41:08 +03:00
parent b96aa182dd
commit 9f492bdd45
2 changed files with 40 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ class PSExposeController extends Controller
]
]);
if ($response->getStatusCode() == 200) {
if ($resPublication->getStatusCode() == 200) {
$publications[] = json_decode($resPublication->getBody()->getContents(),true);
}
}
@@ -81,6 +81,41 @@ class PSExposeController extends Controller
]);
}
/**
* Require params "exposeName" and "publicationId"
*
* @param PhraseaApplication $app
* @param Request $request
* @return string
*/
public function getPublicationAction(PhraseaApplication $app, Request $request)
{
$exposeConfiguration = $app['conf']->get(['phraseanet-service', 'expose-service', 'exposes'], []);
$exposeConfiguration = $exposeConfiguration[$request->get('exposeName')];
$exposeClient = new Client(['base_uri' => $exposeConfiguration['expose_base_uri'], 'http_errors' => false]);
if (!isset($exposeConfiguration['token'])) {
$exposeConfiguration = $this->generateAndSaveToken($exposeConfiguration, $request->get('exposeName'));
}
$publication = [];
$resPublication = $exposeClient->get('/publications/' . $request->get('publicationId') , [
'headers' => [
'Authorization' => 'Bearer '. $exposeConfiguration['token'],
'Content-Type' => 'application/json'
]
]);
if ($resPublication->getStatusCode() == 200) {
$publication = json_decode($resPublication->getBody()->getContents(),true);
}
return $this->render("prod/WorkZone/ExposeEdit.html.twig", [
'publications' => $publication,
]);
}
/**
* Create a publication
* Require params "exposeName" and "publicationData"

View File

@@ -42,6 +42,10 @@ class PSExposeServiceProvider implements ControllerProviderInterface, ServicePro
->method('GET')
->bind('ps_expose_list_publication');
$controllers->match('/get-publication/{publicationId}', 'controller.ps.expose:getPublicationAction')
->method('GET')
->bind('ps_expose_get_publication');
$controllers->match('/delete-publication/{publicationId}', 'controller.ps.expose:deletePublicationAction')
->method('POST|DELETE')
->bind('ps_expose_delete_publication');