markAllAsRead

@param ComponentInterface $subject subject
@param string             $context The context
517829
public function markAllAsRead(ComponentInterface $subject, $context = "GLOBAL")
    {
        $options = array(
            'context' => $context,
            'type'    => 'notification',
        );

        $this->timelineManager->removeAll($subject, $options);
        $this->timelineManager->flush();
    }
811733
public function stickSubject(Subject $subject)
    {
        $this->om->startFlushSuite();
        $subject->setIsSticked(true);
        $this->om->persist($subject);
        $this->dispatch(new StickSubjectEvent($subject));
        $this->om->endFlushSuite();
    }
337320
public function setSubject($subject)
    {
        if ($subject === '') {
            throw new \InvalidArgumentException('$subject must not be empty.', 1331488802);
        }

        if ((strpos($subject, CR) !== false) || (strpos($subject, LF) !== false)) {
            throw new \InvalidArgumentException(
                '$subject must not contain any line breaks or carriage returns.',
                1331488817
            );
        }

        $this->setAsString('subject', $subject);
    }
647605
public function update(\SplSubject $subject)
    {
        if ($subject->getAction() === 'ctrlRouterLink_exec_execRoute') {
            $this->obtainCtrlRouterInfos($subject);
            
            if (
                $this->ctrlRouterInfos->isFound === true &&
                $this->ctrlRouterInfos->forWho === $this->execRouteSystemName
            ) {
                $this->run();
            }
        }
    }
674960
private function useReflectionToGetMessage($subject)
    {
        $reflection = new \ReflectionClass($subject);
        $property   = $reflection->getProperty('_message');
        $property->setAccessible(true);
        $message = $property->getValue($subject);

        return $message;
    }
1058983
protected static function _setCache($from, $subject, $value) {
		$cache = &static::_getCache($from, $subject);
		$cache = $value;
	}
367786
public function setAutoReply($emailFieldName, $text, $subject = NULL) {
    $this->autoReply = (object) array(
      'emailField'=>$emailFieldName,
      'subject'=>$subject,
      'text'=>$text
    );
  }
1077325
protected function _validate($subject)
    {
        $errors = $this->_getValidationErrors($subject);

        if (!$this->_countIterable($errors)) {
            return;
        }

        throw $this->_throwValidationFailedException($this->__('Validation failed'), null, null, true, $subject, $errors);
    }
906890
public function getUnreadNotifications(ComponentInterface $subject, $context = "GLOBAL", array $options = array())
    {
        $options['context'] = $context;
        $options['type']    = 'notification';

        return $this->timelineManager->getTimeline($subject, $options);
    }
1015406
public static function mark_message_as_read($userid, $message, $timeread = null) {
        global $DB;

        if (is_null($timeread)) {
            $timeread = time();
        }

        $mua = new \stdClass();
        $mua->userid = $userid;
        $mua->messageid = $message->id;
        $mua->action = self::MESSAGE_ACTION_READ;
        $mua->timecreated = $timeread;
        $mua->id = $DB->insert_record('message_user_actions', $mua);

        // Get the context for the user who received the message.
        $context = \context_user::instance($userid, IGNORE_MISSING);
        // If the user no longer exists the context value will be false, in this case use the system context.
        if ($context === false) {
            $context = \context_system::instance();
        }

        // Trigger event for reading a message.
        $event = \core\event\message_viewed::create(array(
            'objectid' => $mua->id,
            'userid' => $userid, // Using the user who read the message as they are the ones performing the action.
            'context' => $context,
            'relateduserid' => $message->useridfrom,
            'other' => array(
                'messageid' => $message->id
            )
        ));
        $event->trigger();
    }
179200
protected function _stopped(Subject $subject)
    {
        $subject->set(['success' => false]);
        $this->setFlash('error', $subject);

        return $this->_redirect($subject, ['action' => 'index']);
    }
589905
public function findBySubject(ContentSubjectInterface $subject)
    {
        $content = $subject->getContent();

        if (null !== $content && property_exists($content, '__isInitialized__') && !$content->{'__isInitialized__'}) {
            $qb = $this->getQueryBuilder();
            $qb
                ->leftJoin('c.containers', 'container')
                ->leftJoin('container.rows', 'row')
                ->leftJoin('row.blocks', 'block')
                ->leftJoin('block.translations', 'block_t')
                ->select('PARTIAL c.{id}', 'container', 'row', 'block', 'block_t')
                ->andWhere($qb->expr()->eq('c.id', ':id'))
                ->getQuery()
                ->useQueryCache(true)
                // TODO ->useResultCache(true, 3600, Content::getEntityTagPrefix() . '[id:'.$id.']')
                ->setParameter('id', $content->getId())
                ->getOneOrNullResult();
        }

        return $content;
    }
28148
protected function callChildComponent($component, IContext $context)
    {
        /**
         * @var IRouter $router
         */
        $router = $component->getRouter();
        $router->setBaseUrl($context->getRouteResult()->getMatchedUrl());

        $componentRequest = $this->createComponentRequest($context->getRouteResult()->getUnmatchedUrl());

        try {
            return $component->execute($componentRequest);
        } catch (\Exception $e) {
            return $this->callErrorController($e, $context);
        }
    }
64972
public function closeSubject(Subject $subject)
    {
        $this->om->startFlushSuite();
        $subject->setIsClosed(true);
        $this->om->persist($subject);
        $this->dispatch(new CloseSubjectEvent($subject));
        $this->om->endFlushSuite();
    }
716792
public function unstickSubject(Subject $subject)
    {
        $this->om->startFlushSuite();
        $subject->setIsSticked(false);
        $this->om->persist($subject);
        $this->dispatch(new UnstickSubjectEvent($subject));
        $this->om->endFlushSuite();
    }
150308
public function update(SubjectInterface $subject)
   {
       if ($subject instanceof ModelInterface) {
           foreach (json_decode(json_encode($subject)) as $key => $value) {
               $this->appendValueTo($this->template, $key, $value);
           }
           return $subject;
       }
   }
1204995
public function mailInvoice(AnCommandContext $context)
    {
        if ($this->getItem()) {

            $mails[] = array(
                'to' => $this->getItem()->person->email,
                'subject' => AnTranslator::_('COM-SUBSCRIPTIONS-CONFIRMATION-MESSAGE-SUBJECT'),
                'template' => 'invoice',
            );

            $this->mail($mails);
        }
    }