protected function _formUrl($context, $options)
    {
        $request = $this->_View->getRequest();

        if ($options['action'] === null && $options['url'] === null) {
            return $request->getRequestTarget();
        }

        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->_View->getPlugin(),
            'controller' => $request->getParam('controller'),
            'action' => $request->getParam('action'),
        ];

        $action = (array)$options['url'] + $actionDefaults;

        $pk = $context->primaryKey();
        if (count($pk)) {
            $id = $this->getSourceValue($pk[0]);
        }
        if (empty($action[0]) && isset($id)) {
            $action[0] = $id;
        }

        return $action;
    }