src/View/Helper/GuardianHelper.php
public function protectedConfirmationLink($title, $url, $options, $displayLinkTextIfUnauthorized = false)
    {
        if (!isset($options['confirm-message'])) {
            user_error('\'confirm-message\' option is not set on protectedConfirmationLink.');
            $options['confirm-message'] = '';
        }
        if (!isset($options['confirm-title'])) {
            user_error('\'confirm-title\' option is not set on protectedConfirmationLink.');
            $options['confirm-title'] = '';
        }

        $url = $this->_getUrl($url);
        if (!guardian()->hasAccess($url)) {
            if ($displayLinkTextIfUnauthorized) {
                return $title;
            }
            return '';
        }

        $linkOptions = [
            'data-modal-header' => $options['confirm-title'],
            'data-modal-body' => '<p>' . $options['confirm-message'] . '</p>',
            'data-method' => 'post',
            'data-toggle' => 'confirm'
        ];
        unset($options['confirm-title'], $options['confirm-message']);

        if (isset($options['ajax']) && $options['ajax'] === true) {
            $linkOptions['data-modal-ajax'] = 1;
            unset($options['ajax']);

            if (isset($options['notify'])) {
                $linkOptions['data-modal-notify'] = $options['notify'];
                unset($options['notify']);
            }

            if (isset($options['event'])) {
                $linkOptions['data-modal-event'] = $options['event'];
                unset($options['event']);
            }
        }
        if (isset($options['void']) && $options['void'] === true) {
            $linkOptions['data-modal-action'] = Router::url($url);
            $url = 'javascript:void(0)';
        }

        $linkOptions = Hash::merge($linkOptions, $options);
        return $this->link($title, $url, $linkOptions);
    }
public function protectedConfirmationLink($title, $url, $options, $displayLinkTextIfUnauthorized = false)
    {
        if (!isset($options['confirm-message'])) {
            user_error('\'confirm-message\' option is not set on protectedConfirmationLink.');
            $options['confirm-message'] = '';
        }
        if (!isset($options['confirm-title'])) {
            user_error('\'confirm-title\' option is not set on protectedConfirmationLink.');
            $options['confirm-title'] = '';
        }

        $url = $this->_getUrl($url);
        if (!guardian()->hasAccess($url)) {
            if ($displayLinkTextIfUnauthorized) {
                return $title;
            }
            return '';
        }

        $linkOptions = [
            'data-modal-header' => $options['confirm-title'],
            'data-modal-body' => '<p>' . $options['confirm-message'] . '</p>',
            'data-method' => 'post',
            'data-toggle' => 'confirm'
        ];
        unset($options['confirm-title'], $options['confirm-message']);

        if (isset($options['ajax']) && $options['ajax'] === true) {
            $linkOptions['data-modal-ajax'] = 1;
            unset($options['ajax']);

            if (isset($options['notify'])) {
                $linkOptions['data-modal-notify'] = $options['notify'];
                unset($options['notify']);
            }

            if (isset($options['event'])) {
                $linkOptions['data-modal-event'] = $options['event'];
                unset($options['event']);
            }
        }
        if (isset($options['void']) && $options['void'] === true) {
            $linkOptions['data-modal-action'] = Router::url($url);
            $url = 'javascript:void(0)';
        }

        $linkOptions = Hash::merge($linkOptions, $options);
        return $this->link($title, $url, $linkOptions);
    }
public function protectedConfirmationLink ( $ title , $ url , $ options , $ displayLinkTextIfUnauthorized = false ) { if ( ! isset ( $ options [ 'confirm-message' ] ) ) { user_error ( '\'confirm-message\' option is not set on protectedConfirmationLink.' ) ; $ options [ 'confirm-message' ] = '' ; } if ( ! isset ( $ options [ 'confirm-title' ] ) ) { user_error ( '\'confirm-title\' option is not set on protectedConfirmationLink.' ) ; $ options [ 'confirm-title' ] = '' ; } $ url = $ this -> _getUrl ( $ url ) ; if ( ! guardian ( ) -> hasAccess ( $ url ) ) { if ( $ displayLinkTextIfUnauthorized ) { return $ title ; } return '' ; } $ linkOptions = [ 'data-modal-header' => $ options [ 'confirm-title' ] , 'data-modal-body' => '<p>' . $ options [ 'confirm-message' ] . '</p>' , 'data-method' => 'post' , 'data-toggle' => 'confirm' ] ; unset ( $ options [ 'confirm-title' ] , $ options [ 'confirm-message' ] ) ; if ( isset ( $ options [ 'ajax' ] ) && $ options [ 'ajax' ] === true ) { $ linkOptions [ 'data-modal-ajax' ] = 1 ; unset ( $ options [ 'ajax' ] ) ; if ( isset ( $ options [ 'notify' ] ) ) { $ linkOptions [ 'data-modal-notify' ] = $ options [ 'notify' ] ; unset ( $ options [ 'notify' ] ) ; } if ( isset ( $ options [ 'event' ] ) ) { $ linkOptions [ 'data-modal-event' ] = $ options [ 'event' ] ; unset ( $ options [ 'event' ] ) ; } } if ( isset ( $ options [ 'void' ] ) && $ options [ 'void' ] === true ) { $ linkOptions [ 'data-modal-action' ] = Router :: url ( $ url ) ; $ url = 'javascript:void(0)' ; } $ linkOptions = Hash :: merge ( $ linkOptions , $ options ) ; return $ this -> link ( $ title , $ url , $ linkOptions ) ; }
Create a backend confirmation link.

@param string $title The link title.
@param array|string $url The url to link to.
@param array $options Options passed to the html link helper method.
@param bool $displayLinkTextIfUnauthorized Whether to display the link title if the user is
not authorized to access the link.
@return string
Create a backend confirmation link .