ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.Service.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\News;
22 
25 
29 class Service
30 {
31  protected \ilObjUser $user;
32  protected \ilNewsObjectAdapter $obj_adapter;
33  protected Container $DIC;
34 
35  public function __construct(Container $DIC)
36  {
37  $this->DIC = $DIC;
38  $this->obj_adapter = new \ilNewsObjectAdapter();
39  $this->user = $DIC->user();
40  }
41 
45  public function internal(): InternalService
46  {
47  return new InternalService($this->DIC);
48  }
49 
50  public function data(): NewsItemManager
51  {
52  $i = $this->internal();
53  return new NewsItemManager(
54  $i->data(),
55  $i->repo(),
56  $i->domain()
57  );
58  }
59 
63  public function item(\ilNewsContext $context): \ilNewsItem
64  {
65  $news = new \ilNewsItem();
66  $news->setContext($context->getObjId(), $context->getObjType(), $context->getSubId(), $context->getSubType());
67  $news->setPriority(NEWS_NOTICE);
68  $news->setUserId($this->user->getId());
69  return $news;
70  }
71 
75  public function contextForRefId(
76  int $ref_id,
77  int $subid = 0,
78  string $subtype = ""
79  ): \ilNewsContext {
80  $obj_id = $this->obj_adapter->getObjIdForRefId($ref_id);
81  $obj_type = $this->obj_adapter->getTypeForObjId($obj_id);
82  return new \ilNewsContext($obj_id, $obj_type, $subid, $subtype);
83  }
84 
85  public function isGloballyActivated(): bool
86  {
87  return (bool) $this->DIC->settings()->get("block_activated_news");
88  }
89 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
contextForRefId(int $ref_id, int $subid=0, string $subtype="")
Get context object for news.
$context
Definition: webdav.php:31
Notes internal service.
item(\ilNewsContext $context)
Get a new news item for a context.
ilNewsObjectAdapter $obj_adapter
function data()
Internal service, do not use in other components.
$ref_id
Definition: ltiauth.php:65
const NEWS_NOTICE
A news item can be created by different sources.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $DIC)