0

Taking the difference between REST and RPC calls into account and applying them to apigility I want to implement the register action as a RPC call, which adds a user via POST /user, trigger an actication email submission and separate the data to add some specific information to a second endpoint.

Now my question is: What is the most efficient way and how to actually do trigger a REST request in a RPC request in apigility.

The flow should look like this:

POST /register -> create user (POST /user), send activation email, call another API via curl, add data to this user profile -> return user data

Do I need to curl my own api or can I just pass the request along in apigility? The /user endpoint is a simple database connected REST resource and is tested and functional.

Also important is that I want to add authorization to POST /user since we store some data like timestamps of verification and other restricted information in there which should be accessible once authenticated or via (filtered and processed) RPC calls.

ChrJantz
  • 919
  • 1
  • 11
  • 23

1 Answers1

0

You just have to call the service using the corresponding alias present your api configuration in :

'zf-apigility' => array(
    'db-connected' => array(
         'DBConnectedResource' => array(
            (...)
        ),
     ),
 ),

Here, the alias is DBConnectedResource... $this->getServiceLocator()->get('DBConnectedResource') will do the work ;)

merlin
  • 122
  • 2
  • 6
  • Okay, let me re-phrase my initial question: how can I access the service handling a db connected rest controller request of my choice? I am fully aware about all of this, I just don't know what services apigility creates for its db connected rest controllers and how to use them properly in a rpc controller. – ChrJantz Dec 09 '14 at 18:04
  • Answer updated, I didn't test it but should work. If it work, update your question ;) – merlin Dec 09 '14 at 19:23