Skip to content

The Controller Layer

tenebrousedge edited this page Dec 26, 2012 · 1 revision

The controller-level features of Copula are easy to integrate. The Authorization functions are implemented as a normal CakePHP Authorize object. There are actually some limitations to this by-the-book approach, but it also makes it easy to develop a replacement. For more detail on the subject, see Going Further.

Where were we? So you have an Authorize object, which just exists to provide a yes/no answer to "Does this person have some sort of access token?" and a Component that implements all the OAuth functions related to initially getting those tokens. Both of these expect the controller they're attached to to have a public property $Apis.

<?php
	class MyController extends AppController{
		public $Apis = array('twitter', 'facebook');
	}

The name of the API here must be an exact match for a database configuration variable. You can also specify where the access tokens are stored:

<?php
	class MyController extends AppController{
		public $Apis = array('github' => array('store' => 'Session'));
	}

Valid values for the 'store' key are (currently) 'Db' or 'Session'. Support for storing tokens in persistent cookies may be added in the future.

The CakePHP manual goes into great detail about how to attach both auth objects and components, so that will not be covered here, except to note that neither class has any configurable settings (so far).

Clone this wiki locally