protected function _getContext($data = []) { if (isset($this->_context) && empty($data)) { return $this->_context; } $data += ['entity' => null]; foreach ($this->_contextProviders as $provider) { $check = $provider['callable']; $context = $check($this->request, $data); if ($context) { break; } } if (!isset($context)) { $context = new NullContext($this->request, $data); } if (!$context instanceof ContextInterface) { throw new RuntimeException('Context objects must implement Cake\\View\\Form\\ContextInterface'); } return $this->_context = $context; }