ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.NewsItemManager.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\News\Items;
20 
24 
30 {
34 
35  public function __construct(
36  InternalDataService $data,
37  InternalRepoService $repo,
38  InternalDomainService $domain
39  ) {
40  $this->repo = $repo;
41  $this->data = $data;
42  $this->domain = $domain;
43  }
44 
48  public function save(\ilNewsItem $news_item): int
49  {
50  if ($news_item->getId() > 0) {
51  $news_item->update(true);
52  } else {
53  $news_item->create();
54  }
55  return $news_item->getId();
56  }
57 
64  public function getNewsOfContext(\ilNewsContext $context): array
65  {
66  return \ilNewsItem::getNewsOfContext(
67  $context->getObjId(),
68  $context->getObjType(),
69  $context->getSubId(),
70  $context->getSubType()
71  );
72  }
73 
78  public function delete(\ilNewsItem $news_item): void
79  {
80  $news_item->delete();
81  }
82 }
update(bool $a_as_new=false)
Update item in database.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$context
Definition: webdav.php:31
getNewsOfContext(\ilNewsContext $context)
Get news of context.
__construct(InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain)
A news item can be created by different sources.
create()
Create.
save(\ilNewsItem $news_item)
Save news item.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Repository internal data service.