-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vitor Mattos <vitor@php.rio>
- Loading branch information
1 parent
f2b6934
commit ccd5bce
Showing
9 changed files
with
173 additions
and
28 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,32 @@ | ||
## Implement import | ||
|
||
* Create a new class `lib/Service/Importer/Systems/<ImportName>Service.php` where `<ImportName>` is the name of the source system. | ||
* Create a new importer class extending `ABoardImportService` | ||
* Create a listener for event `BoardImportGetAllowedEvent` to enable your importer. | ||
> You can read more about listeners on [Nextcloud](https://docs.nextcloud.com/server/latest/developer_manual/basics/events.html?highlight=event#writing-a-listener) doc. | ||
Example: | ||
|
||
```php | ||
class YourCustomImporterListener { | ||
public function handle(Event $event): void { | ||
if (!($event instanceof BoardImportGetAllowedEvent)) { | ||
return; | ||
} | ||
|
||
$event->getService()->addAllowedImportSystem([ | ||
'name' => YourCustomImporterService::$name, | ||
'class' => YourCustomImporterService::class, | ||
'internalName' => 'YourCustomImporter' | ||
]); | ||
} | ||
} | ||
``` | ||
* Register your listener on your `Application` class like this: | ||
```php | ||
$dispatcher = $this->getContainer()->query(IEventDispatcher::class); | ||
$dispatcher->registerEventListener( | ||
BoardImportGetAllowedEvent::class, | ||
YourCustomImporterListener::class | ||
); | ||
``` | ||
* Use the `lib/Service/Importer/Systems/TrelloJsonService.php` class as inspiration |
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,44 @@ | ||
<?php | ||
/* | ||
* @copyright Copyright (c) 2021 Vitor Mattos <vitor@php.rio> | ||
* | ||
* @author Vitor Mattos <vitor@php.rio> | ||
* | ||
* @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\Service\Importer\BoardImportService; | ||
use OCP\EventDispatcher\Event; | ||
|
||
abstract class ABoardImportGetAllowedEvent extends Event { | ||
private $service; | ||
|
||
public function __construct(BoardImportService $service) { | ||
parent::__construct(); | ||
|
||
$this->service = $service; | ||
} | ||
|
||
public function getService(): BoardImportService { | ||
return $this->service; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
/* | ||
* @copyright Copyright (c) 2021 Vitor Mattos <vitor@php.rio> | ||
* | ||
* @author Vitor Mattos <vitor@php.rio> | ||
* | ||
* @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; | ||
|
||
class BoardImportGetAllowedEvent extends ABoardImportGetAllowedEvent { | ||
} |
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