我一直收到此错误,但我不知道问题出在哪里,尽管我遵循了[指南] [1]中的所有步骤
Cakephp 2.x
compact() [<a href='http://php.net/function.compact'>function.compact</a>]:
Undefined variable: subject [CORE\Cake\Utility\ObjectCollection.php, line 128]
启用了重写模块
请检查以下代码,我正在使用cakephp 2版本
尝试按照本教程进行操作,但仍然出现相同的错误
public function trigger($callback, $params = array(), $options = array()) {
if (empty($this->_enabled)) {
return true;
}
if ($callback instanceof CakeEvent) {
$event = $callback;
if (is_array($event->data)) {
$params =& $event->data;
}
if (empty($event->omitSubject)) {
$subject = $event->subject();
}
foreach (array('break', 'breakOn', 'collectReturn', 'modParams') as $opt) {
if (isset($event->{$opt})) {
$options[$opt] = $event->{$opt};
}
}
$parts = explode('.', $event->name());
$callback = array_pop($parts);
}
$options += array(
'break' => false,
'breakOn' => false,
'collectReturn' => false,
'modParams' => false
);
$collected = array();
$list = array_keys($this->_enabled);
if ($options['modParams'] !== false && !isset($params[$options['modParams']])) {
throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.'));
}
$result = null;
foreach ($list as $name) {
$result = call_user_func_array(array($this->_loaded[$name], $callback), compact('subject') + $params);
if ($options['collectReturn'] === true) {
$collected[] = $result;
}
if ($options['break'] && ($result === $options['breakOn'] ||
(is_array($options['breakOn']) && in_array($result, $options['breakOn'], true)))
) {
return $result;
} elseif ($options['modParams'] !== false && !in_array($result, array(true, false, null), true)) {
$params[$options['modParams']] = $result;
}
}
if ($options['modParams'] !== false) {
return $params[$options['modParams']];
}
return $options['collectReturn'] ? $collected : $result;
}