Skip to content

Commit

Permalink
moved utils to support to match phalcon 5 structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jturbide committed Feb 22, 2024
1 parent dc2a302 commit 5650168
Show file tree
Hide file tree
Showing 38 changed files with 161 additions and 137 deletions.
21 changes: 13 additions & 8 deletions src/Bootstrap/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@
namespace Zemit\Bootstrap;

use PDO;

use Phalcon\Config\Config as PhalconConfig;
use Phalcon\Db\Column;
use Phalcon\Encryption\Security;
use Phalcon\Config\Config as PhalconConfig;
use Phalcon\Support\Version as PhalconVersion;
use Zemit\Bootstrap\Permissions\TableConfig;
use Zemit\Bootstrap\Permissions\WorkspaceConfig;
use Zemit\Locale;
use Zemit\Support\Version;
use Zemit\Provider;
use Zemit\Utils\Env;
use Zemit\Models;
use Zemit\Modules\Cli;
use Zemit\Modules\Api;
use Zemit\Modules\Cli;
use Zemit\Mvc\Controller\Behavior;
use Zemit\Bootstrap\Permissions\TableConfig;
use Zemit\Bootstrap\Permissions\WorkspaceConfig;
use Zemit\Provider;
use Zemit\Support\Env;
use Zemit\Support\Version;

/**
* Global Zemit Configuration
Expand Down Expand Up @@ -457,6 +456,12 @@ public function __construct(array $data = [], bool $insensitive = false)
Provider\LoremIpsum\ServiceProvider::class => Env::get('PROVIDER_LOREM_IPSUM', Provider\LoremIpsum\ServiceProvider::class),
],

/**
* Helper Services
*/
'helpers' => [
],

/**
* Logger Configuration
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Phalcon\Di\DiInterface;
use Phalcon\Mvc\ModuleDefinitionInterface;
use Zemit\Bootstrap\Config;
use Zemit\Utils;
use Zemit\Support\Utils;

class Module implements ModuleDefinitionInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Zemit\Locale;
use Zemit\Mvc\View;
use Zemit\Provider\Jwt\Jwt;
use Zemit\Utils;
use Zemit\Support\Utils;

/**
* @property Bootstrap\Config $config
Expand All @@ -41,7 +41,7 @@
* @property Identity $identity
* @property Locale $locale
* @property Logger $logger
* @property Utils $utils
* @property \Zemit\Support\Utils $utils
* @property LoremIpsum $loremIpsum
* @property OpenAi $openAi
*/
Expand Down
1 change: 1 addition & 0 deletions src/Di/Injectable.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
// * @property \Zemit\Tag $tag
*
* @property \Zemit\Acl\Acl $acl
* @property \Zemit\Support\HelperFactory $helper
*/
class Injectable extends \Phalcon\Di\Injectable implements \Phalcon\Di\InjectionAwareInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Di/InjectableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* @property \Zemit\Debug $debug
* @property \Zemit\Identity $identity
* @property \Zemit\Locale $locale
* @property \Zemit\Utils $utils
* @property \Zemit\Support\Utils $utils
* @property \Zemit\Profiler $profiler
* @property \Zemit\Logger $logger
* @property \Zemit\Jwt $jwt
Expand Down
2 changes: 1 addition & 1 deletion src/Events/EventsAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Phalcon\Di\Di;
use Phalcon\Events\ManagerInterface;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;

/**
* The EventsAwareTrait provides methods for managing events within a class.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* Zemit\Exception
* All framework exceptions should use or extend this exception
* All Zemit exceptions should use or extend this exception
*/
class Exception extends \Exception implements \Throwable
{
Expand Down
7 changes: 4 additions & 3 deletions src/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@

use Phalcon\Acl\Role;
use Phalcon\Db\Column;
use Phalcon\Messages\Message;
use Phalcon\Mvc\ModelInterface;
use Phalcon\Encryption\Security\Exception;
use Phalcon\Encryption\Security\JWT\Exceptions\ValidatorException;
use Phalcon\Filter\Validation\Validator\Confirmation;
use Phalcon\Filter\Validation\Validator\Numericality;
use Phalcon\Filter\Validation\Validator\PresenceOf;
use Phalcon\Messages\Message;
use Phalcon\Mvc\ModelInterface;
use Phalcon\Support\Helper\Str\Random;
use Zemit\Di\Injectable;
use Zemit\Filter\Validation;
use Zemit\Models\Interfaces\RoleInterface;
use Zemit\Models\Interfaces\SessionInterface;
use Zemit\Models\Interfaces\UserInterface;
use Zemit\Models\User;
use Zemit\Mvc\Model\Behavior\Security as SecurityBehavior;
use Zemit\Support\ModelsMap;
use Zemit\Support\Options\Options;
use Zemit\Support\Options\OptionsInterface;
use Zemit\Mvc\Model\Behavior\Security as SecurityBehavior;

/**
* Identity Management
Expand Down
4 changes: 1 addition & 3 deletions src/Modules/Api/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace Zemit\Modules\Api\Controllers;

use Phalcon\Security\Exception;
use Zemit\Mvc\Controller\Identity;

class AuthController extends AbstractController
Expand All @@ -19,7 +18,7 @@ class AuthController extends AbstractController
getAction as traitGetAction;
}

public function indexAction($id = null): bool
public function indexAction(string|int $id = null): bool
{
return $this->getAction();
}
Expand All @@ -30,7 +29,6 @@ public function indexAction($id = null): bool
* @param bool $refresh
*
* @return bool
* @throws Exception
*/
public function getAction($refresh = false): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Api/Controllers/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Zemit\Modules\Api\Controllers;

use Zemit\Modules\Api\Controller;
use Zemit\Utils;
use Zemit\Support\Utils;

class TestController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Cli/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Zemit\Exception\CliException;
use Zemit\Http\StatusCode;
use Zemit\Support\Helper;
use Zemit\Utils;
use Zemit\Support\Utils;

class Task extends \Zemit\Cli\Task
{
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Cli/Tasks/DataLifeCycleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Phalcon\Mvc\Model\ResultsetInterface;
use Zemit\Modules\Cli\Task;
use Zemit\Mvc\Model;
use Zemit\Utils;
use Zemit\Support\Utils;

class DataLifeCycleTask extends Task
{
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Cli/Tasks/DatabaseTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Zemit\Bootstrap\Deployment;
use Zemit\Modules\Cli\Task;
use Zemit\Modules\Cli\Tasks\Traits\DatabaseTrait;
use Zemit\Utils;
use Zemit\Support\Utils;

class DatabaseTask extends Task
{
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Cli/Tasks/ScaffoldTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use Phalcon\Db\Column;
use Phalcon\Db\ColumnInterface;
use Phalcon\Mvc\Model\Relation;
use Zemit\Modules\Cli\Task;
use Zemit\Mvc\Model;
use Zemit\Support\Helper;
use Zemit\Modules\Cli\Task;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;

class ScaffoldTask extends Task
{
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Cli/Tasks/TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Zemit\Modules\Cli\Tasks;

use Zemit\Modules\Cli\Task;
use Zemit\Utils;
use Zemit\Support\Utils;

class TestTask extends Task
{
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/Cli/Tasks/Traits/UserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
namespace Zemit\Modules\Cli\Tasks\Traits;

use Phalcon\Db\Column;
use Zemit\Models\Interfaces\UserInterface;
use Zemit\Models\Role;
use Zemit\Models\User;
use Zemit\Models\UserRole;
use Zemit\Utils;
use Zemit\Support\Utils;

trait UserTrait
{
Expand Down
6 changes: 3 additions & 3 deletions src/Modules/Frontend/Controllers/CheckController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
namespace Zemit\Modules\Frontend\Controllers;

use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Filter;
use Phalcon\Filter\Validation;
use Phalcon\Http\Response;
use Phalcon\Messages\Message;
use Phalcon\Filter\Validation;
use Zemit\Bootstrap;
use Zemit\Bootstrap\Config;
use Zemit\Escaper;
use Phalcon\Filter;
use Zemit\Http\Request;
use Zemit\Identity;
use Zemit\Locale;
use Zemit\Mvc\Application;
use Zemit\Mvc\Dispatcher;
use Zemit\Mvc\Router;
use Zemit\Mvc\Url;
use Zemit\Utils;
use Zemit\Support\Utils;

class CheckController extends AbstractController
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use Zemit\Filter;
use Zemit\Http\Request;
use Zemit\Identity;
use Zemit\Support\Utils;
use Zemit\Tag;
use Zemit\Utils;

/**
* Class Controller
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Controller/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Zemit\Identity;
use Zemit\Support\Exposer\Exposer;
use Zemit\Support\Helper;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;

/**
* Trait Model
Expand Down
24 changes: 12 additions & 12 deletions src/Mvc/Controller/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
use Shuchkin\SimpleXLSXGen;
use Zemit\Di\Injectable;
use Zemit\Http\StatusCode;
use Zemit\Utils;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;
use Zemit\Support\Utils;

class Rest extends \Zemit\Mvc\Controller
{
Expand All @@ -36,7 +36,7 @@ class Rest extends \Zemit\Mvc\Controller
/**
* @throws Exception
*/
public function indexAction(string|int $id = null): void
public function indexAction(string|int $id = null)
{
$this->restForwarding($id);
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public function getSingleAction(string|int $id = null): false|ResponseInterface
/**
* Retrieving a single record
*/
public function getAction(string|int $id = null): false|ResponseInterface
public function getAction(string|int $id = null): bool|ResponseInterface
{
$modelName = $this->getModelClassName();
$single = $this->getSingle($id, $modelName, null);
Expand Down Expand Up @@ -692,14 +692,14 @@ public function reorderAction(string|int $id = null, int $position = null): fals
}

/**
* Sending an error as an http response
* Set the REST response error
*
* @param null $error
* @param null $response
*
* @return ResponseInterface
* @param int $code The HTTP status code (default: 400)
* @param string $status The status message (default: 'Bad Request')
* @param mixed $response The response body (default: null)
* @return ResponseInterface The REST response object
*/
public function setRestErrorResponse($code = 400, $status = 'Bad Request', $response = null)
public function setRestErrorResponse(int $code = 400, string $status = 'Bad Request', mixed $response = null): ResponseInterface
{
return $this->setRestResponse($response, $code, $status);
}
Expand All @@ -715,7 +715,7 @@ public function setRestErrorResponse($code = 400, $status = 'Bad Request', $resp
*
* @return ResponseInterface
*/
public function setRestResponse($response = null, int $code = null, string $status = null, int $jsonOptions = 0, int $depth = 512): ResponseInterface
public function setRestResponse(mixed $response = null, int $code = null, string $status = null, int $jsonOptions = 0, int $depth = 512): ResponseInterface
{
$debug = $this->isDebugEnabled();

Expand All @@ -726,7 +726,7 @@ public function setRestResponse($response = null, int $code = null, string $stat
$status ??= $reasonPhrase ?: StatusCode::getMessage($code);

$view = $this->view->getParamsToView();
$hash = hash('sha512', json_encode($view));
$hash = hash('sha512', json_encode($view)); // @todo store hash in cache layer with response content

// set response status code
$this->response->setStatusCode($code, $code . ' ' . $status);
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Model/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function initializeSlug(?array $options = null): void
'beforeValidation' => [
$field => function (Model $model, $field) {
$value = $model->readAttribute($field);
return $value && is_string($value) ? \Zemit\Utils\Slug::generate($value) : $value;
return $value && is_string($value) ? \Zemit\Support\Slug::generate($value) : $value;
},
],
]));
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Phalcon\Mvc\View;
use Zemit\Bootstrap\Config;
use Zemit\Di\Injectable;
use Zemit\Utils;
use Zemit\Support\Utils;

/**
* {@inheritDoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Router/ModuleRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Zemit\Mvc\Router;

use Phalcon\Mvc\Router\Group as RouterGroup;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;

class ModuleRoute extends RouterGroup
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Zemit\Mvc;

use Zemit\Support\Helper;
use Zemit\Utils\Slug;
use Zemit\Support\Slug;

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Env/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Phalcon\Di\DiInterface;
use Zemit\Provider\AbstractServiceProvider;
use Zemit\Utils\Env;
use Zemit\Support\Env;

class ServiceProvider extends AbstractServiceProvider
{
Expand Down
Loading

0 comments on commit 5650168

Please sign in to comment.