isAuthorized($url)) { return ($options['before'] ?? '') . parent::link($title, $url, $linkOptions) . ($options['after'] ?? ''); } return ''; } /** * Wrapper for FormHelper.postLink. * Write the link only if user is authorized. * * @param string $title Link's title * @param string|array $url Link's url * @param array $options Link's options * @return string Link as a string. */ public function postLink($title, $url = null, array $options = []): string { return $this->isAuthorized($url) ? $this->Form->postLink($title, $url, $options) : ''; } /** * Get the current request * * @return \Cake\Http\ServerRequest */ public function getRequest() { return $this->getView()->getRequest(); } }