ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilNewsService.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $_deps;
17
22 public function __construct(ilLanguage $lng, ilSetting $settings, ilObjUser $user, ilNewsObjectAdapterInterface $obj_adapter = null)
23 {
24 if (is_null($obj_adapter)) {
25 $obj_adapter = new ilNewsObjectAdapter();
26 }
27 $this->_deps = new ilNewsServiceDependencies($lng, $settings, $user, $obj_adapter);
28 }
29
33 public function data() : ilNewsData
34 {
35 return new ilNewsData($this, $this->_deps);
36 }
37
45 {
46 $news = new ilNewsItem();
47 $news->setContext($context->getObjId(), $context->getObjType(), $context->getSubId(), $context->getSubType());
48 $news->setPriority(NEWS_NOTICE);
49 $news->setUserId($this->_deps->user()->getId());
50 return $news;
51 }
52
61 public function contextForRefId(int $ref_id, int $subid = 0, string $subtype = "") : ilNewsContext
62 {
63 $obj_id = $this->_deps->obj()->getObjIdForRefId($ref_id);
64 $obj_type = $this->_deps->obj()->getTypeForObjId($obj_id);
65 return new ilNewsContext($obj_id, $obj_type, $subid, $subtype);
66 }
67}
An exception for terminatinating execution or to throw for unit testing.
const NEWS_NOTICE
language handling
News data.
Wraps ilObject dependencies.
__construct(ilLanguage $lng, ilSetting $settings, ilObjUser $user, ilNewsObjectAdapterInterface $obj_adapter=null)
Constructor.
contextForRefId(int $ref_id, int $subid=0, string $subtype="")
Get context object for news.
item(ilNewsContext $context)
Get a new news item for a context.
ILIAS Setting Class.
$lng
$context
Definition: webdav.php:26