protected function checkContactSourceAccess($contactSourceId, $action, $isPlugin = false, $integration = '')
    {
        if (!$contactSourceId instanceof ContactSource) {
            //make sure the user has view access to this contactSource
            $contactSourceModel = $this->getModel('contactSource');
            $contactSource      = $contactSourceModel->getEntity((int) $contactSourceId);
        } else {
            $contactSource   = $contactSourceId;
            $contactSourceId = $contactSource->getId();
        }

        if (null === $contactSource || !$contactSource->getId()) {
            if (method_exists($this, 'postActionRedirect')) {
                //set the return URL
                $page      = $this->get('session')->get(
                    $isPlugin ? 'mautic.'.$integration.'.page' : 'mautic.contactSource.page',
                    1
                );
                $returnUrl = $this->generateUrl(
                    $isPlugin ? 'mautic_plugin_timeline_index' : 'mautic_contact_index',
                    ['page' => $page]
                );

                return $this->postActionRedirect(
                    [
                        'returnUrl'       => $returnUrl,
                        'viewParameters'  => ['page' => $page],
                        'contentTemplate' => $isPlugin ? 'MauticContactSourceBundle:ContactSource:pluginIndex' : 'MauticContactSourceBundle:ContactSource:index',
                        'passthroughVars' => [
                            'activeLink'    => $isPlugin ? '#mautic_plugin_timeline_index' : '#mautic_contact_index',
                            'mauticContent' => 'contactSourceTimeline',
                        ],
                        'flashes'         => [
                            [
                                'type'    => 'error',
                                'msg'     => 'mautic.contactSource.contactSource.error.notfound',
                                'msgVars' => ['%id%' => $contactSourceId],
                            ],
                        ],
                    ]
                );
            } else {
                return $this->notFound('mautic.contact.error.notfound');
            }
        } elseif (!$this->get('mautic.security')->hasEntityAccess(
            'contactsource:items:'.$action.'own',
            'contactsource:items:'.$action.'other',
            $contactSource->getPermissionUser()
        )
        ) {
            return $this->accessDenied();
        } else {
            return $contactSource;
        }
    }
protected function checkContactSourceAccess($contactSourceId, $action, $isPlugin = false, $integration = '')
    {
        if (!$contactSourceId instanceof ContactSource) {
            //make sure the user has view access to this contactSource
            $contactSourceModel = $this->getModel('contactSource');
            $contactSource      = $contactSourceModel->getEntity((int) $contactSourceId);
        } else {
            $contactSource   = $contactSourceId;
            $contactSourceId = $contactSource->getId();
        }

        if (null === $contactSource || !$contactSource->getId()) {
            if (method_exists($this, 'postActionRedirect')) {
                //set the return URL
                $page      = $this->get('session')->get(
                    $isPlugin ? 'mautic.'.$integration.'.page' : 'mautic.contactSource.page',
                    1
                );
                $returnUrl = $this->generateUrl(
                    $isPlugin ? 'mautic_plugin_timeline_index' : 'mautic_contact_index',
                    ['page' => $page]
                );

                return $this->postActionRedirect(
                    [
                        'returnUrl'       => $returnUrl,
                        'viewParameters'  => ['page' => $page],
                        'contentTemplate' => $isPlugin ? 'MauticContactSourceBundle:ContactSource:pluginIndex' : 'MauticContactSourceBundle:ContactSource:index',
                        'passthroughVars' => [
                            'activeLink'    => $isPlugin ? '#mautic_plugin_timeline_index' : '#mautic_contact_index',
                            'mauticContent' => 'contactSourceTimeline',
                        ],
                        'flashes'         => [
                            [
                                'type'    => 'error',
                                'msg'     => 'mautic.contactSource.contactSource.error.notfound',
                                'msgVars' => ['%id%' => $contactSourceId],
                            ],
                        ],
                    ]
                );
            } else {
                return $this->notFound('mautic.contact.error.notfound');
            }
        } elseif (!$this->get('mautic.security')->hasEntityAccess(
            'contactsource:items:'.$action.'own',
            'contactsource:items:'.$action.'other',
            $contactSource->getPermissionUser()
        )
        ) {
            return $this->accessDenied();
        } else {
            return $contactSource;
        }
    }
protected function checkContactSourceAccess ( $ contactSourceId , $ action , $ isPlugin = false , $ integration = '' ) { if ( ! $ contactSourceId instanceof ContactSource ) { //make sure the user has view access to this contactSource $ contactSourceModel = $ this -> getModel ( 'contactSource' ) ; $ contactSource = $ contactSourceModel -> getEntity ( ( int ) $ contactSourceId ) ; } else { $ contactSource = $ contactSourceId ; $ contactSourceId = $ contactSource -> getId ( ) ; } if ( null === $ contactSource || ! $ contactSource -> getId ( ) ) { if ( method_exists ( $ this , 'postActionRedirect' ) ) { //set the return URL $ page = $ this -> get ( 'session' ) -> get ( $ isPlugin ? 'mautic.' . $ integration . '.page' : 'mautic.contactSource.page' , 1 ) ; $ returnUrl = $ this -> generateUrl ( $ isPlugin ? 'mautic_plugin_timeline_index' : 'mautic_contact_index' , [ 'page' => $ page ] ) ; return $ this -> postActionRedirect ( [ 'returnUrl' => $ returnUrl , 'viewParameters' => [ 'page' => $ page ] , 'contentTemplate' => $ isPlugin ? 'MauticContactSourceBundle:ContactSource:pluginIndex' : 'MauticContactSourceBundle:ContactSource:index' , 'passthroughVars' => [ 'activeLink' => $ isPlugin ? '#mautic_plugin_timeline_index' : '#mautic_contact_index' , 'mauticContent' => 'contactSourceTimeline' , ] , 'flashes' => [ [ 'type' => 'error' , 'msg' => 'mautic.contactSource.contactSource.error.notfound' , 'msgVars' => [ '%id%' => $ contactSourceId ] , ] , ] , ] ) ; } else { return $ this -> notFound ( 'mautic.contact.error.notfound' ) ; } } elseif ( ! $ this -> get ( 'mautic.security' ) -> hasEntityAccess ( 'contactsource:items:' . $ action . 'own' , 'contactsource:items:' . $ action . 'other' , $ contactSource -> getPermissionUser ( ) ) ) { return $ this -> accessDenied ( ) ; } else { return $ contactSource ; } }
Determines if the user has access to the contactSource the note is for.

@param        $contactSourceId
@param        $action
@param bool   $isPlugin
@param string $integration

@return ContactSource
Determines if the user has access to the contactSource the note is for .