Hi devs,
I am new to Omeka and I'm trying to write a plugin (working in Omeka 2.3) that creates a new API resource that will look up items by their DC IDs. To do this I'm creating an api_resources filter that defines a new controller for an Item. The problem I'm having is that Omeka doesn't seem to find my controller. I created a class called Omekaapiextension_ItemController located in controllers/api/ItemController.php in my plugin folder. My filterApiResources is:
public function filterApiResources($apiResources)
{
$apiResources['my_item'] = array(
'module' => 'OmekaAPIExtension',
'controller' => 'item',
'record_type' => 'Item',
'actions' => array(
'get',
),
);
return $apiResources;
}
When I try to access "api/my_item/1" I am getting an error
{"message":"Invalid controller specified (item)"}. I dug into the code and it seems like this is happening because Omeka is not searching the controller directory of my plugin when it's looking to see if the controller is defined. If I manually add the following lines to filterApiResources:
$front = Zend_Controller_Front::getInstance();
$front->addControllerDirectory('<PATH TO OMEKA>/plugins/OmekaAPIExtension/controllers','OmekaAPIExtension');
then the controller is found. So I assume there is some setting I'm missing somewhere to define where Omeka should look for the controller, but I can't find any documentation or examples that show how to do this configuration, so i'm hoping someone on the list can help out. I've been following the instructions for extending the API (
http://omeka.readthedocs.org/en/latest/Reference/api/extending.html), but there is only info there on using the default controller.
Thanks,
Sarah