| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace Meramo\Crazytermsapi\Api;
- use http\Client\Request;
- use http\Message\Body;
- use Meramo\Begriffmgt\Domain\Model\Type;
- use nn\t3;
- use Nng\Nnrestapi\Api\AbstractApi;
- use Nng\Nnrestapi\Annotations as Api;
- use Meramo\Begriffmgt\Domain\Model\Term as TermModel;
- use Meramo\Begriffmgt\Domain\Repository\TermRepository;
- use Symfony\Component\HttpFoundation\JsonResponse;
- use TYPO3\CMS\Core\Http\Response;
- /**
- * This annotation registers this class as an Endpoint!
- *
- * @Api\Endpoint()
- */
- class chatbotterms extends AbstractApi
- {
- /**
- * Constructor
- * Inject the TermRepository.
- *
- * @return void
- */
- public function __construct(TermRepository $termRepository)
- {
- $this->termRepository = t3::injectClass( TermRepository::class );
- $this->termRepositoryOri = $termRepository;
- }
- /**
- * # Retrieve existing Terms
- *
- * Send a simple POST request to retrieve terms by type or category or whatever from the database.
- * The actual request is made based on the combination of params you provide.
- * ```
- * https://www.this-sites-url.com/api/chatbotterms
- * ```
- * Add your request parameters to the request.
- * Based on the fields in the db a possible request could be i.e.:
- * ```
- * ?type=gedoens
- * ```
- * which retrieves all terms with type 'gedoens' or
- * ```
- * ?category=obst
- * ```
- * which retrieves all terms of category 'obst' or
- * ```
- * ?type=gedoens&category=obst
- * ```
- * which retrieves all terms with type 'gedoens' and category 'obst' or even
- * ```
- * ```
- * which retrieves all terms objects.
- *
- * @Api\Access("fe_users")
- * @Api\Localize()
- * @Api\Label("/api/chatbotterms")
- * @return array
- */
- public function getIndexAction()
- {
- $requestArgs = $this->getRequest()->getArguments();
- $type = $requestArgs['type'];
- $category = $requestArgs['category'];
- $termsQueryResults = $this->termRepositoryOri->findAllTermsByTypeOrCategoryOrSimplyAll($type, $category);
- $response = json_decode(json_encode($termsQueryResults));
- return $response;
- }
- }
|