Created
May 13, 2014 21:43
-
-
Save angelxmoreno/d837f1b9fad724ea27a6 to your computer and use it in GitHub Desktop.
Testing if Controller::set($data) works in 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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