diff options
author | Joas Schilling <coding@schilljs.com> | 2019-01-17 14:40:02 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-20 14:17:33 +0300 |
commit | c0e34c872902c2b324656dcc3d00c9fc60eced1d (patch) | |
tree | 09e842fca8d00ade88c7482a12cda36627d33ffa /lib/Controller | |
parent | bea75cf69834abdb01cc78db5ebaaea3da9b64de (diff) |
Start with commands
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/CommandController.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/Controller/CommandController.php b/lib/Controller/CommandController.php new file mode 100644 index 000000000..793010999 --- /dev/null +++ b/lib/Controller/CommandController.php @@ -0,0 +1,72 @@ +<?php +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @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\Spreed\Controller; + +use OCA\Spreed\Exceptions\ParticipantNotFoundException; +use OCA\Spreed\Exceptions\RoomNotFoundException; +use OCA\Spreed\Manager; +use OCA\Spreed\Model\CommandMapper; +use OCA\Spreed\Participant; +use OCA\Spreed\TalkSession; +use OCP\AppFramework\Http; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\OCSController; +use OCP\IRequest; + +class CommandController extends OCSController { + /** @var CommandMapper */ + protected $commandMapper; + + /** + * @param string $appName + * @param IRequest $request + * @param CommandMapper $commandMapper + */ + public function __construct($appName, + IRequest $request, + CommandMapper $commandMapper) { + parent::__construct($appName, $request); + $this->commandMapper = $commandMapper; + } + + /** + * @return DataResponse + */ + public function getAll(): DataResponse { + $commands = $this->commandMapper->findAll(); + + $result = []; + foreach ($commands as $command) { + $result[] = [ + 'id' => $command->getId(), + 'pattern' => $command->getPattern(), + 'script' => $command->getScript(), + 'output' => $command->getOutput(), + ]; + } + + return new DataResponse($result); + } + +} |