@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $data = [ |
| 77 | 77 | 'user_id' => $user->getUID(), |
| 78 | 78 | 'display_name' => $user->getDisplayName(), |
| 79 | - 'email' => (string)$user->getSystemEMailAddress(), |
|
| 79 | + 'email' => (string) $user->getSystemEMailAddress(), |
|
| 80 | 80 | 'cloud_id' => $user->getCloudId(), |
| 81 | 81 | 'enabled' => $user->isEnabled(), |
| 82 | 82 | 'groups' => $groups, |
@@ -19,96 +19,96 @@ |
||
| 19 | 19 | use Symfony\Component\Console\Output\OutputInterface; |
| 20 | 20 | |
| 21 | 21 | class Info extends Base { |
| 22 | - public function __construct( |
|
| 23 | - protected IUserManager $userManager, |
|
| 24 | - protected IGroupManager $groupManager, |
|
| 25 | - protected SetupManager $setupManager, |
|
| 26 | - ) { |
|
| 27 | - parent::__construct(); |
|
| 28 | - } |
|
| 22 | + public function __construct( |
|
| 23 | + protected IUserManager $userManager, |
|
| 24 | + protected IGroupManager $groupManager, |
|
| 25 | + protected SetupManager $setupManager, |
|
| 26 | + ) { |
|
| 27 | + parent::__construct(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - protected function configure() { |
|
| 31 | - $this |
|
| 32 | - ->setName('user:info') |
|
| 33 | - ->setDescription('show user info') |
|
| 34 | - ->addArgument( |
|
| 35 | - 'user', |
|
| 36 | - InputArgument::REQUIRED, |
|
| 37 | - 'user to show' |
|
| 38 | - )->addOption( |
|
| 39 | - 'output', |
|
| 40 | - null, |
|
| 41 | - InputOption::VALUE_OPTIONAL, |
|
| 42 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
| 43 | - $this->defaultOutputFormat |
|
| 44 | - ); |
|
| 45 | - } |
|
| 30 | + protected function configure() { |
|
| 31 | + $this |
|
| 32 | + ->setName('user:info') |
|
| 33 | + ->setDescription('show user info') |
|
| 34 | + ->addArgument( |
|
| 35 | + 'user', |
|
| 36 | + InputArgument::REQUIRED, |
|
| 37 | + 'user to show' |
|
| 38 | + )->addOption( |
|
| 39 | + 'output', |
|
| 40 | + null, |
|
| 41 | + InputOption::VALUE_OPTIONAL, |
|
| 42 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
| 43 | + $this->defaultOutputFormat |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 48 | - $user = $this->userManager->get($input->getArgument('user')); |
|
| 49 | - if (is_null($user)) { |
|
| 50 | - $output->writeln('<error>user not found</error>'); |
|
| 51 | - return 1; |
|
| 52 | - } |
|
| 53 | - $groups = $this->groupManager->getUserGroupIds($user); |
|
| 54 | - $data = [ |
|
| 55 | - 'user_id' => $user->getUID(), |
|
| 56 | - 'display_name' => $user->getDisplayName(), |
|
| 57 | - 'email' => (string)$user->getSystemEMailAddress(), |
|
| 58 | - 'cloud_id' => $user->getCloudId(), |
|
| 59 | - 'enabled' => $user->isEnabled(), |
|
| 60 | - 'groups' => $groups, |
|
| 61 | - 'quota' => $user->getQuota(), |
|
| 62 | - 'storage' => $this->getStorageInfo($user), |
|
| 63 | - 'first_seen' => $this->formatLoginDate($user->getFirstLogin()), |
|
| 64 | - 'last_seen' => $this->formatLoginDate($user->getLastLogin()), |
|
| 65 | - 'user_directory' => $user->getHome(), |
|
| 66 | - 'backend' => $user->getBackendClassName() |
|
| 67 | - ]; |
|
| 68 | - $this->writeArrayInOutputFormat($input, $output, $data); |
|
| 69 | - return 0; |
|
| 70 | - } |
|
| 47 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 48 | + $user = $this->userManager->get($input->getArgument('user')); |
|
| 49 | + if (is_null($user)) { |
|
| 50 | + $output->writeln('<error>user not found</error>'); |
|
| 51 | + return 1; |
|
| 52 | + } |
|
| 53 | + $groups = $this->groupManager->getUserGroupIds($user); |
|
| 54 | + $data = [ |
|
| 55 | + 'user_id' => $user->getUID(), |
|
| 56 | + 'display_name' => $user->getDisplayName(), |
|
| 57 | + 'email' => (string)$user->getSystemEMailAddress(), |
|
| 58 | + 'cloud_id' => $user->getCloudId(), |
|
| 59 | + 'enabled' => $user->isEnabled(), |
|
| 60 | + 'groups' => $groups, |
|
| 61 | + 'quota' => $user->getQuota(), |
|
| 62 | + 'storage' => $this->getStorageInfo($user), |
|
| 63 | + 'first_seen' => $this->formatLoginDate($user->getFirstLogin()), |
|
| 64 | + 'last_seen' => $this->formatLoginDate($user->getLastLogin()), |
|
| 65 | + 'user_directory' => $user->getHome(), |
|
| 66 | + 'backend' => $user->getBackendClassName() |
|
| 67 | + ]; |
|
| 68 | + $this->writeArrayInOutputFormat($input, $output, $data); |
|
| 69 | + return 0; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - private function formatLoginDate(int $timestamp): string { |
|
| 73 | - if ($timestamp < 0) { |
|
| 74 | - return 'unknown'; |
|
| 75 | - } elseif ($timestamp === 0) { |
|
| 76 | - return 'never'; |
|
| 77 | - } else { |
|
| 78 | - return date(\DateTimeInterface::ATOM, $timestamp); // ISO-8601 |
|
| 79 | - } |
|
| 80 | - } |
|
| 72 | + private function formatLoginDate(int $timestamp): string { |
|
| 73 | + if ($timestamp < 0) { |
|
| 74 | + return 'unknown'; |
|
| 75 | + } elseif ($timestamp === 0) { |
|
| 76 | + return 'never'; |
|
| 77 | + } else { |
|
| 78 | + return date(\DateTimeInterface::ATOM, $timestamp); // ISO-8601 |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param IUser $user |
|
| 84 | - * @return array |
|
| 85 | - */ |
|
| 86 | - protected function getStorageInfo(IUser $user): array { |
|
| 87 | - $this->setupManager->tearDown(); |
|
| 88 | - $this->setupManager->setupForUser($user); |
|
| 89 | - try { |
|
| 90 | - $storage = \OC_Helper::getStorageInfo('/'); |
|
| 91 | - } catch (NotFoundException $e) { |
|
| 92 | - return []; |
|
| 93 | - } |
|
| 94 | - return [ |
|
| 95 | - 'free' => $storage['free'], |
|
| 96 | - 'used' => $storage['used'], |
|
| 97 | - 'total' => $storage['total'], |
|
| 98 | - 'relative' => $storage['relative'], |
|
| 99 | - 'quota' => $storage['quota'], |
|
| 100 | - ]; |
|
| 101 | - } |
|
| 82 | + /** |
|
| 83 | + * @param IUser $user |
|
| 84 | + * @return array |
|
| 85 | + */ |
|
| 86 | + protected function getStorageInfo(IUser $user): array { |
|
| 87 | + $this->setupManager->tearDown(); |
|
| 88 | + $this->setupManager->setupForUser($user); |
|
| 89 | + try { |
|
| 90 | + $storage = \OC_Helper::getStorageInfo('/'); |
|
| 91 | + } catch (NotFoundException $e) { |
|
| 92 | + return []; |
|
| 93 | + } |
|
| 94 | + return [ |
|
| 95 | + 'free' => $storage['free'], |
|
| 96 | + 'used' => $storage['used'], |
|
| 97 | + 'total' => $storage['total'], |
|
| 98 | + 'relative' => $storage['relative'], |
|
| 99 | + 'quota' => $storage['quota'], |
|
| 100 | + ]; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param string $argumentName |
|
| 105 | - * @param CompletionContext $context |
|
| 106 | - * @return string[] |
|
| 107 | - */ |
|
| 108 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 109 | - if ($argumentName === 'user') { |
|
| 110 | - return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord())); |
|
| 111 | - } |
|
| 112 | - return []; |
|
| 113 | - } |
|
| 103 | + /** |
|
| 104 | + * @param string $argumentName |
|
| 105 | + * @param CompletionContext $context |
|
| 106 | + * @return string[] |
|
| 107 | + */ |
|
| 108 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 109 | + if ($argumentName === 'user') { |
|
| 110 | + return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord())); |
|
| 111 | + } |
|
| 112 | + return []; |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | 'notnull' => true, |
| 61 | 61 | ]); |
| 62 | 62 | $table->setPrimaryKey(['id']); |
| 63 | - $table->addUniqueIndex(['user_id'], self::TABLE_NAME . '_user_id_idx'); |
|
| 63 | + $table->addUniqueIndex(['user_id'], self::TABLE_NAME.'_user_id_idx'); |
|
| 64 | 64 | return $schema; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -16,37 +16,37 @@ |
||
| 16 | 16 | use OCP\Migration\SimpleMigrationStep; |
| 17 | 17 | |
| 18 | 18 | class Version23000Date20210930122352 extends SimpleMigrationStep { |
| 19 | - private const TABLE_NAME = 'profile_config'; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @param IOutput $output |
|
| 23 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 24 | - * @param array $options |
|
| 25 | - * @return null|ISchemaWrapper |
|
| 26 | - */ |
|
| 27 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 28 | - /** @var ISchemaWrapper $schema */ |
|
| 29 | - $schema = $schemaClosure(); |
|
| 30 | - |
|
| 31 | - $hasTable = $schema->hasTable(self::TABLE_NAME); |
|
| 32 | - if (!$hasTable) { |
|
| 33 | - $table = $schema->createTable(self::TABLE_NAME); |
|
| 34 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 35 | - 'autoincrement' => true, |
|
| 36 | - 'notnull' => true, |
|
| 37 | - ]); |
|
| 38 | - $table->addColumn('user_id', Types::STRING, [ |
|
| 39 | - 'notnull' => true, |
|
| 40 | - 'length' => 64, |
|
| 41 | - ]); |
|
| 42 | - $table->addColumn('config', Types::TEXT, [ |
|
| 43 | - 'notnull' => true, |
|
| 44 | - ]); |
|
| 45 | - $table->setPrimaryKey(['id']); |
|
| 46 | - $table->addUniqueIndex(['user_id'], self::TABLE_NAME . '_user_id_idx'); |
|
| 47 | - return $schema; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - return null; |
|
| 51 | - } |
|
| 19 | + private const TABLE_NAME = 'profile_config'; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param IOutput $output |
|
| 23 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 24 | + * @param array $options |
|
| 25 | + * @return null|ISchemaWrapper |
|
| 26 | + */ |
|
| 27 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 28 | + /** @var ISchemaWrapper $schema */ |
|
| 29 | + $schema = $schemaClosure(); |
|
| 30 | + |
|
| 31 | + $hasTable = $schema->hasTable(self::TABLE_NAME); |
|
| 32 | + if (!$hasTable) { |
|
| 33 | + $table = $schema->createTable(self::TABLE_NAME); |
|
| 34 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 35 | + 'autoincrement' => true, |
|
| 36 | + 'notnull' => true, |
|
| 37 | + ]); |
|
| 38 | + $table->addColumn('user_id', Types::STRING, [ |
|
| 39 | + 'notnull' => true, |
|
| 40 | + 'length' => 64, |
|
| 41 | + ]); |
|
| 42 | + $table->addColumn('config', Types::TEXT, [ |
|
| 43 | + 'notnull' => true, |
|
| 44 | + ]); |
|
| 45 | + $table->setPrimaryKey(['id']); |
|
| 46 | + $table->addUniqueIndex(['user_id'], self::TABLE_NAME . '_user_id_idx'); |
|
| 47 | + return $schema; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + return null; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -32,23 +32,23 @@ |
||
| 32 | 32 | use OCP\Migration\SimpleMigrationStep; |
| 33 | 33 | |
| 34 | 34 | class Version23000Date20211203110726 extends SimpleMigrationStep { |
| 35 | - private const TABLE_NAME = 'profile_config'; |
|
| 35 | + private const TABLE_NAME = 'profile_config'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param IOutput $output |
|
| 39 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 40 | - * @param array $options |
|
| 41 | - * @return null|ISchemaWrapper |
|
| 42 | - */ |
|
| 43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 44 | - /** @var ISchemaWrapper $schema */ |
|
| 45 | - $schema = $schemaClosure(); |
|
| 37 | + /** |
|
| 38 | + * @param IOutput $output |
|
| 39 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 40 | + * @param array $options |
|
| 41 | + * @return null|ISchemaWrapper |
|
| 42 | + */ |
|
| 43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
| 44 | + /** @var ISchemaWrapper $schema */ |
|
| 45 | + $schema = $schemaClosure(); |
|
| 46 | 46 | |
| 47 | - $table = $schema->getTable(self::TABLE_NAME); |
|
| 48 | - if ($table->hasIndex('user_id')) { |
|
| 49 | - $table->renameIndex('user_id', self::TABLE_NAME . '_user_id_idx'); |
|
| 50 | - return $schema; |
|
| 51 | - } |
|
| 52 | - return null; |
|
| 53 | - } |
|
| 47 | + $table = $schema->getTable(self::TABLE_NAME); |
|
| 48 | + if ($table->hasIndex('user_id')) { |
|
| 49 | + $table->renameIndex('user_id', self::TABLE_NAME . '_user_id_idx'); |
|
| 50 | + return $schema; |
|
| 51 | + } |
|
| 52 | + return null; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | $table = $schema->getTable(self::TABLE_NAME); |
| 48 | 48 | if ($table->hasIndex('user_id')) { |
| 49 | - $table->renameIndex('user_id', self::TABLE_NAME . '_user_id_idx'); |
|
| 49 | + $table->renameIndex('user_id', self::TABLE_NAME.'_user_id_idx'); |
|
| 50 | 50 | return $schema; |
| 51 | 51 | } |
| 52 | 52 | return null; |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * Defines the public facing principal option |
| 32 | 32 | */ |
| 33 | 33 | class PublicPrincipalPlugin extends Plugin { |
| 34 | - public function getCurrentPrincipal(): ?string { |
|
| 35 | - return 'principals/system/public'; |
|
| 36 | - } |
|
| 34 | + public function getCurrentPrincipal(): ?string { |
|
| 35 | + return 'principals/system/public'; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | * Set a custom principal uri to allow public requests to its calendar |
| 33 | 33 | */ |
| 34 | 34 | class CustomPrincipalPlugin extends Plugin { |
| 35 | - public function setCurrentPrincipal(?string $currentPrincipal): void { |
|
| 36 | - $this->currentPrincipal = $currentPrincipal; |
|
| 37 | - } |
|
| 35 | + public function setCurrentPrincipal(?string $currentPrincipal): void { |
|
| 36 | + $this->currentPrincipal = $currentPrincipal; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | |
| 86 | 86 | public function getAuthorizedAppConfig(): array { |
| 87 | 87 | return [ |
| 88 | - 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/'] |
|
| 88 | + 'dav' => ['/('.implode('|', array_keys(self::defaults)).')/'] |
|
| 89 | 89 | ]; |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -17,62 +17,62 @@ |
||
| 17 | 17 | |
| 18 | 18 | class CalDAVSettings implements IDelegatedSettings { |
| 19 | 19 | |
| 20 | - private const defaults = [ |
|
| 21 | - 'sendInvitations' => 'yes', |
|
| 22 | - 'generateBirthdayCalendar' => 'yes', |
|
| 23 | - 'sendEventReminders' => 'yes', |
|
| 24 | - 'sendEventRemindersToSharedUsers' => 'yes', |
|
| 25 | - 'sendEventRemindersPush' => 'yes', |
|
| 26 | - ]; |
|
| 20 | + private const defaults = [ |
|
| 21 | + 'sendInvitations' => 'yes', |
|
| 22 | + 'generateBirthdayCalendar' => 'yes', |
|
| 23 | + 'sendEventReminders' => 'yes', |
|
| 24 | + 'sendEventRemindersToSharedUsers' => 'yes', |
|
| 25 | + 'sendEventRemindersPush' => 'yes', |
|
| 26 | + ]; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * CalDAVSettings constructor. |
|
| 30 | - * |
|
| 31 | - * @param IConfig $config |
|
| 32 | - * @param IInitialState $initialState |
|
| 33 | - */ |
|
| 34 | - public function __construct( |
|
| 35 | - private IConfig $config, |
|
| 36 | - private IInitialState $initialState, |
|
| 37 | - private IURLGenerator $urlGenerator, |
|
| 38 | - private IAppManager $appManager, |
|
| 39 | - ) { |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * CalDAVSettings constructor. |
|
| 30 | + * |
|
| 31 | + * @param IConfig $config |
|
| 32 | + * @param IInitialState $initialState |
|
| 33 | + */ |
|
| 34 | + public function __construct( |
|
| 35 | + private IConfig $config, |
|
| 36 | + private IInitialState $initialState, |
|
| 37 | + private IURLGenerator $urlGenerator, |
|
| 38 | + private IAppManager $appManager, |
|
| 39 | + ) { |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function getForm(): TemplateResponse { |
|
| 43 | - $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars')); |
|
| 44 | - foreach (self::defaults as $key => $default) { |
|
| 45 | - $value = $this->config->getAppValue(Application::APP_ID, $key, $default); |
|
| 46 | - $this->initialState->provideInitialState($key, $value === 'yes'); |
|
| 47 | - } |
|
| 42 | + public function getForm(): TemplateResponse { |
|
| 43 | + $this->initialState->provideInitialState('userSyncCalendarsDocUrl', $this->urlGenerator->linkToDocs('user-sync-calendars')); |
|
| 44 | + foreach (self::defaults as $key => $default) { |
|
| 45 | + $value = $this->config->getAppValue(Application::APP_ID, $key, $default); |
|
| 46 | + $this->initialState->provideInitialState($key, $value === 'yes'); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - Util::addScript(Application::APP_ID, 'settings-admin-caldav'); |
|
| 50 | - Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); |
|
| 51 | - return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); |
|
| 52 | - } |
|
| 49 | + Util::addScript(Application::APP_ID, 'settings-admin-caldav'); |
|
| 50 | + Util::addStyle(Application::APP_ID, 'settings-admin-caldav'); |
|
| 51 | + return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getSection(): ?string { |
|
| 55 | - if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) { |
|
| 56 | - return null; |
|
| 57 | - } |
|
| 54 | + public function getSection(): ?string { |
|
| 55 | + if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) { |
|
| 56 | + return null; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return 'groupware'; |
|
| 60 | - } |
|
| 59 | + return 'groupware'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return int |
|
| 64 | - */ |
|
| 65 | - public function getPriority() { |
|
| 66 | - return 10; |
|
| 67 | - } |
|
| 62 | + /** |
|
| 63 | + * @return int |
|
| 64 | + */ |
|
| 65 | + public function getPriority() { |
|
| 66 | + return 10; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public function getName(): ?string { |
|
| 70 | - return null; // Only setting in this section |
|
| 71 | - } |
|
| 69 | + public function getName(): ?string { |
|
| 70 | + return null; // Only setting in this section |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - public function getAuthorizedAppConfig(): array { |
|
| 74 | - return [ |
|
| 75 | - 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/'] |
|
| 76 | - ]; |
|
| 77 | - } |
|
| 73 | + public function getAuthorizedAppConfig(): array { |
|
| 74 | + return [ |
|
| 75 | + 'dav' => ['/(' . implode('|', array_keys(self::defaults)) . ')/'] |
|
| 76 | + ]; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -27,18 +27,18 @@ |
||
| 27 | 27 | namespace OCA\User_LDAP\PagedResults; |
| 28 | 28 | |
| 29 | 29 | trait TLinkId { |
| 30 | - public function getLinkId($link) { |
|
| 31 | - if (is_object($link)) { |
|
| 32 | - return spl_object_id($link); |
|
| 33 | - } elseif (is_resource($link)) { |
|
| 34 | - return (int)$link; |
|
| 35 | - } elseif (is_array($link) && isset($link[0])) { |
|
| 36 | - if (is_object($link[0])) { |
|
| 37 | - return spl_object_id($link[0]); |
|
| 38 | - } elseif (is_resource($link[0])) { |
|
| 39 | - return (int)$link[0]; |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - throw new \RuntimeException('No resource provided'); |
|
| 43 | - } |
|
| 30 | + public function getLinkId($link) { |
|
| 31 | + if (is_object($link)) { |
|
| 32 | + return spl_object_id($link); |
|
| 33 | + } elseif (is_resource($link)) { |
|
| 34 | + return (int)$link; |
|
| 35 | + } elseif (is_array($link) && isset($link[0])) { |
|
| 36 | + if (is_object($link[0])) { |
|
| 37 | + return spl_object_id($link[0]); |
|
| 38 | + } elseif (is_resource($link[0])) { |
|
| 39 | + return (int)$link[0]; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + throw new \RuntimeException('No resource provided'); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -31,12 +31,12 @@ |
||
| 31 | 31 | if (is_object($link)) { |
| 32 | 32 | return spl_object_id($link); |
| 33 | 33 | } elseif (is_resource($link)) { |
| 34 | - return (int)$link; |
|
| 34 | + return (int) $link; |
|
| 35 | 35 | } elseif (is_array($link) && isset($link[0])) { |
| 36 | 36 | if (is_object($link[0])) { |
| 37 | 37 | return spl_object_id($link[0]); |
| 38 | 38 | } elseif (is_resource($link[0])) { |
| 39 | - return (int)$link[0]; |
|
| 39 | + return (int) $link[0]; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | throw new \RuntimeException('No resource provided'); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } catch (\DomainException $e) { |
| 150 | 150 | throw new OCSForbiddenException($e->getMessage(), $e); |
| 151 | 151 | } catch (Exception $e) { |
| 152 | - $this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]); |
|
| 152 | + $this->logger->error('Error when updating flow with id '.$id, ['exception' => $e]); |
|
| 153 | 153 | throw new OCSException('An internal error occurred', $e->getCode(), $e); |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | } catch (\DomainException $e) { |
| 169 | 169 | throw new OCSForbiddenException($e->getMessage(), $e); |
| 170 | 170 | } catch (Exception $e) { |
| 171 | - $this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]); |
|
| 171 | + $this->logger->error('Error when deleting flow with id '.$id, ['exception' => $e]); |
|
| 172 | 172 | throw new OCSException('An internal error occurred', $e->getCode(), $e); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -22,130 +22,130 @@ |
||
| 22 | 22 | |
| 23 | 23 | abstract class AWorkflowController extends OCSController { |
| 24 | 24 | |
| 25 | - public function __construct( |
|
| 26 | - $appName, |
|
| 27 | - IRequest $request, |
|
| 28 | - protected Manager $manager, |
|
| 29 | - private LoggerInterface $logger, |
|
| 30 | - ) { |
|
| 31 | - parent::__construct($appName, $request); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @throws OCSForbiddenException |
|
| 36 | - */ |
|
| 37 | - abstract protected function getScopeContext(): ScopeContext; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global?format=json" |
|
| 41 | - * |
|
| 42 | - * @throws OCSForbiddenException |
|
| 43 | - */ |
|
| 44 | - public function index(): DataResponse { |
|
| 45 | - $operationsByClass = $this->manager->getAllOperations($this->getScopeContext()); |
|
| 46 | - |
|
| 47 | - foreach ($operationsByClass as &$operations) { |
|
| 48 | - foreach ($operations as &$operation) { |
|
| 49 | - $operation = $this->manager->formatOperation($operation); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return new DataResponse($operationsByClass); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global/OCA\\Workflow_DocToPdf\\Operation?format=json" |
|
| 58 | - * |
|
| 59 | - * @throws OCSForbiddenException |
|
| 60 | - */ |
|
| 61 | - public function show(string $id): DataResponse { |
|
| 62 | - $context = $this->getScopeContext(); |
|
| 63 | - |
|
| 64 | - // The ID corresponds to a class name |
|
| 65 | - $operations = $this->manager->getOperations($id, $context); |
|
| 66 | - |
|
| 67 | - foreach ($operations as &$operation) { |
|
| 68 | - $operation = $this->manager->formatOperation($operation); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - return new DataResponse($operations); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @throws OCSBadRequestException |
|
| 76 | - * @throws OCSForbiddenException |
|
| 77 | - * @throws OCSException |
|
| 78 | - */ |
|
| 79 | - #[PasswordConfirmationRequired] |
|
| 80 | - public function create( |
|
| 81 | - string $class, |
|
| 82 | - string $name, |
|
| 83 | - array $checks, |
|
| 84 | - string $operation, |
|
| 85 | - string $entity, |
|
| 86 | - array $events, |
|
| 87 | - ): DataResponse { |
|
| 88 | - $context = $this->getScopeContext(); |
|
| 89 | - try { |
|
| 90 | - $operation = $this->manager->addOperation($class, $name, $checks, $operation, $context, $entity, $events); |
|
| 91 | - $operation = $this->manager->formatOperation($operation); |
|
| 92 | - return new DataResponse($operation); |
|
| 93 | - } catch (\UnexpectedValueException $e) { |
|
| 94 | - throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 95 | - } catch (\DomainException $e) { |
|
| 96 | - throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 97 | - } catch (Exception $e) { |
|
| 98 | - $this->logger->error('Error when inserting flow', ['exception' => $e]); |
|
| 99 | - throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @throws OCSBadRequestException |
|
| 105 | - * @throws OCSForbiddenException |
|
| 106 | - * @throws OCSException |
|
| 107 | - */ |
|
| 108 | - #[PasswordConfirmationRequired] |
|
| 109 | - public function update( |
|
| 110 | - int $id, |
|
| 111 | - string $name, |
|
| 112 | - array $checks, |
|
| 113 | - string $operation, |
|
| 114 | - string $entity, |
|
| 115 | - array $events, |
|
| 116 | - ): DataResponse { |
|
| 117 | - try { |
|
| 118 | - $context = $this->getScopeContext(); |
|
| 119 | - $operation = $this->manager->updateOperation($id, $name, $checks, $operation, $context, $entity, $events); |
|
| 120 | - $operation = $this->manager->formatOperation($operation); |
|
| 121 | - return new DataResponse($operation); |
|
| 122 | - } catch (\UnexpectedValueException $e) { |
|
| 123 | - throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 124 | - } catch (\DomainException $e) { |
|
| 125 | - throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 126 | - } catch (Exception $e) { |
|
| 127 | - $this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]); |
|
| 128 | - throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @throws OCSBadRequestException |
|
| 134 | - * @throws OCSForbiddenException |
|
| 135 | - * @throws OCSException |
|
| 136 | - */ |
|
| 137 | - #[PasswordConfirmationRequired] |
|
| 138 | - public function destroy(int $id): DataResponse { |
|
| 139 | - try { |
|
| 140 | - $deleted = $this->manager->deleteOperation($id, $this->getScopeContext()); |
|
| 141 | - return new DataResponse($deleted); |
|
| 142 | - } catch (\UnexpectedValueException $e) { |
|
| 143 | - throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 144 | - } catch (\DomainException $e) { |
|
| 145 | - throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 146 | - } catch (Exception $e) { |
|
| 147 | - $this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]); |
|
| 148 | - throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 149 | - } |
|
| 150 | - } |
|
| 25 | + public function __construct( |
|
| 26 | + $appName, |
|
| 27 | + IRequest $request, |
|
| 28 | + protected Manager $manager, |
|
| 29 | + private LoggerInterface $logger, |
|
| 30 | + ) { |
|
| 31 | + parent::__construct($appName, $request); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @throws OCSForbiddenException |
|
| 36 | + */ |
|
| 37 | + abstract protected function getScopeContext(): ScopeContext; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global?format=json" |
|
| 41 | + * |
|
| 42 | + * @throws OCSForbiddenException |
|
| 43 | + */ |
|
| 44 | + public function index(): DataResponse { |
|
| 45 | + $operationsByClass = $this->manager->getAllOperations($this->getScopeContext()); |
|
| 46 | + |
|
| 47 | + foreach ($operationsByClass as &$operations) { |
|
| 48 | + foreach ($operations as &$operation) { |
|
| 49 | + $operation = $this->manager->formatOperation($operation); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return new DataResponse($operationsByClass); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/global/OCA\\Workflow_DocToPdf\\Operation?format=json" |
|
| 58 | + * |
|
| 59 | + * @throws OCSForbiddenException |
|
| 60 | + */ |
|
| 61 | + public function show(string $id): DataResponse { |
|
| 62 | + $context = $this->getScopeContext(); |
|
| 63 | + |
|
| 64 | + // The ID corresponds to a class name |
|
| 65 | + $operations = $this->manager->getOperations($id, $context); |
|
| 66 | + |
|
| 67 | + foreach ($operations as &$operation) { |
|
| 68 | + $operation = $this->manager->formatOperation($operation); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + return new DataResponse($operations); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @throws OCSBadRequestException |
|
| 76 | + * @throws OCSForbiddenException |
|
| 77 | + * @throws OCSException |
|
| 78 | + */ |
|
| 79 | + #[PasswordConfirmationRequired] |
|
| 80 | + public function create( |
|
| 81 | + string $class, |
|
| 82 | + string $name, |
|
| 83 | + array $checks, |
|
| 84 | + string $operation, |
|
| 85 | + string $entity, |
|
| 86 | + array $events, |
|
| 87 | + ): DataResponse { |
|
| 88 | + $context = $this->getScopeContext(); |
|
| 89 | + try { |
|
| 90 | + $operation = $this->manager->addOperation($class, $name, $checks, $operation, $context, $entity, $events); |
|
| 91 | + $operation = $this->manager->formatOperation($operation); |
|
| 92 | + return new DataResponse($operation); |
|
| 93 | + } catch (\UnexpectedValueException $e) { |
|
| 94 | + throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 95 | + } catch (\DomainException $e) { |
|
| 96 | + throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 97 | + } catch (Exception $e) { |
|
| 98 | + $this->logger->error('Error when inserting flow', ['exception' => $e]); |
|
| 99 | + throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @throws OCSBadRequestException |
|
| 105 | + * @throws OCSForbiddenException |
|
| 106 | + * @throws OCSException |
|
| 107 | + */ |
|
| 108 | + #[PasswordConfirmationRequired] |
|
| 109 | + public function update( |
|
| 110 | + int $id, |
|
| 111 | + string $name, |
|
| 112 | + array $checks, |
|
| 113 | + string $operation, |
|
| 114 | + string $entity, |
|
| 115 | + array $events, |
|
| 116 | + ): DataResponse { |
|
| 117 | + try { |
|
| 118 | + $context = $this->getScopeContext(); |
|
| 119 | + $operation = $this->manager->updateOperation($id, $name, $checks, $operation, $context, $entity, $events); |
|
| 120 | + $operation = $this->manager->formatOperation($operation); |
|
| 121 | + return new DataResponse($operation); |
|
| 122 | + } catch (\UnexpectedValueException $e) { |
|
| 123 | + throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 124 | + } catch (\DomainException $e) { |
|
| 125 | + throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 126 | + } catch (Exception $e) { |
|
| 127 | + $this->logger->error('Error when updating flow with id ' . $id, ['exception' => $e]); |
|
| 128 | + throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @throws OCSBadRequestException |
|
| 134 | + * @throws OCSForbiddenException |
|
| 135 | + * @throws OCSException |
|
| 136 | + */ |
|
| 137 | + #[PasswordConfirmationRequired] |
|
| 138 | + public function destroy(int $id): DataResponse { |
|
| 139 | + try { |
|
| 140 | + $deleted = $this->manager->deleteOperation($id, $this->getScopeContext()); |
|
| 141 | + return new DataResponse($deleted); |
|
| 142 | + } catch (\UnexpectedValueException $e) { |
|
| 143 | + throw new OCSBadRequestException($e->getMessage(), $e); |
|
| 144 | + } catch (\DomainException $e) { |
|
| 145 | + throw new OCSForbiddenException($e->getMessage(), $e); |
|
| 146 | + } catch (Exception $e) { |
|
| 147 | + $this->logger->error('Error when deleting flow with id ' . $id, ['exception' => $e]); |
|
| 148 | + throw new OCSException('An internal error occurred', $e->getCode(), $e); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | } |
@@ -39,117 +39,117 @@ |
||
| 39 | 39 | |
| 40 | 40 | class Version2000Date20190808074233 extends SimpleMigrationStep { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param IOutput $output |
|
| 44 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 45 | - * @param array $options |
|
| 46 | - * @return null|ISchemaWrapper |
|
| 47 | - */ |
|
| 48 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 49 | - /** @var ISchemaWrapper $schema */ |
|
| 50 | - $schema = $schemaClosure(); |
|
| 42 | + /** |
|
| 43 | + * @param IOutput $output |
|
| 44 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 45 | + * @param array $options |
|
| 46 | + * @return null|ISchemaWrapper |
|
| 47 | + */ |
|
| 48 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 49 | + /** @var ISchemaWrapper $schema */ |
|
| 50 | + $schema = $schemaClosure(); |
|
| 51 | 51 | |
| 52 | - if (!$schema->hasTable('flow_checks')) { |
|
| 53 | - $table = $schema->createTable('flow_checks'); |
|
| 54 | - $table->addColumn('id', Types::INTEGER, [ |
|
| 55 | - 'autoincrement' => true, |
|
| 56 | - 'notnull' => true, |
|
| 57 | - 'length' => 4, |
|
| 58 | - ]); |
|
| 59 | - $table->addColumn('class', Types::STRING, [ |
|
| 60 | - 'notnull' => true, |
|
| 61 | - 'length' => 256, |
|
| 62 | - 'default' => '', |
|
| 63 | - ]); |
|
| 64 | - $table->addColumn('operator', Types::STRING, [ |
|
| 65 | - 'notnull' => true, |
|
| 66 | - 'length' => 16, |
|
| 67 | - 'default' => '', |
|
| 68 | - ]); |
|
| 69 | - $table->addColumn('value', Types::TEXT, [ |
|
| 70 | - 'notnull' => false, |
|
| 71 | - ]); |
|
| 72 | - $table->addColumn('hash', Types::STRING, [ |
|
| 73 | - 'notnull' => true, |
|
| 74 | - 'length' => 32, |
|
| 75 | - 'default' => '', |
|
| 76 | - ]); |
|
| 77 | - $table->setPrimaryKey(['id']); |
|
| 78 | - $table->addUniqueIndex(['hash'], 'flow_unique_hash'); |
|
| 79 | - } |
|
| 52 | + if (!$schema->hasTable('flow_checks')) { |
|
| 53 | + $table = $schema->createTable('flow_checks'); |
|
| 54 | + $table->addColumn('id', Types::INTEGER, [ |
|
| 55 | + 'autoincrement' => true, |
|
| 56 | + 'notnull' => true, |
|
| 57 | + 'length' => 4, |
|
| 58 | + ]); |
|
| 59 | + $table->addColumn('class', Types::STRING, [ |
|
| 60 | + 'notnull' => true, |
|
| 61 | + 'length' => 256, |
|
| 62 | + 'default' => '', |
|
| 63 | + ]); |
|
| 64 | + $table->addColumn('operator', Types::STRING, [ |
|
| 65 | + 'notnull' => true, |
|
| 66 | + 'length' => 16, |
|
| 67 | + 'default' => '', |
|
| 68 | + ]); |
|
| 69 | + $table->addColumn('value', Types::TEXT, [ |
|
| 70 | + 'notnull' => false, |
|
| 71 | + ]); |
|
| 72 | + $table->addColumn('hash', Types::STRING, [ |
|
| 73 | + 'notnull' => true, |
|
| 74 | + 'length' => 32, |
|
| 75 | + 'default' => '', |
|
| 76 | + ]); |
|
| 77 | + $table->setPrimaryKey(['id']); |
|
| 78 | + $table->addUniqueIndex(['hash'], 'flow_unique_hash'); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (!$schema->hasTable('flow_operations')) { |
|
| 82 | - $table = $schema->createTable('flow_operations'); |
|
| 83 | - $table->addColumn('id', Types::INTEGER, [ |
|
| 84 | - 'autoincrement' => true, |
|
| 85 | - 'notnull' => true, |
|
| 86 | - 'length' => 4, |
|
| 87 | - ]); |
|
| 88 | - $table->addColumn('class', Types::STRING, [ |
|
| 89 | - 'notnull' => true, |
|
| 90 | - 'length' => 256, |
|
| 91 | - 'default' => '', |
|
| 92 | - ]); |
|
| 93 | - $table->addColumn('name', Types::STRING, [ |
|
| 94 | - 'notnull' => false, |
|
| 95 | - 'length' => 256, |
|
| 96 | - 'default' => '', |
|
| 97 | - ]); |
|
| 98 | - $table->addColumn('checks', Types::TEXT, [ |
|
| 99 | - 'notnull' => false, |
|
| 100 | - ]); |
|
| 101 | - $table->addColumn('operation', Types::TEXT, [ |
|
| 102 | - 'notnull' => false, |
|
| 103 | - ]); |
|
| 104 | - $this->ensureEntityColumns($table); |
|
| 105 | - $table->setPrimaryKey(['id']); |
|
| 106 | - } else { |
|
| 107 | - $table = $schema->getTable('flow_operations'); |
|
| 108 | - $this->ensureEntityColumns($table); |
|
| 109 | - } |
|
| 81 | + if (!$schema->hasTable('flow_operations')) { |
|
| 82 | + $table = $schema->createTable('flow_operations'); |
|
| 83 | + $table->addColumn('id', Types::INTEGER, [ |
|
| 84 | + 'autoincrement' => true, |
|
| 85 | + 'notnull' => true, |
|
| 86 | + 'length' => 4, |
|
| 87 | + ]); |
|
| 88 | + $table->addColumn('class', Types::STRING, [ |
|
| 89 | + 'notnull' => true, |
|
| 90 | + 'length' => 256, |
|
| 91 | + 'default' => '', |
|
| 92 | + ]); |
|
| 93 | + $table->addColumn('name', Types::STRING, [ |
|
| 94 | + 'notnull' => false, |
|
| 95 | + 'length' => 256, |
|
| 96 | + 'default' => '', |
|
| 97 | + ]); |
|
| 98 | + $table->addColumn('checks', Types::TEXT, [ |
|
| 99 | + 'notnull' => false, |
|
| 100 | + ]); |
|
| 101 | + $table->addColumn('operation', Types::TEXT, [ |
|
| 102 | + 'notnull' => false, |
|
| 103 | + ]); |
|
| 104 | + $this->ensureEntityColumns($table); |
|
| 105 | + $table->setPrimaryKey(['id']); |
|
| 106 | + } else { |
|
| 107 | + $table = $schema->getTable('flow_operations'); |
|
| 108 | + $this->ensureEntityColumns($table); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - if (!$schema->hasTable('flow_operations_scope')) { |
|
| 112 | - $table = $schema->createTable('flow_operations_scope'); |
|
| 113 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 114 | - 'autoincrement' => true, |
|
| 115 | - 'notnull' => true, |
|
| 116 | - 'length' => 4, |
|
| 117 | - ]); |
|
| 118 | - $table->addColumn('operation_id', Types::INTEGER, [ |
|
| 119 | - 'notnull' => true, |
|
| 120 | - 'length' => 4, |
|
| 121 | - 'default' => 0, |
|
| 122 | - ]); |
|
| 123 | - $table->addColumn('type', Types::INTEGER, [ |
|
| 124 | - 'notnull' => true, |
|
| 125 | - 'length' => 4, |
|
| 126 | - 'default' => 0, |
|
| 127 | - ]); |
|
| 128 | - $table->addColumn('value', Types::STRING, [ |
|
| 129 | - 'notnull' => false, |
|
| 130 | - 'length' => 64, |
|
| 131 | - 'default' => '', |
|
| 132 | - ]); |
|
| 133 | - $table->setPrimaryKey(['id']); |
|
| 134 | - $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope'); |
|
| 135 | - } |
|
| 111 | + if (!$schema->hasTable('flow_operations_scope')) { |
|
| 112 | + $table = $schema->createTable('flow_operations_scope'); |
|
| 113 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 114 | + 'autoincrement' => true, |
|
| 115 | + 'notnull' => true, |
|
| 116 | + 'length' => 4, |
|
| 117 | + ]); |
|
| 118 | + $table->addColumn('operation_id', Types::INTEGER, [ |
|
| 119 | + 'notnull' => true, |
|
| 120 | + 'length' => 4, |
|
| 121 | + 'default' => 0, |
|
| 122 | + ]); |
|
| 123 | + $table->addColumn('type', Types::INTEGER, [ |
|
| 124 | + 'notnull' => true, |
|
| 125 | + 'length' => 4, |
|
| 126 | + 'default' => 0, |
|
| 127 | + ]); |
|
| 128 | + $table->addColumn('value', Types::STRING, [ |
|
| 129 | + 'notnull' => false, |
|
| 130 | + 'length' => 64, |
|
| 131 | + 'default' => '', |
|
| 132 | + ]); |
|
| 133 | + $table->setPrimaryKey(['id']); |
|
| 134 | + $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope'); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return $schema; |
|
| 138 | - } |
|
| 137 | + return $schema; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - protected function ensureEntityColumns(Table $table) { |
|
| 141 | - if (!$table->hasColumn('entity')) { |
|
| 142 | - $table->addColumn('entity', Types::STRING, [ |
|
| 143 | - 'notnull' => true, |
|
| 144 | - 'length' => 256, |
|
| 145 | - 'default' => File::class, |
|
| 146 | - ]); |
|
| 147 | - } |
|
| 148 | - if (!$table->hasColumn('events')) { |
|
| 149 | - $table->addColumn('events', Types::TEXT, [ |
|
| 150 | - 'notnull' => true, |
|
| 151 | - 'default' => '[]', |
|
| 152 | - ]); |
|
| 153 | - } |
|
| 154 | - } |
|
| 140 | + protected function ensureEntityColumns(Table $table) { |
|
| 141 | + if (!$table->hasColumn('entity')) { |
|
| 142 | + $table->addColumn('entity', Types::STRING, [ |
|
| 143 | + 'notnull' => true, |
|
| 144 | + 'length' => 256, |
|
| 145 | + 'default' => File::class, |
|
| 146 | + ]); |
|
| 147 | + } |
|
| 148 | + if (!$table->hasColumn('events')) { |
|
| 149 | + $table->addColumn('events', Types::TEXT, [ |
|
| 150 | + 'notnull' => true, |
|
| 151 | + 'default' => '[]', |
|
| 152 | + ]); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |