From 0c7e2591517818862f6021c8e66a44f5b84d6a65 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 15 Nov 2024 15:59:55 +0100 Subject: feat(systemtags): allow setting color with occ Signed-off-by: skjnldsv --- core/Command/SystemTag/Edit.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/Command/SystemTag/Edit.php b/core/Command/SystemTag/Edit.php index eb6412b7639..614f2798ce4 100644 --- a/core/Command/SystemTag/Edit.php +++ b/core/Command/SystemTag/Edit.php @@ -40,6 +40,12 @@ class Edit extends Base { null, InputOption::VALUE_OPTIONAL, 'sets the access control level (public, restricted, invisible)', + ) + ->addOption( + 'color', + null, + InputOption::VALUE_OPTIONAL, + 'set the tag color', ); } @@ -80,9 +86,24 @@ class Edit extends Base { } } + $color = $tag->getColor(); + if ($input->hasOption('color')) { + $color = $input->getOption('color'); + if (substr($color, 0, 1) === '#') { + $color = substr($color, 1); + } + + if ($input->getOption('color') === '') { + $color = null; + } elseif (strlen($color) !== 6 || !ctype_xdigit($color)) { + $output->writeln('Color must be a 6-digit hexadecimal value'); + return 2; + } + } + try { - $this->systemTagManager->updateTag($input->getArgument('id'), $name, $userVisible, $userAssignable); - $output->writeln('Tag updated ("' . $name . '", ' . $userVisible . ', ' . $userAssignable . ')'); + $this->systemTagManager->updateTag($input->getArgument('id'), $name, $userVisible, $userAssignable, $color); + $output->writeln('Tag updated ("' . $name . '", ' . json_encode($userVisible) . ', ' . json_encode($userAssignable) . ', "' . ($color ? "#$color" : '') . '")'); return 0; } catch (TagNotFoundException $e) { $output->writeln('Tag not found'); -- cgit v1.2.3