public function onNodeAccess(NodeAccessEvent $event)
    {
        $node     = $event->getNode();
        $account  = $event->getAccount();
        $op       = $event->getOperation();
        $access   = $this->siteManager->getAccess();

        if ('create' === $op) {
            if ($this->siteManager->hasContext()) {
                $site = $this->siteManager->getContext();

                // Prevent creating content on disabled or pending sites
                if (!in_array($site->getState(), [SiteState::INIT, SiteState::OFF, SiteState::ON])) {
                    return $event->deny();
                }
            }

            // All other use cases will be driven by other modules; depending
            // on the user role (webmaser, admin, contributor, or any other)
            // the content creation will be authorized or denied by Drupal core
            // permissions
            return $event->ignore();
        }

        // For some reasons, and because we don't care about the 'update'
        // operation in listings, we are going to hardcode a few behaviors
        // in this method, which won't affect various listings
        if (Permission::UPDATE === $op && $account->uid && $node->uid == $account->uid) {
            if ($node->ucms_sites) {
                // Site contributors can update their own content in sites
                foreach ($access->getUserRoles($account) as $grant) {
                    if (in_array($grant->getSiteId(), $node->ucms_sites)) {
                        return $event->allow();
                    }
                }
            }
        }

        if (Permission::CLONE === $op) {
            if ($node->ucms_sites) {
                foreach (array_intersect_key($access->getUserRoles($account), array_flip($node->ucms_sites)) as $role) {
                    if ($role->getRole() == Access::ROLE_WEBMASTER) {
                        return true;
                    }
                }
            }
        }

        return $event->ignore();
    }
public function onNodeAccess(NodeAccessEvent $event)
    {
        $node     = $event->getNode();
        $account  = $event->getAccount();
        $op       = $event->getOperation();
        $access   = $this->siteManager->getAccess();

        if ('create' === $op) {
            if ($this->siteManager->hasContext()) {
                $site = $this->siteManager->getContext();

                // Prevent creating content on disabled or pending sites
                if (!in_array($site->getState(), [SiteState::INIT, SiteState::OFF, SiteState::ON])) {
                    return $event->deny();
                }
            }

            // All other use cases will be driven by other modules; depending
            // on the user role (webmaser, admin, contributor, or any other)
            // the content creation will be authorized or denied by Drupal core
            // permissions
            return $event->ignore();
        }

        // For some reasons, and because we don't care about the 'update'
        // operation in listings, we are going to hardcode a few behaviors
        // in this method, which won't affect various listings
        if (Permission::UPDATE === $op && $account->uid && $node->uid == $account->uid) {
            if ($node->ucms_sites) {
                // Site contributors can update their own content in sites
                foreach ($access->getUserRoles($account) as $grant) {
                    if (in_array($grant->getSiteId(), $node->ucms_sites)) {
                        return $event->allow();
                    }
                }
            }
        }

        if (Permission::CLONE === $op) {
            if ($node->ucms_sites) {
                foreach (array_intersect_key($access->getUserRoles($account), array_flip($node->ucms_sites)) as $role) {
                    if ($role->getRole() == Access::ROLE_WEBMASTER) {
                        return true;
                    }
                }
            }
        }

        return $event->ignore();
    }
public function onNodeAccess ( NodeAccessEvent $ event ) { $ node = $ event -> getNode ( ) ; $ account = $ event -> getAccount ( ) ; $ op = $ event -> getOperation ( ) ; $ access = $ this -> siteManager -> getAccess ( ) ; if ( 'create' === $ op ) { if ( $ this -> siteManager -> hasContext ( ) ) { $ site = $ this -> siteManager -> getContext ( ) ; // Prevent creating content on disabled or pending sites if ( ! in_array ( $ site -> getState ( ) , [ SiteState :: INIT , SiteState :: OFF , SiteState :: ON ] ) ) { return $ event -> deny ( ) ; } } // All other use cases will be driven by other modules; depending // on the user role (webmaser, admin, contributor, or any other) // the content creation will be authorized or denied by Drupal core // permissions return $ event -> ignore ( ) ; } // For some reasons, and because we don't care about the 'update' // operation in listings, we are going to hardcode a few behaviors // in this method, which won't affect various listings if ( Permission :: UPDATE === $ op && $ account -> uid && $ node -> uid == $ account -> uid ) { if ( $ node -> ucms_sites ) { // Site contributors can update their own content in sites foreach ( $ access -> getUserRoles ( $ account ) as $ grant ) { if ( in_array ( $ grant -> getSiteId ( ) , $ node -> ucms_sites ) ) { return $ event -> allow ( ) ; } } } } if ( Permission :: CLONE === $ op ) { if ( $ node -> ucms_sites ) { foreach ( array_intersect_key ( $ access -> getUserRoles ( $ account ) , array_flip ( $ node -> ucms_sites ) ) as $ role ) { if ( $ role -> getRole ( ) == Access :: ROLE_WEBMASTER ) { return true ; } } } } return $ event -> ignore ( ) ; }
Check node access event listener

@see \MakinaCorpus\Ucms\Contrib\NodeAccess\NodeAccessEventSubscriber
Important note: if you are looking for CREATION ACCESS, please look
into the 'ucms_contrib' module, which drives creation access rights
using the type handler.
Check node access event listener