ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.Service.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\News;
22
25
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
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}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
user()
Get the current user.
Definition: Container.php:71
ilNewsObjectAdapter $obj_adapter
data()
Internal service, do not use in other components.
item(\ilNewsContext $context)
Get a new news item for a context.
__construct(Container $DIC)
contextForRefId(int $ref_id, int $subid=0, string $subtype="")
Get context object for news.
const NEWS_NOTICE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A news item can be created by different sources.
$ref_id
Definition: ltiauth.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$context
Definition: webdav.php:31