Pimcore\Tool\Newsletter::unsubscribeByEmail PHP Метод

unsubscribeByEmail() публичный Метод

public unsubscribeByEmail ( string $email ) : boolean
$email string
Результат boolean
    public function unsubscribeByEmail($email)
    {
        $className = $this->getClassName();
        $objects = $className::getByEmail($email);
        if (count($objects)) {
            foreach ($objects as $object) {
                $this->unsubscribe($object);
            }
            return true;
        }
        return false;
    }

Usage Example

Пример #1
0
 public function unsubscribeAction()
 {
     $this->enableLayout();
     $newsletter = new Newsletter("person");
     // replace "crm" with the class name you have used for your class above (mailing list)
     $unsubscribeMethod = null;
     $success = false;
     if ($this->getParam("email")) {
         $unsubscribeMethod = "email";
         $success = $newsletter->unsubscribeByEmail($this->getParam("email"));
     }
     if ($this->getParam("token")) {
         $unsubscribeMethod = "token";
         $success = $newsletter->unsubscribeByToken($this->getParam("token"));
     }
     $this->view->success = $success;
     $this->view->unsubscribeMethod = $unsubscribeMethod;
 }