Skip to content

Instantly share code, notes, and snippets.

@angelxmoreno
Created May 13, 2014 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelxmoreno/d837f1b9fad724ea27a6 to your computer and use it in GitHub Desktop.
Save angelxmoreno/d837f1b9fad724ea27a6 to your computer and use it in GitHub Desktop.
Testing if Controller::set($data) works in 3.0
<?php
//Controller
namespace App\Controller;
use App\Controller\AppController;
class ArticlesController extends AppController {
public function beforeRender(\Cake\Event\Event $event) {
parent::beforeRender($event);
debug($this->viewVars);
}
/**
* View method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
$article = $this->Articles->get($id, [
'contain' => []
]);
$this->set($article);
}
}
/*
* my view returned `[]` in the debug
* but when i did
* $this->set(compact('article')); //OR
* $this->set('article', $article);
* it had the article object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment