/**
  * Load subscriber
  *
  * Always creates user object. To check if user exists, use $this->exists().
  *
  * @param string $username
  * @return Subscriber
  */
 public static function load($email, array $post = [])
 {
     /** @var ResourceLocatorInterface $locator */
     $locator = self::getGrav()['locator'];
     // force lowercase of username
     $email = strtolower($email);
     /** @var  $content */
     $filePath = $locator->findResource('user://data/newsletter/subscribers/' . $email . YAML_EXT);
     $file = CompiledYamlFile::instance($filePath);
     $subscriber = new Subscriber(array_merge($file->content(), $post));
     if ($subscriber) {
         $subscriber->file($file);
     }
     return $subscriber;
 }
 public function doDisable()
 {
     if (!isset($this->post['subscriber'])) {
         $this->setMessage('Email should be provided');
     }
     $email = $this->post['subscriber'];
     $subscriber = Subscriber::load($email, ['subscribed' => false]);
     if (!$subscriber) {
         $this->setMessage('Subscriber with given email does not exist.');
     }
     $subscriber->save();
     $this->setMessage('Subscriber has been disabled.');
 }