ExportController.php
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace App\Controllers;
use App\Constants\Services;
use PhalconRest\Export\Documentation;
use PhalconRest\Export\Postman\ApiCollection;
use PhalconRest\Mvc\Controllers\CollectionController;
use PhalconRest\Transformers\DocumentationTransformer;
use PhalconRest\Transformers\Postman\ApiCollectionTransformer;
class ExportController extends CollectionController
{
public function documentation()
{
/** @var \Phalcon\Config $config */
$config = $this->di->get(Services::CONFIG);
$documentation = new Documentation($config->application->title, $config->hostName);
$documentation->addManyCollections($this->application->getCollections());
$documentation->addManyRoutes($this->application->getRouter()->getRoutes());
return $this->createItemResponse($documentation, new DocumentationTransformer(), 'documentation');
}
public function postman()
{
/** @var \Phalcon\Config $config */
$config = $this->di->get(Services::CONFIG);
$postmanCollection = new ApiCollection($config->application->title, $config->hostName);
$postmanCollection->addManyCollections($this->application->getCollections());
$postmanCollection->addManyRoutes($this->application->getRouter()->getRoutes());
return $this->createItemResponse($postmanCollection, new ApiCollectionTransformer());
}
}