0

I am writing a custom plugin API that should return PDF, I am using Joomla 5 but I see that it only supports JSON as a return via the View, not only that, but it also requires you to be working with Full MVC structure, is there a away to not do that? I want the flexibility to return a blob or text or whatever from inside the Controller.

class ProductsController extends ApiController
{
 protected $contentType = '';
 protected $default_view = '';

 public function displayList()
 {
 // I need to be able to return here a blob or whatever i want, right now if i return anything the content type in postmen is always "text/html; charset=UTF-8"
 }
}

And this is the view that I don't really need, but it's mandatory by Joomla:

class JsonapiView extends BaseApiView
{
        protected $fieldsToRenderList = [];

        protected $fieldsToRenderItem = [];
}

For reference, these are the docs: https://docs.joomla.org/J4.x:Adding_an_API_to_a_Joomla_Component/en

I did try to just return inside the displayList method but it's not working.

1 Answer 1

0

I found the solution, it was simple by using the header method and exiting after it in the 'displayList' method like so:

header('Content-Type:application/pdf');
exit();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.