First API implementation

This commit is contained in:
Frédéric Guillot
2014-06-20 15:41:05 -03:00
parent efdc959c55
commit 7c5b900bd8
28 changed files with 1285 additions and 63 deletions

View File

@@ -197,6 +197,18 @@ class Project extends Base
return $this->db->table(self::TABLE)->eq('id', $project_id)->findOne();
}
/**
* Get a project by the name
*
* @access public
* @param string $project_name Project name
* @return array
*/
public function getByName($project_name)
{
return $this->db->table(self::TABLE)->eq('name', $project_name)->findOne();
}
/**
* Fetch project data by using the token
*
@@ -505,7 +517,8 @@ class Project extends Base
new Validators\Integer('id', t('This value must be an integer')),
new Validators\Required('name', t('The project name is required')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50),
new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE)
new Validators\Unique('name', t('This project must be unique'), $this->db->getConnection(), self::TABLE),
new Validators\Integer('is_active', t('This value must be an integer'))
));
return array(