library phalcon
By Edward Hieatt and Rob Mee: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
generic-repository/phalcon
By Edward Hieatt and Rob Mee: Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
- Friday, September 18, 2015
- by karborator
- Repository
- 3 Watchers
- 7 Stars
- 2 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
Phalcon-generic-repository
Generic repository for Phalcon-framework, (*1)
Move the folder named 'repository 'somewhere in your project.In my case it will be vendor.
Then, at your services file:, (*2)
/**
* Autoload repository
*/
include __DIR__ . "/../../vendor/repository/autoload.php";
/**
* Generic Repository
*/
$dependencyInjector['repository'] = new GenericRepository($config, 'user');
At some Controller :, (*3)
/**
* List all created pages
*
* @link /page - method GET
* @link /page/1 - method GET
*/
public function indexAction($id)
{
if (!empty($id)) {
echo $this->repository->setModel('Page')->setCriteria(array("id = '$id'"))
->mergeResults()
->findFirst()
->getRelated(array('articles', 'comments'))
->returnAs('json');
exit;
}
echo $this->repository->setModel('Page')
->mergeResults()
->findAll()
->getRelated(array('articles', 'comments'))
->returnAs('json');
exit;
}