0
votes

I want to use some JSON API as a remote datasource. I've found a Webservice plugin by UseMuffin.

I have clear install of CakePHP (latest).

After I've followed all of the steps provided in the "Usage" section of this plugin (https://github.com/UseMuffin/Webservice) I'm stuck on the Unknown repository type "Endpoint". Make sure you register a type before trying to use it. error.

Not sure how to register this type. I've tried

   public function beforeFilter(Event $event)
    {
        $this->modelFactory(
            'Endpoint',
            ['Endpoint', 'factory']
        );
        $this->loadModel('Articles', 'Endpoint');
    }

but got Argument 2 passed to Cake\Controller\Controller::modelFactory() must be callable, array given error.

1
The Endpoint factory should get registered in the dispatcher filter that ships with the plugin. github.com/UseMuffin/Webservice/blob/1.0.2/src/Routing/Filter/… - ndm
May be. But if I use only $this->loadModel('Articles', 'Endpoint'); Unknown repository type "Endpoint" error shows up. - user1327
I know, that was just a hint so you have something where you can start debugging. - ndm

1 Answers

0
votes

Try with:

use Cake\Datasource\ModelAwareTrait;
class YourClassName
{
   use ModelAwareTrait;
   public function abc() {
      $this->modelFactory('Endpoint', ['Muffin\Webservice\Model\EndpointRegistry', 'get']);
      // and then 
      $this->loadModel('Articles', 'Endpoint'); 
   }       

}