Internal data [Kohana 3.1]

In the infrastructure of Kohana 3.1.x.

What are the benefits of sending data with internal queries like

$post = Request::factory('module/data')
        ->method(Request::POST)
        ->post(array('some' => 'random data'))
        ->execute()
        ->response;

if you can just send data like this

Module::instance()->data(array('some' => 'random data'));

In this example Module, a random module, and datasome random method.

I will call it Modulethrough ajax and internal requests. I plan to develop a RESTful API.

QUESTION: Why use HMVC instead of directly using the internal class API

+3
source share
3 answers

Since they are internal requests, no additional HTTP request is created.

, Request_Client_Internal Request_Client_External. :)

Edit:

, AJAX - " HTTP-". cURL, PECL HTTP, file_get_contents() PHP HTTP- (imho RFC 2616, , HTTP).

+1

HMVC Ajax . , (-ajax) http-, , . "--", .

HMVC, (- ), - Ajax. ( HMVC ajax- ). .

0

I would comment on the foregoing, what bicaveron said, but I cannot yet, so I said that this is the answer. @stacknoob: Could you use Module::instance()->data(array(...))as a controller action? You could - with some extra code. Instead, as biakaveron has already said, you can save your code logic and force the action to return the same result for AJAX and HMVC requests . In one place. DRY + KISS.

0
source

All Articles