Skip to content

Instantly share code, notes, and snippets.

@soelen
Created September 9, 2014 09:27
Show Gist options
  • Save soelen/48c89b78adaf02fa42e8 to your computer and use it in GitHub Desktop.
Save soelen/48c89b78adaf02fa42e8 to your computer and use it in GitHub Desktop.
yuidoc :
{
Controller :
{
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options:
{
paths: 'app/Controller/',
outdir: 'doc/Controller/'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-yuidoc');
grunt.registerTask('doc', ['yuidoc']);
Running "yuidoc:Controller" (yuidoc) task
Start YUIDoc compile...
Scanning: app/Controller/
Output: doc/Controller/
YUIDoc compile completed in 0.064 seconds
Done, without errors.
<?php
App::uses('AppController', 'Controller');
/**
* Users Controller
*
* @property User $User
* @property PaginatorComponent $Paginator
*/
class UsersController extends AppController {
/**
* Components
*
* @var array
*/
/**
* index method
*
* @return void
*/
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->Paginator->paginate());
}
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->User->exists($id)) {
throw new NotFoundException(__('Invalid user'));
}
$options = array('conditions' => array('User.' . $this->User->primaryKey => $id));
$this->set('user', $this->User->find('first', $options));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
$groups = $this->User->Group->find('list');
$this->set(compact('groups'));
}
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
if (!$this->User->exists($id)) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('User.' . $this->User->primaryKey => $id));
$this->request->data = $this->User->find('first', $options);
}
$groups = $this->User->Group->find('list');
$this->set(compact('groups'));
}
/**
* delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function delete($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
$this->request->allowMethod('post', 'delete');
if ($this->User->delete()) {
$this->Session->setFlash(__('The user has been deleted.'));
} else {
$this->Session->setFlash(__('The user could not be deleted. Please, try again.'));
}
return $this->redirect(array('action' => 'index'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment