How can I access the variables which are set to the view in CakePHP 3 in a Helper? I did not find anything in the documentation.
In CakePHP 2.x this used to work:
$this->_View->viewVars['foo'];
655: /**
656: * Returns the contents of the given View variable.
657: *
658: * @param string $var The view var you want the contents of.
659: * @param mixed $default The default/fallback content of $var.
660: * @return mixed The content of the named var if its set, otherwise $default.
661: */
662: public function get($var, $default = null)
663: {
664: if (!isset($this->viewVars[$var])) {
665: return $default;
666: }
667:
668: return $this->viewVars[$var];
669: }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.