ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 }
$context
Definition: webdav.php:25
Wraps ilObject dependencies.
getObjId()
Get Obj Id.
News data.
item(ilNewsContext $context)
Get a new news item for a context.
__construct(ilLanguage $lng, ilSetting $settings, ilObjUser $user, ilNewsObjectAdapterInterface $obj_adapter=null)
Constructor.
News service.
getSubId()
Get Sub Obj Id.
$lng
const NEWS_NOTICE
getObjType()
Get Obj Type.
$user
Definition: migrateto20.php:57
contextForRefId(int $ref_id, int $subid=0, string $subtype="")
Get context object for news.
language handling
getSubType()
Get Sub Obj Type.