josegonzalez/josegonzalez.github.io

Documentation shows incorrect EntityModel and Entity calls

Opened this issue · 1 comments

The following documentation errors and omissions were noted in the CakeAdvent Calendar Article (no. 5) and the Github Readme for all versions.

CakeAdvent Article

# this call, as documented, does not return entities
$post = $this->findById($post_id);

To get this to work you must do one of the following

# OPT-1: returns entities correctly
$this->entity = true;  #set entity property to true before doing findById
$post = $this->findById($post_id);

# ..or..

#OPT-2: returns entities correctly
$post = $this->find('first', ['Post.id' => $post_id], ['entity'=>true]);

Github Entity Plugin Markdown
Documentation on github only includes and example of OPT-2 above and should include the example for OPT-1

$post = $this->find('first', ['Post.id' => $post_id], ['entity'=>true]);

# ..or..

$this->entity = true; 
$post = $this->findById($post_id);

Fixered :)