@param string $subject
@param string $body
@param User[] $users
@param User   $from
@param array  $extra
@param bool   $force

@return boolean
191803
public function send($subject, $body, array $users, $from = null, array $extra = array(), $force = false)
    {
        if ($this->isMailerAvailable()) {
            $body = $this->parseBodyUrl($body);

            $to = [];

            $layout = $this->contentManager->getTranslatedContent(array('type' => 'claro_mail_layout'));
            $fromEmail = $this->getMailerFrom();
            $locale = count($users) === 1 ? $users[0]->getLocale() : $this->ch->getParameter('locale_language');

            if (!$locale) {
                $locale = $this->ch->getParameter('locale_language');
            }

            $usedLayout = $layout[$locale]['content'];
            $body = str_replace('%content%', $body, $usedLayout);
            $body = str_replace('%platform_name%', $this->ch->getParameter('name'), $body);

            if ($from) {
                $body = str_replace('%first_name%', $from->getFirstName(), $body);
                $body = str_replace('%last_name%', $from->getLastName(), $body);
            } else {
                $body = str_replace('%first_name%', $this->ch->getParameter('name'), $body);
                $body = str_replace('%last_name%', '', $body);
            }

            foreach ($users as $user) {
                $mail = $user->getMail();

                if ($user->isMailValidated() || $force) {
                    $to[] = $mail;
                }
            }

            if (isset($extra['to'])) {
                foreach ($extra['to'] as $mail) {
                    if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
                        $to[] = $mail;
                    }
                }
            }

            $message = \Swift_Message::newInstance()
                ->setSubject($subject)
                ->setFrom($fromEmail)
                ->setBody($body, 'text/html');

            if ($from !== null && filter_var($from->getMail(), FILTER_VALIDATE_EMAIL)) {
                $message->setReplyTo($from->getMail());
            }

            if (count($to) > 1) {
                $message->setBcc($to);
            } else {
                $message->setTo($to);
            }

            if (isset($extra['attachment'])) {
                $message->attach(\Swift_Attachment::fromPath($extra['attachment'], "application/octet-stream"));
            }

            return $this->mailer->send($message) ? true : false;
        }

        return false;
    }
1258002
protected function _ensureData(Subject $subject)
    {
        $controller = $this->_controller();
        $action = $this->_action();

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        if (isset($controller->viewVars[$viewVar])) {
            return;
        }

        $key = $subject->success ? 'success' : 'error';

        $config = $action->getConfig('api.' . $key);

        $data = [];

        if (isset($config['data']['subject'])) {
            $config['data']['subject'] = Hash::normalize((array)$config['data']['subject']);

            $subjectArray = (array)$subject;
            foreach ($config['data']['subject'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                $keyPath = $this->_expandPath($subject, $keyPath);
                $valuePath = $this->_expandPath($subject, $valuePath);

                $data = Hash::insert($data, $keyPath, Hash::get($subjectArray, $valuePath));
            }
        }

        if (isset($config['data']['entity'])) {
            $config['data']['entity'] = Hash::normalize((array)$config['data']['entity']);

            foreach ($config['data']['entity'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                if (method_exists($subject->entity, $valuePath)) {
                    $data = Hash::insert($data, $keyPath, call_user_func([$subject->entity, $valuePath]));
                } elseif (isset($subject->entity->{$valuePath})) {
                    $data = Hash::insert($data, $keyPath, $subject->entity->{$valuePath});
                }
            }
        }

        if (isset($config['data']['raw'])) {
            foreach ($config['data']['raw'] as $path => $value) {
                $path = $this->_expandPath($subject, $path);
                $data = Hash::insert($data, $path, $value);
            }
        }

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        $controller->set($viewVar, $data);
    }
1100433
protected function has($part, $subject)
    {
        return (
            method_exists($subject, $part)
            || (is_array($subject) && array_key_exists($part, $subject))
            || (is_object($subject) && property_exists($subject, $part))
        );
    }
1343233
protected function sendEmail(array $recipient, array $from, $subject, $bodyHTML = '', $bodyPlain = '', array $replyTo = NULL)
    {

        if ($replyTo == NULL) {
            $replyTo = $from;
        }
        $mail = GeneralUtility::makeInstance(MailMessage::class);
        $mail
            ->setTo($recipient)
            ->setFrom($from)
            ->setReplyTo($replyTo)
            ->setSubject($subject);

        if ($bodyHTML !== '' && $bodyHTML !== NULL ) {
            $mail->addPart($bodyHTML, 'text/html');
        }
        if ($bodyPlain !== '' && $bodyPlain !== NULL ) {
            $mail->addPart($bodyPlain, 'text/plain');
        }

        return $mail->send();
    }
330548
public function roleFetchSubjectRoles(SubjectInterface $subject, $permissions = true)
    {
        $query = "
            SELECT
                role_id
            FROM
                auth_subject_role
            WHERE
                subject_id = :subject_id
        ";
        $roles = [];
        $cur = $this->db->prepare($query);
        $cur->bindValue(":subject_id", $subject->id(), PDO::PARAM_INT);
        try {
            $cur->execute();
            $res = $cur->fetchAll(PDO::FETCH_OBJ);
            if (!$res) {
                return [];
            } else {
                $role_ids = array_map(
                    function ($row) {
                        return $row->role_id;
                    },
                    $res
                );
                $roles = $this->roleFetchById($role_ids);
            }
        } catch (PDOException $db_err) {
            if ($this->logger) {
                $this->logger->error("Failed to fetch roles for subject", ['exception' => $db_err]);
            }
        }
        return $roles;
    }
431773
protected function _success(Subject $subject)
    {
        $subject->set(['success' => true, 'created' => true]);

        $this->_trigger('afterRegister', $subject);
        $this->setFlash('success', $subject);

        $redirectUrl = $this->config('redirectUrl');
        if ($redirectUrl === null && $this->_controller()->components()->has('Auth')) {
            $redirectUrl = $this->_controller()->Auth->config('loginAction');
        }

        return $this->_redirect($subject, $redirectUrl);
    }
833255
public function httpUrl($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        return $v === '' ? false : (
            strpos($v, 'http') === 0
            && !!filter_var('' . $v, FILTER_VALIDATE_URL)
        );
    }
192483
public function subject($subject) {

		if(false === is_string($subject)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($subject)), E_USER_ERROR);
		}

		$this -> subject = $subject;

		return $this;
	}
168563
public function message($to = '', $subject = '', $body = '')
    {
        $message = $this->transport->newMessage();

        if ($to) {
            $message->to($to);
        }
        if ($subject) {
            $message->subject($subject);
        }
        if ($body) {
            $message->body($body);
        }

        $message->setMailer($this);

        return $message;
    }
1174179
public function validate($subject): bool
    {
        if (\is_numeric($this->schema['exclusiveMinimum'])) {
            if ($subject <= $this->schema['exclusiveMinimum']) {
                return false;
            }
        }
        return true;
    }
471167
private function translateSubject($subject, array $subjectParams)
    {
        foreach ($subjectParams as &$param) {
            $param = $this->translator->trans($param);
        }

        unset($param);

        return $this->translator->trans($subject, $subjectParams);
    }
500405
public function match($pattern, $subject)
    {
        if (! $this->validate($pattern)) {
            return false;
        }
        
        return $this->getInstance()->match($pattern, $subject);
    }
1100753
public function create_message($userName, $subject, $textBody, $action = null, $pmId = null)
    {
        try {
            $manager = $this->container->get('symbb.extension.tapatalk.manager.user');
            return $manager->createMessage($userName, $subject, $textBody, $action, $pmId);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc);
        }
    }
126985
public function trackUse($string, $subject)
    {
        $id = $this->resolveUserID($subject);

        // If the subject is invalid return false
        if (!$id) {
            return false;
        }

        if (!is_string($string)) {
            throw new \InvalidArgumentException(t('Invalid mixed value provided. Must be a string.'));
        }

        if ($this->maxReuse) {
            // Store the use in the database
            $this->entityManager->transactional(function (EntityManagerInterface $em) use ($id, $string) {
                $reuse = new UsedString();
                $reuse->setDate(Carbon::now());
                $reuse->setSubject($id);
                $reuse->setUsedString(password_hash($string, PASSWORD_DEFAULT));

                $em->persist($reuse);
            });
        }

        // Prune extra tracked uses
        $this->pruneUses($id);

        return true;
    }
742563
private function resolveUserID($subject)
    {
        // Handle `null`, `0`, and any other falsy subject
        if (!$subject) {
            return 0;
        }

        // If an integer is just passed in
        if (is_numeric($subject)) {
            return (int)$subject;
        }

        // If we get an actual user instance
        if ($subject instanceof User || $subject instanceof UserInfo || $subject instanceof EntityUser) {
            return $subject->getUserID();
        }

        // Non-falsy subject that is unsupported
        throw new \InvalidArgumentException(t('Unsupported subject provided. Subject must be a User, UserInfo, or User Entity object.'));
    }
1096952
public function transferRoles(User $from, User $to)
    {
        $roles = $from->getEntityRoles();

        foreach ($roles as $role) {
            $to->addRole($role);
        }

        $this->objectManager->flush();

        return count($roles);
    }
519083
public function createMessage($subject = null, $body = null, $contentType = null, $charset = null)
    {
        $message = Swift_Message::newInstance($subject, $body, $contentType, $charset);

        if(null !== $this->fromEmail) {
            
            if(null === $this->fromName) {
                $message->setFrom($this->fromEmail);
            } else {
                $message->setFrom($this->fromEmail, $this->fromName);
            }
            
        }

        return $message;
    }