-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2099 from studer-raimann/feature/6-0/plr-notifica…
…tions GlobalScreen: Scope Notifications
- Loading branch information
Showing
32 changed files
with
1,195 additions
and
4 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Services/BackgroundTasks/classes/Provider/BTNotificationProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php namespace ILIAS\BackgroundTasks\Provider; | ||
|
||
use ILIAS\GlobalScreen\Identification\IdentificationInterface; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractNotificationProvider; | ||
use ILIAS\GlobalScreen\Scope\Notification\Provider\NotificationProvider; | ||
|
||
/** | ||
* Class BTNotificationProvider | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class BTNotificationProvider extends AbstractNotificationProvider implements NotificationProvider | ||
{ | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getNotifications() : array | ||
{ | ||
$id = function (string $id) : IdentificationInterface { | ||
return $this->if->identifier($id); | ||
}; | ||
|
||
$factory = $this->globalScreen()->notifications()->factory(); | ||
|
||
$group = $factory->standardGroup($id('bg_bucket_group'))->withTitle("Some Notifications"); | ||
|
||
for ($x = 1; $x < 10; $x++) { | ||
$n = $factory->standard($id('bg_bucket_id_' . $x)) | ||
->withTitle("A Notification " . $x) | ||
->withSummary("with a super summary " . $x) | ||
->withAction("#"); | ||
|
||
$group->addNotification($n); | ||
} | ||
|
||
return [ | ||
$group, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/GlobalScreen/Scope/MetaBar/Collector/Renderer/NotificationCenterRenderer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php namespace ILIAS\GlobalScreen\Scope\MetaBar\Collector\Renderer; | ||
|
||
use ILIAS\GlobalScreen\Collector\Renderer\isSupportedTrait; | ||
use ILIAS\GlobalScreen\Scope\MetaBar\Factory\isItem; | ||
use ILIAS\GlobalScreen\Scope\MetaBar\Factory\NotificationCenter; | ||
use ILIAS\UI\Component\Component; | ||
|
||
/** | ||
* Class NotificationCenterRenderer | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class NotificationCenterRenderer implements MetaBarItemRenderer | ||
{ | ||
|
||
use isSupportedTrait; | ||
/** | ||
* @var \ILIAS\GlobalScreen\Services | ||
*/ | ||
private $ui; | ||
/** | ||
* @var \ILIAS\GlobalScreen\Services | ||
*/ | ||
private $gs; | ||
|
||
|
||
/** | ||
* BaseMetaBarItemRenderer constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
global $DIC; | ||
$this->ui = $DIC->ui(); | ||
$this->gs = $DIC->globalScreen(); | ||
} | ||
|
||
|
||
/** | ||
* @param NotificationCenter $item | ||
* | ||
* @return Component | ||
*/ | ||
public function getComponentForItem(isItem $item) : Component | ||
{ | ||
$f = $this->ui->factory(); | ||
|
||
$combined = $f->mainControls()->slate()->combined("Notification Center", $item->getSymbol()); | ||
|
||
foreach ($this->gs->collector()->notifications()->getNotifications() as $notification) { | ||
$component = $notification->getRenderer()->getComponentForItem($notification); | ||
if ($this->isComponentSupportedForCombinedSlate($component)) { | ||
$combined = $combined->withAdditionalEntry($component); | ||
} | ||
} | ||
|
||
return $combined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/GlobalScreen/Scope/MetaBar/Factory/NotificationCenter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php namespace ILIAS\GlobalScreen\Scope\MetaBar\Factory; | ||
|
||
use ILIAS\GlobalScreen\Identification\IdentificationInterface; | ||
use ILIAS\GlobalScreen\Scope\MetaBar\Collector\Renderer\NotificationCenterRenderer; | ||
use ILIAS\UI\Component\Symbol\Symbol; | ||
|
||
/** | ||
* Class NotificationCenter | ||
* | ||
* @author Fabian Schmid <[email protected]> | ||
*/ | ||
class NotificationCenter extends AbstractBaseItem implements isItem, hasSymbol | ||
{ | ||
|
||
/** | ||
* @var isItem[] | ||
*/ | ||
private $notifications = []; | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct(IdentificationInterface $provider_identification) | ||
{ | ||
parent::__construct($provider_identification); | ||
$this->renderer = new NotificationCenterRenderer(); | ||
} | ||
|
||
|
||
/** | ||
* @param isItem[] $notifications | ||
* | ||
* @return NotificationCenter | ||
*/ | ||
public function withNotifications(array $notifications) : NotificationCenter | ||
{ | ||
$this->notifications = $notifications; | ||
|
||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @return isItem[] | ||
*/ | ||
public function getNotifications() : array | ||
{ | ||
return $this->notifications; | ||
} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function withSymbol(Symbol $symbol) : hasSymbol | ||
{ | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function hasSymbol() : bool | ||
{ | ||
return true; | ||
} | ||
|
||
|
||
/** | ||
* @return Symbol | ||
*/ | ||
public function getSymbol() : Symbol | ||
{ | ||
global $DIC; | ||
|
||
// TODO implement counter | ||
return $DIC->ui()->factory()->symbol()->glyph()->notification(); | ||
} | ||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPosition() : int | ||
{ | ||
return 1; | ||
} | ||
} |
Oops, something went wrong.