Restrict External Access to Controller, but enable access from Model (CakePHP 2.X) -
In our application we are using controller and view to generate a PDF file which will be emailed to a user The controller is a visible file and it is sent back to the model.
This is setup like this because in the second part of the application we use the same view file (which requires postal data) to display PDF on-page.
My problem is that I need to be able to access controller functions with my model, although I want to stop anyone from executing the controller function (using the website directly).
In the model:
$ content = new content controller (); $ Message = $ content-> Generated PDF ($ view); In the administrator:
Public function generated PDF ($ input_data) {// Set the original page and check results for creating the page: Foreach ($ Input_data $ key = & gt; $ value) {$ this- & gt; Set ($ key, $ value); } // Controller $ view = new View ($ this) to a new view class immediately; $ ViewData = $ view- & gt; Render ('pdf_file', 'pdf'); Return $ ViewData; } However, if the user goes and generates type / content / pdf in his browser, they can use this controller function, so I stop it from accessing the web Want me straight
I am using CakePHP 2.X
The easiest way Underline your controller method by an underline: _generatePDF . Such methods are not accessible through the browser.
Comments
Post a Comment