Skip to content

Commit 5d699ca

Browse files
committed
Correcting shared console commands
1 parent f0d05cd commit 5d699ca

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

shared/Commands/PostShowCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function exec()
9999
$rows = [];
100100

101101
foreach ($transformedPosts as $post) {
102-
$rows[] = $this->composeTableRow($post);
102+
$rows[] = $this->composeTableRow($post, 50);
103103
}
104104

105105
$table = new Table($this->output);
@@ -113,10 +113,18 @@ public function exec()
113113
/**
114114
* Composes a table row
115115
* @param array $item
116+
* @param int $maxContentLength
116117
* @return array
117118
*/
118-
private function composeTableRow(array $item): array
119+
private function composeTableRow(array $item, int $maxContentLength = 25): array
119120
{
121+
$content = strip_tags($item['content'] ?? '');
122+
123+
$content = str_replace(["\r", "\n"], ' ', $content);
124+
if (mb_strlen($content) > $maxContentLength) {
125+
$content = mb_substr($content, 0, $maxContentLength) . '...';
126+
}
127+
120128
return [
121129
$item['uuid'] ?? '',
122130
$item['title'] ?? '',

shared/Commands/UserCreateCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Quantum\Service\Exceptions\ServiceException;
1818
use Quantum\Service\Factories\ServiceFactory;
1919
use Quantum\Libraries\Validation\Validator;
20-
use Quantum\Model\Factories\ModelFactory;
2120
use Quantum\Di\Exceptions\DiException;
2221
use Quantum\Libraries\Validation\Rule;
2322
use Quantum\Libraries\Hasher\Hasher;

shared/Commands/UserDeleteCommand.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,9 @@ public function exec()
101101
*/
102102
private function deleteSingleUser(string $uuid)
103103
{
104-
$postService = ServiceFactory::get(AuthService::class);
104+
$authService = ServiceFactory::get(AuthService::class);
105105

106-
$post = $postService->getPost($uuid);
107-
108-
if ($post->isEmpty()) {
109-
$this->error('The post is not found');
110-
return;
111-
}
112-
113-
$postService->deletePost($uuid);
106+
$authService->delete($uuid);
114107

115108
$this->info("User with UUID '{$uuid}' deleted successfully");
116109
}

shared/Services/AuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function get(string $field, $value): ?AuthUser
9595
*/
9696
public function add(array $data): AuthUser
9797
{
98-
$data['uuid'] = $data['uuid'] ?? uuid_ordered();
98+
$data['uuid'] = !empty($data['uuid']) ? $data['uuid'] : uuid_ordered();
9999
$data['role'] = $data['role'] ?? 'editor';
100100

101101
$this->createUserDirectory($data['uuid']);

shared/config/dependencies.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* Default dependencies auto-loaded
77
* ---------------------------------------------------------
88
*/
9-
\Quantum\Loader\Setup::class,
10-
\Shared\Transformers\PostTransformer::class,
9+
\Quantum\Loader\Setup::class => Quantum\Loader\Setup::class,
10+
\Shared\Transformers\PostTransformer::class => \Shared\Transformers\PostTransformer::class,
1111
];

0 commit comments

Comments
 (0)