Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arman committed Aug 21, 2024
1 parent e1a6c51 commit f8fea63
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 29 deletions.
11 changes: 2 additions & 9 deletions helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
*/

use Quantum\Libraries\Storage\FileSystem;
use Quantum\Exceptions\LangException;
use Quantum\Exceptions\DiException;
use Quantum\Di\Di;

/**
* Gets the url with selected language
* @param string $lang
* @return string
* @throws LangException
*/
function url_with_lang(string $lang): string
{
Expand Down Expand Up @@ -76,12 +78,3 @@ function save_remote_image(string $imageUrl, string $userDirectory, string $imag

return $imageName;
}

function getRecaptcha()
{
if (env('RECAPTCHA_SITE_KEY_V2')) {
echo partial('partials/recaptchaVersions/recaptchaCheckbox');
} elseif (env('RECAPTCHA_SITE_KEY_V3')) {
echo partial('partials/recaptchaVersions/recaptchaInvisibleV3');
}
}
1 change: 1 addition & 0 deletions modules/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#qt
23 changes: 20 additions & 3 deletions shared/Commands/DemoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

namespace Shared\Commands;

use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Input\ArrayInput;
use Quantum\Libraries\Storage\FileSystem;
use Quantum\Exceptions\DatabaseException;
use Quantum\Exceptions\ConfigException;
use Bluemmb\Faker\PicsumPhotosProvider;
use Quantum\Exceptions\ModelException;
use Quantum\Migration\MigrationTable;
use Quantum\Factory\ServiceFactory;
use Quantum\Exceptions\DiException;
Expand Down Expand Up @@ -96,19 +99,23 @@ class DemoCommand extends QtCommand
const DEFAULT_PASSWORD = 'password';

/**
* Command name of run migration
* Command name to run migrations
*/
const COMMAND_MIGRATE = 'migration:migrate';

/**
* Command name of create user
* Command name to create users
*/
const COMMAND_USER_CREATE = 'user:create';

/**
* Command name of create post
* Command name to create posts
*/
const COMMAND_POST_CREATE = 'post:create';

/**
* Command name to generate modules
*/
const COMMAND_CREATE_MODULE = 'module:generate';

/**
Expand All @@ -125,7 +132,13 @@ public function __construct()

/**
* Executes the command
* @throws DatabaseException
* @throws DiException
* @throws ReflectionException
* @throws ConfigException
* @throws ModelException
* @throws Exception
* @throws ExceptionInterface
*/
public function exec()
{
Expand Down Expand Up @@ -175,6 +188,7 @@ public function exec()
/**
* Runs an external command
* @throws Exception
* @throws ExceptionInterface
*/
protected function runExternalCommand($commandName, $arguments)
{
Expand Down Expand Up @@ -226,6 +240,9 @@ private function newPostData($user): array
/**
* Cleanups the database
* @throws DatabaseException
* @throws DiException
* @throws ExceptionInterface
* @throws ReflectionException
*/
private function cleanUp()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/PostCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

namespace Shared\Commands;

use Quantum\Exceptions\ServiceException;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Shared\Services\PostService;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class PostCreateCommand
Expand Down Expand Up @@ -58,6 +60,8 @@ class PostCreateCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/PostDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

namespace Shared\Commands;

use Quantum\Exceptions\ServiceException;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Shared\Services\PostService;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class PostDeleteCommand
Expand Down Expand Up @@ -55,6 +57,8 @@ class PostDeleteCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/PostShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
namespace Shared\Commands;

use Symfony\Component\Console\Helper\Table;
use Quantum\Exceptions\ServiceException;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Shared\Services\PostService;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class PostShowCommand
Expand Down Expand Up @@ -56,6 +58,8 @@ class PostShowCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/PostUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

namespace Shared\Commands;

use Quantum\Exceptions\ServiceException;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Shared\Services\PostService;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class PostUpdateCommand
Expand Down Expand Up @@ -65,6 +67,8 @@ class PostUpdateCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/UserCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
namespace Shared\Commands;

use Quantum\Libraries\Validation\Validator;
use Quantum\Exceptions\ServiceException;
use Quantum\Libraries\Validation\Rule;
use Quantum\Libraries\Hasher\Hasher;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Quantum\Factory\ModelFactory;
use Shared\Services\AuthService;
use Quantum\Console\QtCommand;
use ReflectionException;
use Shared\Models\User;

/**
Expand Down Expand Up @@ -70,6 +72,8 @@ class UserCreateCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
4 changes: 4 additions & 0 deletions shared/Commands/UserShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
namespace Shared\Commands;

use Symfony\Component\Console\Helper\Table;
use Quantum\Exceptions\ServiceException;
use Quantum\Exceptions\DiException;
use Quantum\Factory\ServiceFactory;
use Shared\Services\AuthService;
use Quantum\Console\QtCommand;
use ReflectionException;

/**
* Class UserShowCommand
Expand Down Expand Up @@ -56,6 +58,8 @@ class UserShowCommand extends QtCommand
/**
* Executes the command
* @throws DiException
* @throws ServiceException
* @throws ReflectionException
*/
public function exec()
{
Expand Down
22 changes: 18 additions & 4 deletions shared/Services/AuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <[email protected]>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.8.0
* @since 2.9.0
*/

namespace Shared\Services;
Expand Down Expand Up @@ -96,10 +96,15 @@ public function userSchema(): array
}

/**
* Get
* Get
* @param string $field
* @param mixed $value
* @param $value
* @return AuthUser|null
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function get(string $field, $value): ?AuthUser
{
Expand All @@ -116,6 +121,11 @@ public function get(string $field, $value): ?AuthUser
* Add user
* @param array $data
* @return AuthUser
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function add(array $data): AuthUser
{
Expand All @@ -137,6 +147,11 @@ public function add(array $data): AuthUser
* @param string|null $value
* @param array $data
* @return AuthUser|null
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function update(string $field, ?string $value, array $data): ?AuthUser
{
Expand All @@ -162,7 +177,6 @@ public function deleteTable()

/**
* @param string $uuid
* @return void
* @throws DiException
* @throws ReflectionException
*/
Expand Down
31 changes: 28 additions & 3 deletions shared/Services/PostService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public function __init(PostTransformer $transformer)
/**
* Get posts
* @return array
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function getPosts(): array
{
Expand All @@ -79,10 +84,15 @@ public function getPosts(): array
}

/**
* Get post
* Get post
* @param string $uuid
* @param bool $transformed
* @return array|null
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function getPost(string $uuid, bool $transformed = true): ?array
{
Expand Down Expand Up @@ -110,9 +120,14 @@ public function getPost(string $uuid, bool $transformed = true): ?array
}

/**
* Get post
* Get post
* @param int $userId
* @return ?array
* @return array|null
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function getMyPosts(int $userId): ?array
{
Expand Down Expand Up @@ -156,6 +171,11 @@ public function addPost(array $data): array
* Update post
* @param string $uuid
* @param array $data
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function updatePost(string $uuid, array $data)
{
Expand All @@ -168,6 +188,11 @@ public function updatePost(string $uuid, array $data)
* Deletes the post
* @param string $uuid
* @return bool
* @throws ConfigException
* @throws DatabaseException
* @throws DiException
* @throws ModelException
* @throws ReflectionException
*/
public function deletePost(string $uuid): bool
{
Expand Down
2 changes: 1 addition & 1 deletion shared/config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
/**
* ---------------------------------------------------------
* Current cache settings
* Cache settings
* ---------------------------------------------------------
*
* Current configuration to use.
Expand Down
Loading

0 comments on commit f8fea63

Please sign in to comment.