protected function _formUrl($context, $options)
{
if ($options['action'] === null && $options['url'] === null) {
return $this->request->here(false);
}
if (is_string($options['url']) || is_array($options['url']) && isset($options['url']['_name'])) {
return $options['url'];
}
if (isset($options['action']) && empty($options['url']['action'])) {
$options['url']['action'] = $options['action'];
}
$actionDefaults = ['plugin' => $this->plugin, 'controller' => $this->request->params['controller'], 'action' => $this->request->params['action']];
$action = (array) $options['url'] + $actionDefaults;
$pk = $context->primaryKey();
if (count($pk)) {
$id = $context->val($pk[0]);
}
if (empty($action[0]) && isset($id)) {
$action[0] = $id;
}
return $action;
}