Code style fixes and cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
bc36cc808f
commit
9a2694fcb0
|
@ -7,7 +7,7 @@ use OCP\DirectEditing\IManager;
|
|||
|
||||
class CleanupDirectEditingTokens extends TimedJob {
|
||||
|
||||
const INTERVAL_MINUTES = 15 * 60;
|
||||
private const INTERVAL_MINUTES = 15 * 60;
|
||||
|
||||
/**
|
||||
* @var IManager
|
||||
|
|
|
@ -30,6 +30,8 @@ use OCP\Capabilities\ICapability;
|
|||
use OCP\DirectEditing\ACreateEmpty;
|
||||
use OCP\DirectEditing\ACreateFromTemplate;
|
||||
use OCP\DirectEditing\IEditor;
|
||||
use OCP\DirectEditing\RegisterDirectEditorEvent;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
|
||||
/**
|
||||
|
@ -38,17 +40,25 @@ use OCP\IConfig;
|
|||
* @package OCA\Files
|
||||
*/
|
||||
class Capabilities implements ICapability {
|
||||
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
|
||||
/** @var Manager */
|
||||
protected $directEditingManager;
|
||||
|
||||
/** @var IEventDispatcher */
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* Capabilities constructor.
|
||||
*
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(IConfig $config, Manager $manager) {
|
||||
public function __construct(IConfig $config, Manager $manager, IEventDispatcher $eventDispatcher) {
|
||||
$this->config = $config;
|
||||
$this->directEditingManager = $manager;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +76,9 @@ class Capabilities implements ICapability {
|
|||
];
|
||||
}
|
||||
|
||||
private function getDirectEditingCapabilitites() {
|
||||
private function getDirectEditingCapabilitites(): array {
|
||||
$this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
|
||||
$capabilities = [
|
||||
'editors' => [],
|
||||
'creators' => []
|
||||
|
|
|
@ -66,7 +66,7 @@ class DirectEditingController extends OCSController {
|
|||
* @NoAdminRequired
|
||||
*/
|
||||
public function create(string $path, string $editorId, string $creatorId, string $templateId = null): DataResponse {
|
||||
$this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
$this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
|
||||
try {
|
||||
$token = $this->directEditingManager->create($path, $editorId, $creatorId, $templateId);
|
||||
|
@ -83,7 +83,7 @@ class DirectEditingController extends OCSController {
|
|||
* @NoAdminRequired
|
||||
*/
|
||||
public function open(int $fileId, string $editorId = null): DataResponse {
|
||||
$this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
$this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
|
||||
try {
|
||||
$token = $this->directEditingManager->open($fileId, $editorId);
|
||||
|
@ -102,7 +102,7 @@ class DirectEditingController extends OCSController {
|
|||
* @NoAdminRequired
|
||||
*/
|
||||
public function templates(string $editorId, string $creatorId): DataResponse {
|
||||
$this->eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
$this->eventDispatcher->dispatchTyped(new RegisterDirectEditorEvent($this->directEditingManager));
|
||||
|
||||
try {
|
||||
return new DataResponse($this->directEditingManager->getTemplates($editorId, $creatorId));
|
||||
|
|
|
@ -50,7 +50,6 @@ class Version18000Date20191014105105 extends SimpleMigrationStep {
|
|||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
if (!$schema->hasTable('direct_edit')) {
|
||||
$table = $schema->createTable('direct_edit');
|
||||
|
||||
$table->addColumn('id', Type::BIGINT, [
|
||||
|
@ -87,7 +86,6 @@ class Version18000Date20191014105105 extends SimpleMigrationStep {
|
|||
|
||||
$table->setPrimaryKey(['id']);
|
||||
$table->addIndex(['token']);
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
|
|
@ -64,15 +64,12 @@ class Manager implements IManager {
|
|||
ISecureRandom $random,
|
||||
IDBConnection $connection,
|
||||
IUserSession $userSession,
|
||||
IRootFolder $rootFolder,
|
||||
IEventDispatcher $eventDispatcher
|
||||
IRootFolder $rootFolder
|
||||
) {
|
||||
$this->random = $random;
|
||||
$this->connection = $connection;
|
||||
$this->userId = $userSession->getUser() ? $userSession->getUser()->getUID() : null;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$eventDispatcher->dispatch(RegisterDirectEditorEvent::class, new RegisterDirectEditorEvent($this));
|
||||
|
||||
}
|
||||
|
||||
public function registerDirectEditor(IEditor $directEditor): void {
|
||||
|
|
|
@ -32,7 +32,7 @@ abstract class ACreateFromTemplate extends ACreateEmpty {
|
|||
* List of available templates for the create from template action
|
||||
*
|
||||
* @since 18.0.0
|
||||
* @return array
|
||||
* @return ATemplate[]
|
||||
*/
|
||||
abstract public function getTemplates(): array;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ interface IEditor {
|
|||
* A list of mimetypes that should open the editor by default
|
||||
*
|
||||
* @since 18.0.0
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMimetypes(): array;
|
||||
|
||||
|
@ -64,7 +64,7 @@ interface IEditor {
|
|||
* A list of mimetypes that can be opened in the editor optionally
|
||||
*
|
||||
* @since 18.0.0
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMimetypesOptional(): array;
|
||||
|
||||
|
@ -72,7 +72,7 @@ interface IEditor {
|
|||
* Return a list of file creation options to be presented to the user
|
||||
*
|
||||
* @since 18.0.0
|
||||
* @return array of ICreateFromTemplate|ICreateEmpty
|
||||
* @return ACreateFromTemplate[]|ACreateEmpty[]
|
||||
*/
|
||||
public function getCreators(): array;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ use OC\Files\Node\File;
|
|||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\DirectEditing\ACreateEmpty;
|
||||
use OCP\DirectEditing\IEditor;
|
||||
use OCP\DirectEditing\IToken;
|
||||
|
@ -16,6 +15,7 @@ use OCP\Files\IRootFolder;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class CreateEmpty extends ACreateEmpty {
|
||||
|
@ -82,9 +82,25 @@ class ManagerTest extends TestCase {
|
|||
*/
|
||||
private $editor;
|
||||
/**
|
||||
* @var \PHPUnit\Framework\MockObject\MockObject
|
||||
* @var MockObject|ISecureRandom
|
||||
*/
|
||||
private $random;
|
||||
/**
|
||||
* @var IDBConnection
|
||||
*/
|
||||
private $connection;
|
||||
/**
|
||||
* @var MockObject|IUserSession
|
||||
*/
|
||||
private $userSession;
|
||||
/**
|
||||
* @var MockObject|IRootFolder
|
||||
*/
|
||||
private $rootFolder;
|
||||
/**
|
||||
* @var MockObject|Folder
|
||||
*/
|
||||
private $userFolder;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
|
Loading…
Reference in New Issue