Skip to content

Instantly share code, notes, and snippets.

@davb
Last active October 10, 2015 14:58
Show Gist options
  • Save davb/3707995 to your computer and use it in GitHub Desktop.
Save davb/3707995 to your computer and use it in GitHub Desktop.
Skeleton implementation of the FeeligoUsersSelector interface
<?php
/**
* Feeligo_Mysite_User_Friends_Selector
*
* this class implements methods to find friends of a given user in
* the database and pass them as Adapters to the Feeligo API.
*/
require_once(str_replace('//','/',dirname(__FILE__).'/').'sdk/interfaces/users_selector.php');
require_once(str_replace('//','/',dirname(__FILE__).'/').'mysite_user_adapter.php');
/**
* this file provides a skeleton implementation, modify to your needs.
*/
class Feeligo_Mysite_User_Friends_Selector implements FeeligoUsersSelector {
/**
* constructor
*
* expects an instance of FeeligoUserAdapter wrapping the user
* whose friends this class gives access to
*
* @param FeeligoUserAdapter $user_adapter
*/
function __construct($user_adapter) {
$this->_user_adapter = $user_adapter;
}
/**
* returns an array containing all the user's friends
*
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function all($limit = null, $offset = 0) {
//TODO: implement this
}
/**
* finds a specific friend by its id
*
* @param mixed $id argument for the SQL id='$id' condition
* @param bool $throw whether the method should throw a
* FeeligoNotFoundException if a friend with that $id is
* not found
* @return FeeligoUserAdapter
*/
public function find($id, $throw = true) {
//TODO: implement this
}
/**
* finds a list of friends by their id's
*
* @param mixed array $ids
* @return FeeligoUserAdapter[] array
*/
public function find_all($ids) {
//TODO: implement this
}
/**
* returns an array containing all the friends whose name matches the query
*
* @param string $query the search query, argument to a SQL LIKE '%$query%' clause
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function search_by_name($query, $limit = null, $offset = 0) {
//TODO: implement this
}
/**
* returns an array containing all the friends whose birth date matches the
* arguments.
* The $year number can be null, which should return all users whose birthday
* is on the specified $day and $month, regardless of their birth year.
* Implementation can safely assume $year, $month, $day is a valid date.
*
* @param int $day the day number, from 1 to 31
* @param int $month the month number, from 1 = January to 12 = December
* @param int $year the year number (as a 4-digit integer), such as 2013
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function search_by_birth_date($day, $month, $year = null, $limit = null, $offset = 0) {
//TODO: implement this
}
}
<?php
/**
* Feeligo_Mysite_Users_Selector
*
* this class implements methods to find users in the
* database and pass them as Adapters to the Feeligo API.
*/
require_once(str_replace('//','/',dirname(__FILE__).'/').'sdk/interfaces/users_selector.php');
require_once(str_replace('//','/',dirname(__FILE__).'/').'mysite_user_adapter.php');
/**
* this file provides a skeleton implementation, modify to your needs.
*/
class Feeligo_Mysite_Users_Selector implements FeeligoUsersSelector {
/**
* returns an array containing all the Users
*
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function all($limit = null, $offset = 0) {
//TODO: implement this
}
/**
* finds a specific User by its id
*
* @param mixed $id argument for the SQL id='$id' condition
* @param bool $throw whether the method should throw a
* FeeligoNotFoundException if a user with that $id is
* not found
* @return FeeligoUserAdapter
*/
public function find($id, $throw = true) {
//TODO: implement this
}
/**
* finds a list of Users by their id's
*
* @param mixed array $ids
* @return FeeligoUserAdapter[] array
*/
public function find_all($ids) {
//TODO: implement this
}
/**
* returns an array containing all the Users whose name matches the query
*
* @param string $query the search query, argument to a SQL LIKE '%$query%' clause
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function search_by_name($query, $limit = null, $offset = 0) {
//TODO: implement this
}
/**
* returns an array containing all the Users whose birth date matches the
* arguments.
* The $year number can be null, which should return all users whose birthday
* is on the specified $day and $month, regardless of their birth year.
* Implementation can safely assume $year, $month, $day is a valid date.
*
* @param int $day the day number, from 1 to 31
* @param int $month the month number, from 1 = January to 12 = December
* @param int $year the year number (as a 4-digit integer), such as 2013
* @param int $limit argument for the SQL LIMIT clause
* @param int $offset argument for the SQL OFFSET clause
* @return FeeligoUserAdapter[] array
*/
public function search_by_birth_date($day, $month, $year = null, $limit = null, $offset = 0) {
//TODO: implement this
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment