Compare commits
1 Commits
v1.15.0
...
enh/flow-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ef5f8edd0 |
@@ -45,6 +45,8 @@ use OCA\Deck\Service\FullTextSearchService;
|
||||
use OCA\Deck\Service\PermissionService;
|
||||
use OCA\Deck\Sharing\DeckShareProvider;
|
||||
use OCA\Deck\Sharing\Listener;
|
||||
use OCA\Deck\Listeners\RegisterChecksListener;
|
||||
use OCA\Deck\Listeners\RegisterEntityListener;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
@@ -66,6 +68,8 @@ use OCP\IUserManager;
|
||||
use OCP\Notification\IManager as NotificationManager;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Util;
|
||||
use OCP\WorkflowEngine\Events\RegisterChecksEvent;
|
||||
use OCP\WorkflowEngine\Events\RegisterEntitiesEvent;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class Application20 extends App implements IBootstrap {
|
||||
@@ -127,6 +131,9 @@ class Application20 extends App implements IBootstrap {
|
||||
$context->registerDashboardWidget(DeckWidget::class);
|
||||
|
||||
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
|
||||
|
||||
$context->registerEventListener(RegisterEntitiesEvent::class, RegisterEntityListener::class);
|
||||
//$context->registerEventListener(RegisterChecksEvent::class, RegisterChecksListener::class);
|
||||
}
|
||||
|
||||
public function registerNotifications(NotificationManager $notificationManager): void {
|
||||
|
||||
43
lib/Event/CardCreatedEvent.php
Normal file
43
lib/Event/CardCreatedEvent.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace OCA\Deck\Event;
|
||||
|
||||
use OCA\Deck\Db\Card;
|
||||
|
||||
class CardCreatedEvent extends \OCP\EventDispatcher\Event {
|
||||
|
||||
/** @var Card */
|
||||
private $card;
|
||||
|
||||
public function __construct(Card $card) {
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
public function getCard(): Card {
|
||||
return $this->card;
|
||||
}
|
||||
}
|
||||
107
lib/Flow/CardEntity.php
Normal file
107
lib/Flow/CardEntity.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace OCA\Deck\Flow;
|
||||
|
||||
use OCA\Deck\Event\CardCreatedEvent;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\WorkflowEngine\EntityContext\IDisplayName;
|
||||
use OCP\WorkflowEngine\EntityContext\IDisplayText;
|
||||
use OCP\WorkflowEngine\EntityContext\IUrl;
|
||||
use OCP\WorkflowEngine\IEntity;
|
||||
use OCP\WorkflowEngine\IRuleMatcher;
|
||||
|
||||
class CardEntity implements IEntity, IDisplayText, IDisplayName, IUrl {
|
||||
|
||||
/**
|
||||
* @var IL10N
|
||||
*/
|
||||
private $l10n;
|
||||
/**
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
|
||||
private $card;
|
||||
|
||||
public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
|
||||
$this->l10n = $l;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string {
|
||||
return $this->l10n->t('Deck card');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->imagePath('deck', 'deck-dark.svg');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getEvents(): array {
|
||||
return [new CardEntityCreatedEvent($this->l10n)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, Event $event): void {
|
||||
if(!$event instanceof CardCreatedEvent) {
|
||||
return;
|
||||
}
|
||||
/** @var CardCreatedEvent $event */
|
||||
$ruleMatcher->setEntitySubject($this, $event->getCard());
|
||||
$this->card = $event->getCard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isLegitimatedForUserId(string $userId): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDisplayName(): string {
|
||||
return $this->card->getTitle();
|
||||
}
|
||||
|
||||
public function getDisplayText(int $verbosity = 0): string {
|
||||
return $this->card->getTitle() . PHP_EOL . $this->card->getDescription();
|
||||
}
|
||||
|
||||
public function getUrl(): string {
|
||||
return $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . '#' . '/board/1/card/' . $this->card->getId();
|
||||
}
|
||||
}
|
||||
48
lib/Flow/CardEntityCreatedEvent.php
Normal file
48
lib/Flow/CardEntityCreatedEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace OCA\Deck\Flow;
|
||||
|
||||
use OCA\Deck\Event\CardCreatedEvent;
|
||||
use OCP\IL10N;
|
||||
use OCP\WorkflowEngine\IEntityEvent;
|
||||
|
||||
class CardEntityCreatedEvent implements IEntityEvent {
|
||||
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
public function __construct(IL10N $l10n) {
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
public function getDisplayName(): string {
|
||||
return $this->l10n->t('Card created');
|
||||
}
|
||||
|
||||
public function getEventName(): string {
|
||||
return CardCreatedEvent::class;
|
||||
}
|
||||
}
|
||||
51
lib/Listeners/RegisterChecksListener.php
Normal file
51
lib/Listeners/RegisterChecksListener.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Listeners;
|
||||
|
||||
use OCA\FlowWebhooks\AppInfo\Application;
|
||||
use OCA\FlowWebhooks\Flow\ParameterCheck;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Util;
|
||||
use OCP\WorkflowEngine\Events\RegisterChecksEvent;
|
||||
|
||||
class RegisterChecksListener implements IEventListener {
|
||||
|
||||
/** @var ParameterCheck */
|
||||
private $parameterCheck;
|
||||
|
||||
public function __construct(ParameterCheck $parameterCheck) {
|
||||
$this->parameterCheck = $parameterCheck;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof RegisterChecksEvent)) {
|
||||
return;
|
||||
}
|
||||
$event->registerCheck($this->parameterCheck);
|
||||
|
||||
Util::addScript(Application::APP_ID, Application::APP_ID);
|
||||
}
|
||||
}
|
||||
47
lib/Listeners/RegisterEntityListener.php
Normal file
47
lib/Listeners/RegisterEntityListener.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Listeners;
|
||||
|
||||
use OCA\Deck\Flow\CardEntity;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\WorkflowEngine\Events\RegisterEntitiesEvent;
|
||||
|
||||
class RegisterEntityListener implements IEventListener {
|
||||
|
||||
/** @var CardEntity */
|
||||
private $cardEntity;
|
||||
|
||||
public function __construct(CardEntity $cardEntity) {
|
||||
$this->cardEntity = $cardEntity;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if(!$event instanceof RegisterEntitiesEvent) {
|
||||
return;
|
||||
}
|
||||
$event->registerEntity($this->cardEntity);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Event\CardCreatedEvent;
|
||||
use OCA\Deck\Event\FTSEvent;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
@@ -224,7 +225,8 @@ class CardService {
|
||||
$card = $this->cardMapper->insert($card);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
||||
$this->changeHelper->cardChanged($card->getId(), false);
|
||||
|
||||
$this->eventDispatcher->dispatchTyped(new CardCreatedEvent($card));
|
||||
|
||||
$this->eventDispatcher->dispatch(
|
||||
'\OCA\Deck\Card::onCreate',
|
||||
new FTSEvent(
|
||||
|
||||
Reference in New Issue
Block a user