Skip to content
tenebrousedge edited this page Dec 26, 2012 · 1 revision

Paths are configured in whichever config file you want. For consistency I would recommend using Config/paths.php You are responsible for loading this file (using Configure::load()) before the ApisSource datasource needs it: bootstrap.php is a convenient place for that.

API paths must be ordered from most specific conditions to least (or none). This is because the map is iterated through until the first path which has all of its required conditions met is found. If a path has no required conditions, it will be used. Optional conditions aren't checked, but are added when building the request.

<?php
	$config['Copula']['MyPlugin']['path']['host'] = 'www.example.com/api';
	$config['Copula']['MyPlugin']['read'] = array(
	// section
	'people' => array(
		// api url
		'people/id=' => array(
			// required conditions
			'id',
		),
		'people/url=' => array(
			'url',
		),
		'people/~' => array(),
	),
	'people-search' => array(
		'people-search' => array(
		// optional conditions the api call can take
			'optional' => array(
				'keywords',
			),
		),
	),
	);
	$config['Copula']['MyPlugin']['write'] = array(
	);
	$config['Copula']['MyPlugin']['update'] = array(
	);
	$config['Copula']['MyPlugin']['delete'] = array(
	);

You can specify the section by passing a 'section' key in find() requests, otherwise it will default to the value of $useTable for the model making the request.