Controller/Adminhtml/Rules/Edit.php
private function checkRuleExistAndLoad($id, $emailRules)
    {
        if ($id) {
            $this->rulesResource->load($emailRules, $id);

            if (!$emailRules->getId()) {
                $this->messageManager->addErrorMessage(__('This rule no longer exists.'));
                $this->_redirect('*/*');
            }
        }

        $this->_view->getPage()->getConfig()->getTitle()->prepend(
            $emailRules->getId() ? $emailRules->getName() : __('New Rule')
        );

        // set entered data if was error when we do save
        $data = $this->_session->getPageData(true);
        if (!empty($data)) {
            $this->rules->addData($data);
        }
    }
private function checkRuleExistAndLoad($id, $emailRules)
    {
        if ($id) {
            $this->rulesResource->load($emailRules, $id);

            if (!$emailRules->getId()) {
                $this->messageManager->addErrorMessage(__('This rule no longer exists.'));
                $this->_redirect('*/*');
            }
        }

        $this->_view->getPage()->getConfig()->getTitle()->prepend(
            $emailRules->getId() ? $emailRules->getName() : __('New Rule')
        );

        // set entered data if was error when we do save
        $data = $this->_session->getPageData(true);
        if (!empty($data)) {
            $this->rules->addData($data);
        }
    }
private function checkRuleExistAndLoad ( $ id , $ emailRules ) { if ( $ id ) { $ this -> rulesResource -> load ( $ emailRules , $ id ) ; if ( ! $ emailRules -> getId ( ) ) { $ this -> messageManager -> addErrorMessage ( __ ( 'This rule no longer exists.' ) ) ; $ this -> _redirect ( '*/*' ) ; } } $ this -> _view -> getPage ( ) -> getConfig ( ) -> getTitle ( ) -> prepend ( $ emailRules -> getId ( ) ? $ emailRules -> getName ( ) : __ ( 'New Rule' ) ) ; // set entered data if was error when we do save $ data = $ this -> _session -> getPageData ( true ) ; if ( ! empty ( $ data ) ) { $ this -> rules -> addData ( $ data ) ; } }
Check rule exist

@param int|null $id
@param \Dotdigitalgroup\Email\Model\Rules $emailRules
@return void
Check rule exist