├── tests ├── _root │ ├── journal.log │ ├── logs │ │ └── .gitkeep │ ├── shared │ │ ├── store │ │ │ └── .gitkeep │ │ ├── emails │ │ │ └── .gitkeep │ │ ├── config │ │ │ ├── hooks.php │ │ │ ├── env.php │ │ │ ├── view_cache.php │ │ │ ├── app.php │ │ │ ├── modules.php │ │ │ ├── session.php │ │ │ ├── view.php │ │ │ ├── logging.php │ │ │ ├── lang.php │ │ │ ├── captcha.php │ │ │ ├── fs.php │ │ │ ├── cors.php │ │ │ ├── auth.php │ │ │ ├── mailer.php │ │ │ ├── cache.php │ │ │ ├── uploads.php │ │ │ └── database.php │ │ ├── resources │ │ │ └── lang │ │ │ │ ├── en │ │ │ │ └── custom.php │ │ │ │ └── es │ │ │ │ └── custom.php │ │ ├── views │ │ │ ├── email │ │ │ │ └── template.php │ │ │ └── errors │ │ │ │ └── 404.php │ │ ├── Models │ │ │ ├── TestNotesModel.php │ │ │ ├── TestUserProfessionModel.php │ │ │ ├── TestPostModel.php │ │ │ ├── TestProductsModel.php │ │ │ ├── TestTicketModel.php │ │ │ ├── TestEventModel.php │ │ │ ├── TestUserMeetingModel.php │ │ │ ├── TestUserEventModel.php │ │ │ ├── TestProfileModel.php │ │ │ └── TestUserModel.php │ │ └── Services │ │ │ └── TokenService.php │ ├── cache │ │ └── data │ │ │ └── .gitkeep │ ├── modules │ │ └── Test │ │ │ ├── Views │ │ │ ├── post.php │ │ │ ├── index.php │ │ │ ├── index.twig.php │ │ │ ├── partial.php │ │ │ ├── layout.twig.php │ │ │ └── layout.php │ │ │ ├── resources │ │ │ └── lang │ │ │ │ ├── en │ │ │ │ └── custom.php │ │ │ │ └── es │ │ │ │ └── custom.php │ │ │ ├── routes │ │ │ └── routes.php │ │ │ ├── Controllers │ │ │ └── TestController.php │ │ │ ├── config │ │ │ └── dependencies.php │ │ │ └── Transformers │ │ │ └── PostTransformer.php │ ├── .env.example │ └── php8fe1.tmp ├── Unit │ ├── Environment │ │ └── Helpers │ │ │ └── EnvHelperTest.php │ ├── Libraries │ │ ├── Session │ │ │ └── TestCaseHelper.php │ │ ├── Transformer │ │ │ └── PostTransformer.php │ │ ├── Database │ │ │ └── Adapters │ │ │ │ ├── Sleekdb │ │ │ │ └── SleekDbalTest.php │ │ │ │ └── Idiorm │ │ │ │ └── IdiormDbalTest.php │ │ ├── Csrf │ │ │ └── Helpers │ │ │ │ └── CsrfHelperFunctionsTest.php │ │ ├── Cookie │ │ │ └── Helpers │ │ │ │ └── CookieHelperFunctionsTest.php │ │ ├── Mailer │ │ │ ├── MailerTestCase.php │ │ │ └── Adapters │ │ │ │ ├── MandrillAdapterTest.php │ │ │ │ ├── SendgridAdapterTest.php │ │ │ │ ├── SendinblueAdapterTest.php │ │ │ │ └── MailgunAdapterTest.php │ │ ├── Storage │ │ │ └── Adapters │ │ │ │ ├── GoogleDrive │ │ │ │ └── GoogleDriveTokenServiceTestCase.php │ │ │ │ └── Dropbox │ │ │ │ └── DropboxTokenServiceTestCase.php │ │ ├── Auth │ │ │ └── Helpers │ │ │ │ └── AuthHelperFunctionsTest.php │ │ ├── Logger │ │ │ └── Adapters │ │ │ │ └── MessageAdapterTest.php │ │ ├── Lang │ │ │ └── TranslatorTest.php │ │ └── Captcha │ │ │ └── Helpers │ │ │ └── CaptchaHelperFunctionsTest.php │ ├── Service │ │ ├── Helpers │ │ │ └── ServiceHelperFunctionTest.php │ │ └── QtServiceTest.php │ ├── View │ │ └── Factories │ │ │ └── ViewFactoryTest.php │ ├── Renderer │ │ └── Adapters │ │ │ ├── HtmlAdapterTest.php │ │ │ └── TwigAdapterTest.php │ ├── Config │ │ └── Helpers │ │ │ └── ConfigHelperFunctionsTest.php │ ├── Http │ │ └── Traits │ │ │ └── Response │ │ │ ├── HttpResponseHeaderTest.php │ │ │ └── HttpResponseStatusTest.php │ ├── Loader │ │ └── LoaderTest.php │ ├── Router │ │ └── RouteControllerTest.php │ └── App │ │ └── Adapters │ │ └── WebAppAdapterTest.php ├── Helpers │ └── functions.php └── bootstrap.php ├── _config.yml ├── src ├── Module │ ├── Templates │ │ ├── DemoWeb │ │ │ └── src │ │ │ │ ├── resources │ │ │ │ └── .gitkeep │ │ │ │ ├── Views │ │ │ │ ├── partials │ │ │ │ │ ├── messages │ │ │ │ │ │ ├── success.php.tpl │ │ │ │ │ │ └── error.php.tpl │ │ │ │ │ ├── logo.php.tpl │ │ │ │ │ ├── bubbles.php.tpl │ │ │ │ │ ├── search.php.tpl │ │ │ │ │ ├── footer.php.tpl │ │ │ │ │ └── language.php.tpl │ │ │ │ ├── post │ │ │ │ │ ├── partials │ │ │ │ │ │ ├── back.php.tpl │ │ │ │ │ │ ├── modal.php.tpl │ │ │ │ │ │ ├── comment-form.php.tpl │ │ │ │ │ │ ├── my-post-item.php.tpl │ │ │ │ │ │ └── comment-item.php.tpl │ │ │ │ │ ├── post.php.tpl │ │ │ │ │ ├── comments.php.tpl │ │ │ │ │ ├── single.php.tpl │ │ │ │ │ └── my-posts.php.tpl │ │ │ │ ├── layouts │ │ │ │ │ └── main.php.tpl │ │ │ │ ├── pages │ │ │ │ │ └── index.php.tpl │ │ │ │ └── account │ │ │ │ │ └── partials │ │ │ │ │ └── account.php.tpl │ │ │ │ ├── Enums │ │ │ │ └── Role.php.tpl │ │ │ │ ├── Middlewares │ │ │ │ ├── Auth.php.tpl │ │ │ │ └── Guest.php.tpl │ │ │ │ ├── Transformers │ │ │ │ ├── CommentTransformer.php.tpl │ │ │ │ └── PostTransformer.php.tpl │ │ │ │ ├── config │ │ │ │ ├── database.php.tpl │ │ │ │ └── auth.php.tpl │ │ │ │ └── Models │ │ │ │ └── User.php.tpl │ │ ├── DemoApi │ │ │ └── src │ │ │ │ ├── resources │ │ │ │ └── .gitkeep │ │ │ │ ├── Enums │ │ │ │ └── Role.php.tpl │ │ │ │ ├── config │ │ │ │ ├── cors.php.tpl │ │ │ │ ├── database.php.tpl │ │ │ │ └── auth.php.tpl │ │ │ │ ├── Controllers │ │ │ │ ├── OpenApi │ │ │ │ │ └── OpenApiController.php.tpl │ │ │ │ └── BaseController.php.tpl │ │ │ │ ├── Transformers │ │ │ │ ├── CommentTransformer.php.tpl │ │ │ │ └── PostTransformer.php.tpl │ │ │ │ ├── Middlewares │ │ │ │ ├── Signout.php.tpl │ │ │ │ ├── Auth.php.tpl │ │ │ │ └── Comment.php.tpl │ │ │ │ └── Models │ │ │ │ └── User.php.tpl │ │ ├── Toolkit │ │ │ └── src │ │ │ │ ├── Views │ │ │ │ ├── pages │ │ │ │ │ ├── dashboard │ │ │ │ │ │ └── index.php.tpl │ │ │ │ │ ├── logs │ │ │ │ │ │ └── index.php.tpl │ │ │ │ │ ├── email │ │ │ │ │ │ └── index.php.tpl │ │ │ │ │ └── database │ │ │ │ │ │ └── index.php.tpl │ │ │ │ ├── partials │ │ │ │ │ ├── delete-modal.php.tpl │ │ │ │ │ ├── jsoneditor-modal.php.tpl │ │ │ │ │ ├── navbar.php.tpl │ │ │ │ │ ├── database-row.php.tpl │ │ │ │ │ └── email-item.php.tpl │ │ │ │ └── layouts │ │ │ │ │ ├── iframe.php.tpl │ │ │ │ │ └── main.php.tpl │ │ │ │ ├── config │ │ │ │ └── basic_auth.php.tpl │ │ │ │ ├── Services │ │ │ │ └── DashboardService.php.tpl │ │ │ │ └── routes │ │ │ │ └── routes.php.tpl │ │ ├── DefaultApi │ │ │ └── src │ │ │ │ ├── routes │ │ │ │ └── routes.php.tpl │ │ │ │ ├── config │ │ │ │ └── cors.php.tpl │ │ │ │ └── Controllers │ │ │ │ ├── OpenApi │ │ │ │ └── OpenApiController.php.tpl │ │ │ │ └── MainController.php.tpl │ │ └── DefaultWeb │ │ │ └── src │ │ │ ├── routes │ │ │ └── routes.php.tpl │ │ │ └── Views │ │ │ ├── partials │ │ │ └── bubbles.php.tpl │ │ │ ├── index.php.tpl │ │ │ └── layouts │ │ │ └── main.php.tpl │ └── Enums │ │ └── ExceptionMessages.php ├── App │ ├── Config │ │ └── dependencies.php │ ├── Contracts │ │ └── AppInterface.php │ ├── Helpers │ │ ├── uuid.php │ │ └── app.php │ ├── Enums │ │ ├── ReservedKeys.php │ │ └── ExceptionMessages.php │ ├── Exceptions │ │ ├── AppException.php │ │ └── StopExecutionException.php │ └── Adapters │ │ └── AppAdapter.php ├── Config │ ├── Helpers │ │ └── config.php │ ├── Enums │ │ └── ExceptionMessages.php │ └── Exceptions │ │ └── ConfigException.php ├── Hook │ ├── Helpers │ │ └── hook.php │ ├── Enums │ │ └── ExceptionMessages.php │ └── Exceptions │ │ └── HookException.php ├── Libraries │ ├── Cookie │ │ ├── Helpers │ │ │ └── cookie.php │ │ └── Contracts │ │ │ └── CookieStorageInterface.php │ ├── Cache │ │ ├── Exceptions │ │ │ └── CacheException.php │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Helpers │ │ │ └── cache.php │ ├── Mailer │ │ ├── Exceptions │ │ │ └── MailerException.php │ │ └── Helpers │ │ │ └── mailer.php │ ├── Captcha │ │ ├── Exceptions │ │ │ └── CaptchaException.php │ │ └── Helpers │ │ │ └── captcha.php │ ├── ResourceCache │ │ └── Exceptions │ │ │ └── ResourceCacheException.php │ ├── Database │ │ └── Enums │ │ │ ├── Relation.php │ │ │ ├── ExceptionMessages.php │ │ │ └── Key.php │ ├── Jwt │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Exceptions │ │ │ └── JwtException.php │ ├── HttpClient │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Exceptions │ │ │ └── HttpClientException.php │ ├── Transformer │ │ ├── Contracts │ │ │ └── TransformerInterface.php │ │ ├── Helpers │ │ │ └── transformer.php │ │ └── Transformer.php │ ├── Csrf │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ ├── Helpers │ │ │ └── csrf.php │ │ └── Exceptions │ │ │ └── CsrfException.php │ ├── Archive │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Exceptions │ │ │ └── ArchiveException.php │ ├── Asset │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ ├── Helpers │ │ │ └── asset.php │ │ └── Exceptions │ │ │ └── AssetException.php │ ├── Session │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ ├── Helpers │ │ │ └── session.php │ │ ├── Exceptions │ │ │ └── SessionException.php │ │ └── Contracts │ │ │ └── SessionStorageInterface.php │ ├── Hasher │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Exceptions │ │ │ └── HasherException.php │ ├── Logger │ │ ├── Contracts │ │ │ └── ReportableInterface.php │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ ├── Adapters │ │ │ └── MessageAdapter.php │ │ └── Exceptions │ │ │ └── LoggerException.php │ ├── Lang │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ └── Exceptions │ │ │ └── LangException.php │ ├── Encryption │ │ ├── Contracts │ │ │ └── EncryptionInterface.php │ │ └── Enums │ │ │ └── ExceptionMessages.php │ ├── Storage │ │ ├── Helpers │ │ │ └── fs.php │ │ ├── Enums │ │ │ └── ExceptionMessages.php │ │ ├── Contracts │ │ │ ├── TokenServiceInterface.php │ │ │ └── CloudAppInterface.php │ │ └── Exceptions │ │ │ └── FileUploadException.php │ └── Auth │ │ ├── Enums │ │ └── ExceptionMessages.php │ │ ├── Helpers │ │ └── auth.php │ │ └── Contracts │ │ ├── AuthenticatableInterface.php │ │ └── AuthServiceInterface.php ├── Http │ ├── Exceptions │ │ └── HttpException.php │ └── Enums │ │ └── ContentType.php ├── Renderer │ ├── Exceptions │ │ └── RendererException.php │ └── Contracts │ │ └── TemplateRendererInterface.php ├── Service │ ├── Exceptions │ │ └── ServiceException.php │ ├── QtService.php │ └── Helpers │ │ └── service.php ├── Console │ └── Contracts │ │ └── CommandInterface.php ├── Loader │ └── Exceptions │ │ └── LoaderException.php ├── Middleware │ ├── Enums │ │ └── ExceptionMessages.php │ ├── QtMiddleware.php │ └── Exceptions │ │ └── MiddlewareException.php ├── Environment │ ├── Helpers │ │ ├── env.php │ │ └── server.php │ ├── Enums │ │ ├── ExceptionMessages.php │ │ └── Env.php │ └── Exceptions │ │ └── EnvException.php ├── Paginator │ ├── Enums │ │ ├── ExceptionMessages.php │ │ └── Pagination.php │ └── Exceptions │ │ └── PaginatorException.php ├── View │ ├── Enums │ │ └── ExceptionMessages.php │ ├── RawParam.php │ └── Exceptions │ │ └── ViewException.php ├── Migration │ ├── Enums │ │ └── ExceptionMessages.php │ └── QtMigration.php ├── Di │ └── Enums │ │ └── ExceptionMessages.php ├── Model │ └── Enums │ │ └── ExceptionMessages.php └── Router │ └── Exceptions │ └── RouteControllerException.php ├── .gitignore ├── .scrutinizer.yml ├── phpunit.xml ├── .travis.yml └── LICENSE /tests/_root/journal.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/logs/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/_root/shared/store/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/cache/data/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/_root/shared/emails/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/post.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/.env.example: -------------------------------------------------------------------------------- 1 | APP_KEY=XYZ1234567890 2 | DEBUG=TRUE 3 | -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/pages/dashboard/index.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/_root/shared/config/hooks.php: -------------------------------------------------------------------------------- 1 | 'testing' 5 | ]; -------------------------------------------------------------------------------- /tests/_root/php8fe1.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/softberg/quantum-php-core/HEAD/tests/_root/php8fe1.tmp -------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/index.php: -------------------------------------------------------------------------------- 1 |

Hello , this is rendered html view

-------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/index.twig.php: -------------------------------------------------------------------------------- 1 |

Hello {{ (name ?? "World") }}, this is rendered twig view

-------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/partial.php: -------------------------------------------------------------------------------- 1 |

Hello , this is rendered partial html view

-------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /.idea 3 | /nbproject/* 4 | /tests/_root/shared/store/* 5 | composer.lock 6 | .phpunit.result.cache 7 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/layout.twig.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ view() }} 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/Views/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/_root/shared/config/view_cache.php: -------------------------------------------------------------------------------- 1 | 300, 5 | 'cache_dir' => 'cache', 6 | 'minify' => false 7 | ]; 8 | -------------------------------------------------------------------------------- /src/Module/Templates/DefaultApi/src/routes/routes.php.tpl: -------------------------------------------------------------------------------- 1 | get('/', 'MainController', 'index'); 5 | }; -------------------------------------------------------------------------------- /src/Module/Templates/DefaultWeb/src/routes/routes.php.tpl: -------------------------------------------------------------------------------- 1 | get('/', 'MainController', 'index'); 5 | }; -------------------------------------------------------------------------------- /tests/_root/shared/resources/lang/en/custom.php: -------------------------------------------------------------------------------- 1 | 'Learn more', 5 | 'info' => 'Information about the {%1} feature', 6 | 'test' => 'Testing' 7 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/resources/lang/es/custom.php: -------------------------------------------------------------------------------- 1 | 'Aprender más', 5 | 'info' => 'Información sobre la función {%1}', 6 | 'test' => 'Prueba' 7 | ]; -------------------------------------------------------------------------------- /tests/_root/modules/Test/resources/lang/en/custom.php: -------------------------------------------------------------------------------- 1 | 'Learn more', 5 | 'info' => 'Information about the {%1} feature', 6 | 'test' => 'Testing' 7 | ]; -------------------------------------------------------------------------------- /tests/_root/modules/Test/resources/lang/es/custom.php: -------------------------------------------------------------------------------- 1 | 'Aprender más', 5 | 'info' => 'Información sobre la función {%1}', 6 | 'test' => 'Prueba' 7 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/messages/success.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/routes/routes.php: -------------------------------------------------------------------------------- 1 | get("[:alpha:2]?/tests", "TestController", "tests"); 5 | $route->get("[:alpha:2]?/Test/[id=:any]", "TestController", "test"); 6 | }; -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/partials/back.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | arrow_back 3 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/logo.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | <?php echo env('APP_NAME') ?> 3 | -------------------------------------------------------------------------------- /src/App/Config/dependencies.php: -------------------------------------------------------------------------------- 1 | \Quantum\Loader\Loader::class, 5 | \Quantum\Http\Request::class => \Quantum\Http\Request::class, 6 | \Quantum\Http\Response::class => \Quantum\Http\Response::class, 7 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/config/app.php: -------------------------------------------------------------------------------- 1 | 'Quantum PHP Framework', 5 | 'version' => '2.9.5', 6 | 'key' => env('APP_KEY'), 7 | 'base_url' => 'http://localhost', 8 | 'debug' => true, 9 | 'test' => 'Testing', 10 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/config/modules.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'prefix' => 'test', 6 | 'enabled' => true, 7 | ], 8 | 'Meme' => [ 9 | 'prefix' => 'meme', 10 | 'enabled' => false, 11 | ], 12 | ]; 13 | -------------------------------------------------------------------------------- /tests/_root/shared/config/session.php: -------------------------------------------------------------------------------- 1 | 'native', 5 | 6 | 'native' => [ 7 | 'timeout' => 300 8 | ], 9 | 10 | 'database' => [ 11 | 'table' => 'sessions', 12 | 'timeout' => 300, 13 | ] 14 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/bubbles.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Module/Templates/DefaultWeb/src/Views/partials/bubbles.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/shared/config/view.php: -------------------------------------------------------------------------------- 1 | 'html', 4 | 5 | 'html' => [ 6 | 7 | ], 8 | 9 | 'twig' => [ 10 | 'autoescape' => FALSE, 11 | 'charset' => 'UTF-8', 12 | 'debug' => false, 13 | 'cache' => false, 14 | ] 15 | ]; 16 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/Controllers/TestController.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Email Template 6 | 7 | 8 | 9 | 10 |
11 |

Template

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /.scrutinizer.yml: -------------------------------------------------------------------------------- 1 | build: 2 | environment: 3 | php: 4 | version: 7.4 5 | dependencies: 6 | before: 7 | - curl -sS https://getcomposer.org/installer | php -- --2 8 | - mv composer.phar composer 9 | - export PATH="$PWD:$PATH" 10 | tests: 11 | override: 12 | - php-scrutinizer-run -------------------------------------------------------------------------------- /tests/_root/shared/config/logging.php: -------------------------------------------------------------------------------- 1 | 'single', 4 | 5 | 'single' => [ 6 | 'path' => logs_dir() . DS . 'app.log', 7 | 'level' => 'info', 8 | ], 9 | 10 | 'daily' => [ 11 | 'path' => logs_dir(), 12 | 'level' => 'warning', 13 | ] 14 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/views/errors/404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Error Page 400 6 | 7 | 8 | 9 | 10 |
11 |

404

12 |

ERROR PAGE

13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestNotesModel.php: -------------------------------------------------------------------------------- 1 | env('BASIC_AUTH_NAME'), 10 | "password" => env('BASIC_AUTH_PWD') 11 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/config/lang.php: -------------------------------------------------------------------------------- 1 | true, 10 | 'supported' => ['en', 'es'], 11 | 'default' => 'en', 12 | 'url_segment' => 1, 13 | ]; -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestUserProfessionModel.php: -------------------------------------------------------------------------------- 1 | assertNull(env('NEW_ENV_KEY')); 12 | 13 | putenv('NEW_ENV_KEY=New value'); 14 | 15 | $this->assertEquals('New value', env('NEW_ENV_KEY')); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/Helpers/functions.php: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | -------------------------------------------------------------------------------- /tests/_root/modules/Test/config/dependencies.php: -------------------------------------------------------------------------------- 1 | PostTransformer::class, 10 | TokenServiceInterface::class => TokenService::class, 11 | ]; -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/partials/modal.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/shared/config/captcha.php: -------------------------------------------------------------------------------- 1 | 'recaptcha', 5 | 6 | 'recaptcha' => [ 7 | 'type' => 'visible', 8 | 'secret_key' => '10000000-ffff-ffff-ffff-000000000001', 9 | 'site_key' => '0x0000000000000000000000000000000000000000' 10 | ], 11 | 12 | 'hcaptcha' => [ 13 | 'type' => 'visible', 14 | 'secret_key' => '0xE1a02fB374Bf228678E613645295A2d0fD0Dc5Fa', 15 | 'site_key' => '07737dfc-abfa-44e3-a695-66ac44365d0c' 16 | ] 17 | ]; 18 | -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestProductsModel.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Config\Config; 16 | 17 | /** 18 | * Config facade 19 | * @return Config 20 | */ 21 | function config(): Config 22 | { 23 | return Config::getInstance(); 24 | } -------------------------------------------------------------------------------- /tests/_root/shared/config/fs.php: -------------------------------------------------------------------------------- 1 | 'local', 5 | 6 | 'dropbox' => [ 7 | 'service' => Quantum\Tests\_root\shared\Services\TokenService::class, 8 | 'params' => [ 9 | 'app_key' => '', 10 | 'app_secret' => '', 11 | ] 12 | ], 13 | 14 | 'gdrive' => [ 15 | 'service' => Quantum\Tests\_root\shared\Services\TokenService::class, 16 | 'params' => [ 17 | 'app_key' => '', 18 | 'app_secret' => '', 19 | ] 20 | ] 21 | ]; 22 | -------------------------------------------------------------------------------- /src/Module/Templates/DefaultWeb/src/Views/index.php.tpl: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | <?php echo config()->get('app.name') ?> 6 |
7 |

HOME PAGE

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/footer.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/shared/config/cors.php: -------------------------------------------------------------------------------- 1 | '*', 11 | 'Access-Control-Allow-Headers' => '*', 12 | 'Access-Control-Allow-Methods' => '*', 13 | 'Access-Control-Allow-Credentials' => false, 14 | ]; 15 | -------------------------------------------------------------------------------- /src/Hook/Helpers/hook.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Hook\HookManager; 16 | 17 | /** 18 | * Gets the HookManager instance 19 | * @return HookManager 20 | */ 21 | function hook(): HookManager 22 | { 23 | return HookManager::getInstance(); 24 | } -------------------------------------------------------------------------------- /src/Libraries/Cookie/Helpers/cookie.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | use Quantum\Libraries\Cookie\Cookie; 16 | 17 | /** 18 | * Gets cookie handler 19 | * @return Cookie 20 | */ 21 | function cookie(): Cookie 22 | { 23 | return Cookie::getInstance($_COOKIE); 24 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Session/TestCaseHelper.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Enums; 16 | 17 | /** 18 | * Class Role 19 | * @package Modules\{{MODULE_NAME}} 20 | */ 21 | class Role 22 | { 23 | const ADMIN = 'admin'; 24 | 25 | const EDITOR = 'editor'; 26 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Enums/Role.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Enums; 16 | 17 | /** 18 | * Class Role 19 | * @package Modules\{{MODULE_NAME}} 20 | */ 21 | class Role 22 | { 23 | const ADMIN = 'admin'; 24 | 25 | const EDITOR = 'editor'; 26 | } -------------------------------------------------------------------------------- /src/Http/Exceptions/HttpException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Http\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class HttpException 21 | * @package Quantum\Http 22 | */ 23 | class HttpException extends BaseException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/Renderer/Exceptions/RendererException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | namespace Quantum\Renderer\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class RendererException 21 | * @package Quantum\Renderer 22 | */ 23 | class RendererException extends BaseException 24 | { 25 | } -------------------------------------------------------------------------------- /src/Service/Exceptions/ServiceException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Service\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class ServiceException 21 | * @package Quantum\Service 22 | */ 23 | class ServiceException extends BaseException 24 | { 25 | 26 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Transformer/PostTransformer.php: -------------------------------------------------------------------------------- 1 | $item['id'], 14 | 'title' => $item['title'], 15 | 'content' => $item['content'], 16 | 'updated' => $item['updated_at'], 17 | 'author' => $item['user']['firstname'] . ' ' . $item['user']['lastname'] 18 | ]; 19 | } 20 | } -------------------------------------------------------------------------------- /src/Libraries/Cache/Exceptions/CacheException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Cache\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class CacheException 21 | * @package Quantum\Libraries\Cache 22 | */ 23 | class CacheException extends BaseException 24 | { 25 | 26 | } -------------------------------------------------------------------------------- /src/Libraries/Mailer/Exceptions/MailerException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Mailer\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class MailerException 21 | * @package Quantum\Libraries\Mailer 22 | */ 23 | class MailerException extends BaseException 24 | { 25 | 26 | } -------------------------------------------------------------------------------- /src/App/Contracts/AppInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\App\Contracts; 16 | 17 | 18 | /** 19 | * Interface AppInterface 20 | * @package Quantum\App 21 | */ 22 | interface AppInterface 23 | { 24 | /** 25 | * Starts the app 26 | * @return int|null 27 | */ 28 | public function start(): ?int; 29 | } -------------------------------------------------------------------------------- /src/Libraries/Captcha/Exceptions/CaptchaException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | namespace Quantum\Libraries\Captcha\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class CacheException 21 | * @package Quantum\Libraries\Captcha 22 | */ 23 | class CaptchaException extends BaseException 24 | { 25 | 26 | } -------------------------------------------------------------------------------- /tests/_root/shared/Services/TokenService.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.6.0 13 | */ 14 | 15 | namespace Quantum\Console\Contracts; 16 | 17 | /** 18 | * Interface CommandInterface 19 | * @package Quantum\Console 20 | */ 21 | interface CommandInterface 22 | { 23 | /** 24 | * Executes the current command. 25 | */ 26 | public function exec(); 27 | 28 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Database/Adapters/Sleekdb/SleekDbalTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(SleekDbal::class, $userModel); 15 | } 16 | 17 | public function testSleekGetTable() 18 | { 19 | $userModel = new SleekDbal('users'); 20 | 21 | $this->assertEquals('users', $userModel->getTable()); 22 | } 23 | } -------------------------------------------------------------------------------- /src/Loader/Exceptions/LoaderException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | namespace Quantum\Loader\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * DatabaseException class 21 | * 22 | * @package Quantum 23 | * @category Exceptions 24 | */ 25 | class LoaderException extends BaseException 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/Module/Templates/DefaultApi/src/config/cors.php.tpl: -------------------------------------------------------------------------------- 1 | '*', 11 | 'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Authorization, refresh_token', 12 | 'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS', 13 | 'Access-Control-Allow-Credentials' => true, 14 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/config/cors.php.tpl: -------------------------------------------------------------------------------- 1 | '*', 11 | 'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Authorization, refresh_token', 12 | 'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS', 13 | 'Access-Control-Allow-Credentials' => true, 14 | ]; -------------------------------------------------------------------------------- /tests/Unit/Libraries/Database/Adapters/Idiorm/IdiormDbalTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(IdiormDbal::class, $userModel); 14 | } 15 | 16 | public function testIdiormGetTable() 17 | { 18 | $userModel = new IdiormDbal('users'); 19 | 20 | $this->assertEquals('users', $userModel->getTable()); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /tests/_root/shared/config/auth.php: -------------------------------------------------------------------------------- 1 | 'session', 5 | 6 | 'session' => [ 7 | 'service' => Quantum\Tests\_root\modules\Test\Services\AuthService::class 8 | ], 9 | 10 | 'jwt' => [ 11 | 'service' => Quantum\Tests\_root\modules\Test\Services\AuthService::class, 12 | 'claims' => [ 13 | 'jti' => uniqid(), 14 | 'iss' => 'issuer', 15 | 'aud' => 'audience', 16 | 'iat' => time(), 17 | 'nbf' => time() + 1, 18 | 'exp' => time() + 3600 // 1 hour 19 | ] 20 | ], 21 | 22 | 'two_fa' => env('TWO_FA', true), 23 | 'otp_expires' => 2, 24 | ]; 25 | -------------------------------------------------------------------------------- /src/Libraries/ResourceCache/Exceptions/ResourceCacheException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\ResourceCache\Exceptions; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | 19 | /** 20 | * Class ResourceCacheException 21 | * @package Quantum\Libraries\ResourceCache 22 | */ 23 | class ResourceCacheException extends BaseException 24 | { 25 | 26 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/messages/error.php.tpl: -------------------------------------------------------------------------------- 1 |
2 | getFlash('error') ?> 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 |
-------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Services/DashboardService.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace Modules\Toolkit\Services; 16 | 17 | use Quantum\Service\QtService; 18 | 19 | /** 20 | * Class DashboardService 21 | * @package Modules\Toolkit 22 | */ 23 | class DashboardService extends QtService 24 | { 25 | 26 | public function __construct() 27 | { 28 | } 29 | } -------------------------------------------------------------------------------- /src/Libraries/Database/Enums/Relation.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Database\Enums; 16 | 17 | /** 18 | * Class Relation 19 | * @package Quantum\Libraries\Database 20 | */ 21 | class Relation { 22 | const HAS_ONE = 'hasOne'; 23 | const HAS_MANY = 'hasMany'; 24 | const BELONGS_TO = 'belongsTo'; 25 | const BELONGS_TO_MANY = 'belongsToMany'; 26 | } -------------------------------------------------------------------------------- /src/Module/Templates/DefaultWeb/src/Views/layouts/main.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php echo $title ?> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/partials/language.php.tpl: -------------------------------------------------------------------------------- 1 |
  • 2 | 3 | language 4 | 5 | 14 |
  • -------------------------------------------------------------------------------- /tests/Unit/Libraries/Csrf/Helpers/CsrfHelperFunctionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Csrf::class, csrf()); 14 | } 15 | 16 | public function testCsrfToken() 17 | { 18 | $request = new Request(); 19 | 20 | $request->create('PUT', '/update', ['title' => 'Task Title', 'csrf-token' => csrf_token()]); 21 | 22 | $this->assertTrue(csrf()->checkToken($request)); 23 | } 24 | } -------------------------------------------------------------------------------- /tests/_root/shared/config/mailer.php: -------------------------------------------------------------------------------- 1 | 'smtp', 5 | 6 | 'mail_trap' => true, 7 | 8 | 'smtp' => [ 9 | 'host' => '127.0.0.1', 10 | 'secure' => 'ssl', 11 | 'port' => '80', 12 | 'username' => 'test', 13 | 'password' => 'test' 14 | ], 15 | 16 | 'sendinblue' => [ 17 | 'api_key' => 'sendinblue_api_key', 18 | ], 19 | 20 | 'sendgrid' => [ 21 | 'api_key' => 'sendgrid_api_key', 22 | ], 23 | 24 | 'mandrill' => [ 25 | 'api_key' => 'mandrill_api_key' 26 | ], 27 | 28 | 'mailgun' => [ 29 | 'api_key' => 'mailgun_api_key', 30 | 'domain' => 'mailgun_domain', 31 | ], 32 | ]; 33 | -------------------------------------------------------------------------------- /src/Config/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Config\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Config 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const CONFIG_COLLISION = 'Config key `{%1}` is already in use'; 26 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/partials/jsoneditor-modal.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Libraries/Jwt/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Jwt\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Jwt 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const MISSING_PAYLOAD = 'JWT payload is missing.'; 26 | } -------------------------------------------------------------------------------- /src/Middleware/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Middleware\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Middleware 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const MIDDLEWARE_NOT_FOUND = 'Middleware class `{%1}` not found.'; 26 | } -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | 18 | 19 | ./src 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestTicketModel.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'type' => Relation::HAS_MANY, 25 | 'foreign_key' => 'ticket_id', 26 | 'local_key' => 'id' 27 | ] 28 | ]; 29 | } 30 | } -------------------------------------------------------------------------------- /src/Environment/Helpers/env.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Environment\Exceptions\EnvException; 16 | use Quantum\Environment\Environment; 17 | 18 | /** 19 | * Gets environment variable 20 | * @param string $var 21 | * @param $default 22 | * @return mixed 23 | * @throws EnvException 24 | */ 25 | function env(string $var, $default = null) 26 | { 27 | return Environment::getInstance()->getValue($var, $default); 28 | } -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestEventModel.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'type' => Relation::HAS_MANY, 25 | 'foreign_key' => 'event_id', 26 | 'local_key' => 'id' 27 | ] 28 | ]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Libraries/Cache/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Cache\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Cache 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const ARGUMENT_NOT_ITERABLE = 'The argument {%1} is not iterable'; 26 | } -------------------------------------------------------------------------------- /src/Libraries/HttpClient/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\HttpClient\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\HttpClient 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const REQUEST_NOT_CREATED = 'Request is not created.'; 26 | } -------------------------------------------------------------------------------- /src/App/Helpers/uuid.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | use Ramsey\Uuid\Uuid; 16 | 17 | /** 18 | * Generate a standard v4 UUID (random) 19 | * @return string 20 | */ 21 | function uuid_random(): string 22 | { 23 | return Uuid::uuid4()->toString(); 24 | } 25 | 26 | /** 27 | * Generate an ordered UUID (time-based) 28 | * @return string 29 | */ 30 | function uuid_ordered(): string 31 | { 32 | return Uuid::uuid1()->toString(); 33 | } 34 | -------------------------------------------------------------------------------- /src/Libraries/Transformer/Contracts/TransformerInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.8.0 13 | */ 14 | 15 | namespace Quantum\Libraries\Transformer\Contracts; 16 | 17 | /** 18 | * Interface TransformerInterface 19 | * @package Quantum\Libraries\Transformer 20 | */ 21 | interface TransformerInterface 22 | { 23 | 24 | /** 25 | * Defines the transformer signature 26 | * @param mixed $item 27 | */ 28 | public function transform($item); 29 | } -------------------------------------------------------------------------------- /src/Paginator/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Paginator\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Paginator 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const MISSING_REQUIRED_PARAMS = 'Missing required parameter `{%1}` missing for adapter {%2}'; 26 | } -------------------------------------------------------------------------------- /src/View/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\View\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\View 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const LAYOUT_NOT_SET = 'Layout is not set.'; 26 | 27 | const VIEW_NOT_RENDERED_YET = 'View not rendered yet.'; 28 | } -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestUserMeetingModel.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'type' => Relation::HAS_MANY, 25 | 'foreign_key' => 'meeting_id', 26 | 'local_key' => 'id' 27 | ] 28 | ]; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/partials/navbar.php.tpl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestUserEventModel.php: -------------------------------------------------------------------------------- 1 | [ 25 | 'type' => Relation::BELONGS_TO, 26 | 'foreign_key' => 'event_id', 27 | 'local_key' => 'id' 28 | ] 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Hook/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Hook\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Hook 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const DUPLICATE_HOOK_NAME = 'The Hook `{%1}` already registered.'; 26 | 27 | const UNREGISTERED_HOOK_NAME = 'The Hook `{%1}` was not registered.'; 28 | } -------------------------------------------------------------------------------- /src/App/Enums/ReservedKeys.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\App\Enums; 16 | 17 | /** 18 | * Class ReservedKeys 19 | * @package Quantum\App 20 | */ 21 | final class ReservedKeys 22 | { 23 | 24 | /** 25 | * Internal response key for rendered view 26 | */ 27 | public const RENDERED_VIEW = '_qt_rendered_view'; 28 | 29 | /** 30 | * Internal session key for previous request 31 | */ 32 | public const PREV_REQUEST = '_qt_prev_request'; 33 | 34 | } -------------------------------------------------------------------------------- /src/App/Helpers/app.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\App\Exceptions\StopExecutionException; 16 | 17 | /** 18 | * Stops the app execution 19 | * @param Closure|null $closure 20 | * @param int|null $code 21 | * @return mixed 22 | * @throws StopExecutionException 23 | */ 24 | function stop(?Closure $closure = null, ?int $code = 0) 25 | { 26 | if ($closure) { 27 | $closure(); 28 | } 29 | 30 | throw StopExecutionException::executionTerminated($code); 31 | } 32 | -------------------------------------------------------------------------------- /src/Libraries/Csrf/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Csrf\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Csrf 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const CSRF_TOKEN_MISSING = 'CSRF Token is missing'; 26 | 27 | const CSRF_TOKEN_MISMATCH = 'CSRF Token does not matched'; 28 | } -------------------------------------------------------------------------------- /src/Renderer/Contracts/TemplateRendererInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Renderer\Contracts; 16 | 17 | /** 18 | * Interface TemplateRendererInterface 19 | * @package Quantum\Renderer 20 | */ 21 | interface TemplateRendererInterface 22 | { 23 | /** 24 | * Renders the template 25 | * @param string $view 26 | * @param array $params 27 | * @return string 28 | */ 29 | public function render(string $view, array $params = []): string; 30 | } -------------------------------------------------------------------------------- /tests/_root/shared/config/cache.php: -------------------------------------------------------------------------------- 1 | 'file', 4 | 5 | 'file' => [ 6 | 'prefix' => str_replace(' ', '', env('APP_NAME')), 7 | 'path' => base_dir() . DS . 'cache' . DS . 'data', 8 | 'ttl' => 600 9 | ], 10 | 11 | 'database' => [ 12 | 'prefix' => str_replace(' ', '', env('APP_NAME')), 13 | 'table' => 'cache', 14 | 'ttl' => 60 15 | ], 16 | 'memcached' => [ 17 | 'prefix' => str_replace(' ', '', env('APP_NAME')), 18 | 'host' => '127.0.0.1', 19 | 'port' => 11211, 20 | 'ttl' => 60 21 | ], 22 | 23 | 'redis' => [ 24 | 'prefix' => str_replace(' ', '', env('APP_NAME')), 25 | 'host' => '127.0.0.1', 26 | 'port' => 6379, 27 | 'ttl' => 60 28 | ] 29 | ]; -------------------------------------------------------------------------------- /src/Libraries/Archive/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Archive\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Archive 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const CANT_OPEN = 'The archive `{%1}` can not be opened'; 26 | 27 | const NAME_NOT_SET = 'Archive name is not set'; 28 | } -------------------------------------------------------------------------------- /src/Libraries/Asset/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Asset\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Asset 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const POSITION_IN_USE = 'Position `{%1}` for asset `{%2}` is in use'; 26 | 27 | const NAME_IN_USE = 'The name {%1} is in use'; 28 | } -------------------------------------------------------------------------------- /tests/_root/shared/config/uploads.php: -------------------------------------------------------------------------------- 1 | extensions map for UploadedFile validation. 6 | */ 7 | 'allowed_mime_types' => [ 8 | // Images 9 | 'image/jpeg' => ['jpg', 'jpeg'], 10 | 'image/png' => ['png'], 11 | 'image/gif' => ['gif'], 12 | 'image/webp' => ['webp'], 13 | 'image/svg+xml' => ['svg'], 14 | // Audio 15 | 'audio/mpeg' => ['mp3'], 16 | 'audio/wav' => ['wav'], 17 | 'audio/ogg' => ['ogg'], 18 | 'audio/webm' => ['weba'], 19 | // Video 20 | 'video/mp4' => ['mp4'], 21 | 'video/mpeg' => ['mpeg', 'mpg'], 22 | 'video/quicktime' => ['mov'], 23 | 'video/webm' => ['webm'], 24 | 'video/x-msvideo' => ['avi'], 25 | ], 26 | ]; -------------------------------------------------------------------------------- /src/Libraries/Session/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Session\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Session 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const SESSION_NOT_STARTED = 'Can not start the session.'; 26 | 27 | const SESSION_NOT_DESTROYED = 'Can not destroy the session.'; 28 | } -------------------------------------------------------------------------------- /src/App/Exceptions/AppException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\App\Exceptions; 16 | 17 | use Quantum\App\Enums\ExceptionMessages; 18 | 19 | /** 20 | * Class AppException 21 | * @package Quantum\App 22 | */ 23 | class AppException extends BaseException 24 | { 25 | 26 | /** 27 | * @return AppException 28 | */ 29 | public static function missingAppKey(): AppException 30 | { 31 | return new static(ExceptionMessages::APP_KEY_MISSING, E_ERROR); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestProfileModel.php: -------------------------------------------------------------------------------- 1 | [ 27 | 'type' => Relation::BELONGS_TO, 28 | 'foreign_key' => 'user_id', 29 | 'local_key' => 'id' 30 | ], 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Libraries/Hasher/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Hasher\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Hasher 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const ALGORITHM_NOT_SUPPORTED = 'The algorithm {%1} not supported.'; 26 | 27 | const INVALID_BCRYPT_COST = 'Provided bcrypt cost is invalid.'; 28 | } -------------------------------------------------------------------------------- /src/Libraries/Logger/Contracts/ReportableInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Logger\Contracts; 16 | 17 | /** 18 | * Interface ReportableInterface 19 | * @package Quantum\Logger 20 | */ 21 | interface ReportableInterface 22 | { 23 | 24 | /** 25 | * Reports the message 26 | * @param string $level 27 | * @param mixed $message 28 | * @param array|null $context 29 | */ 30 | public function report(string $level, $message, ?array $context = []); 31 | 32 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/pages/logs/index.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 |
    5 |
      6 | 7 |
    • 8 | 9 |
    • 10 | 11 |
    12 |
    13 |
    14 | 15 |
    16 |
    17 | 18 |
    No log found.
    19 | 20 |
    21 | 22 | -------------------------------------------------------------------------------- /src/Libraries/Lang/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Lang\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Lang 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const TRANSLATION_FILES_NOT_FOUND = 'Translation files not found.'; 26 | 27 | const MISCONFIGURED_DEFAULT_LANG = 'Misconfigured lang default config.'; 28 | } -------------------------------------------------------------------------------- /src/Libraries/Logger/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Logger\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Logger 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const LOG_PATH_NOT_DIRECTORY = 'Log path is not point to a directory.'; 26 | 27 | const LOG_PATH_NOT_FILE = 'Log path is not point to a file.'; 28 | } -------------------------------------------------------------------------------- /src/Libraries/Transformer/Helpers/transformer.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 16 | use Quantum\Libraries\Transformer\Transformer; 17 | 18 | /** 19 | * Transforms the data by given transformer signature 20 | * @param array $data 21 | * @param TransformerInterface $transformer 22 | * @return array 23 | */ 24 | function transform(array $data, TransformerInterface $transformer): array 25 | { 26 | return Transformer::transform($data, $transformer); 27 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Cookie/Helpers/CookieHelperFunctionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Cookie::class, cookie()); 13 | } 14 | 15 | public function testCookieMethodsViaHelper() 16 | { 17 | $this->assertFalse(cookie()->has('test')); 18 | 19 | cookie()->set('test', 'Testing'); 20 | 21 | $this->assertTrue(cookie()->has('test')); 22 | 23 | $this->assertEquals('Testing', cookie()->get('test')); 24 | 25 | cookie()->delete('test'); 26 | 27 | $this->assertFalse(cookie()->has('test')); 28 | } 29 | } -------------------------------------------------------------------------------- /tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(TokenService::class, $service); 17 | 18 | $this->assertInstanceOf(QtService::class, $service); 19 | } 20 | 21 | public function testModelThrowsOnInvalidClass() 22 | { 23 | $this->expectException(ServiceException::class); 24 | 25 | service('NonExistentServiceClass'); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/layouts/iframe.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
    20 | 21 |
    22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Environment/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Environment\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Environment 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const IMMUTABLE_ENVIRONMENT = 'The environment is immutable. Modifications are not allowed.'; 26 | 27 | const ENVIRONMENT_NOT_LOADED = 'Environment not loaded. Call `load()` method first.'; 28 | } -------------------------------------------------------------------------------- /tests/Unit/View/Factories/ViewFactoryTest.php: -------------------------------------------------------------------------------- 1 | viewFactory = new ViewFactory(); 19 | } 20 | 21 | public function testGetInstance() 22 | { 23 | $this->assertInstanceOf(QtView::class, $this->viewFactory->get()); 24 | } 25 | 26 | public function testProxyCalls() 27 | { 28 | $view = $this->viewFactory->get(); 29 | 30 | $view->setParam('key', 'Value'); 31 | 32 | $this->assertEquals('Value', $view->getParam('key')); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/layouts/main.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php echo $title ?> 7 | 8 | 9 | 10 | 11 | 12 | 13 |
    14 | 15 |
    16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Migration/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Migration\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Migration 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const WRONG_MIGRATION_DIRECTION = 'Migration direction can only be [up] or [down]'; 26 | 27 | const NOT_SUPPORTED_ACTION = 'The action `{%1}`, is not supported'; 28 | 29 | const NOTHING_TO_MIGRATE = 'Nothing to migrate'; 30 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/partials/comment-form.php.tpl: -------------------------------------------------------------------------------- 1 | has('error')) : ?> 2 | 3 | 4 |
    6 |
    7 | 8 | 10 |
    11 | 12 | 14 |
    -------------------------------------------------------------------------------- /src/Libraries/Encryption/Contracts/EncryptionInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Encryption\Contracts; 16 | 17 | /** 18 | * Interface EncryptionInterface 19 | * @package Quantum\Libraries\Encryption 20 | */ 21 | interface EncryptionInterface 22 | { 23 | 24 | /** 25 | * @param string $plain 26 | * @return string 27 | */ 28 | public function encrypt(string $plain): string; 29 | 30 | /** 31 | * @param string $encrypted 32 | * @return string 33 | */ 34 | public function decrypt(string $encrypted): string; 35 | } -------------------------------------------------------------------------------- /src/Libraries/Encryption/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Encryption\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Encryption 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const PUBLIC_KEY_MISSING = 'Public key is not provided'; 26 | 27 | const PRIVATE_KEY_MISSING = 'Private key is not provided'; 28 | 29 | const INVALID_CIPHER = 'The cipher is invalid'; 30 | 31 | 32 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/post.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |

    3 |
    4 | 5 | 6 | $post]) ?> 7 | 8 | 9 |
    10 | 11 |

    ...

    12 | 13 | 14 | 15 |
    16 | getPagination(0, 5) ?> 17 |
    18 | 19 | t('common.post')]) ?> 20 |
    -------------------------------------------------------------------------------- /src/Libraries/Jwt/Exceptions/JwtException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Jwt\Exceptions; 16 | 17 | use Quantum\Libraries\Jwt\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class JwtException 22 | * @package Quantum\Libraries\JwtToken 23 | */ 24 | class JwtException extends BaseException 25 | { 26 | 27 | /** 28 | * @return JwtException 29 | */ 30 | public static function payloadNotFound(): JwtException 31 | { 32 | return new static(ExceptionMessages::MISSING_PAYLOAD, E_WARNING); 33 | } 34 | } -------------------------------------------------------------------------------- /src/View/RawParam.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | namespace Quantum\View; 16 | 17 | /** 18 | * Class RawParam 19 | * @package Quantum\View 20 | */ 21 | class RawParam 22 | { 23 | /** 24 | * @var mixed 25 | */ 26 | private $value; 27 | 28 | /** 29 | * @param mixed $value 30 | */ 31 | public function __construct($value) 32 | { 33 | $this->value = $value; 34 | } 35 | 36 | /** 37 | * Gets the raw value. 38 | * @return mixed 39 | */ 40 | public function getValue() 41 | { 42 | return $this->value; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/App/Exceptions/StopExecutionException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\App\Exceptions; 16 | 17 | use Quantum\App\Enums\ExceptionMessages; 18 | 19 | /** 20 | * Class StopExecutionException 21 | * @package Quantum\App 22 | */ 23 | class StopExecutionException extends BaseException 24 | { 25 | 26 | /** 27 | * @param int|null $code 28 | * @return StopExecutionException 29 | */ 30 | public static function executionTerminated(?int $code): StopExecutionException 31 | { 32 | return new static(ExceptionMessages::EXECUTION_TERMINATED, $code); 33 | } 34 | } -------------------------------------------------------------------------------- /src/Libraries/Cache/Helpers/cache.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Cache\Factories\CacheFactory; 16 | use Quantum\Config\Exceptions\ConfigException; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Di\Exceptions\DiException; 19 | use Quantum\Libraries\Cache\Cache; 20 | 21 | /** 22 | * @param string|null $adapter 23 | * @return Cache 24 | * @throws BaseException 25 | * @throws ConfigException 26 | * @throws DiException 27 | * @throws ReflectionException 28 | */ 29 | function cache(?string $adapter = null): Cache 30 | { 31 | return CacheFactory::get($adapter); 32 | } -------------------------------------------------------------------------------- /tests/_root/shared/config/database.php: -------------------------------------------------------------------------------- 1 | 'sqlite', 5 | 'mysql' => [ 6 | 'driver' => 'mysql', 7 | 'host' => 'localhost', 8 | 'dbname' => 'database', 9 | 'username' => 'username', 10 | 'password' => 'password', 11 | 'charset' => 'charset', 12 | ], 13 | 'sqlite' => [ 14 | 'driver' => 'sqlite', 15 | 'database' => ':memory:', 16 | ], 17 | 'sleekdb' => [ 18 | 'config' => [ 19 | 'auto_cache' => true, 20 | 'cache_lifetime' => null, 21 | 'timeout' => false, 22 | 'search' => [ 23 | 'min_length' => 2, 24 | 'mode' => 'or', 25 | 'score_key' => 'scoreKey', 26 | 'algorithm' => 1 27 | ], 28 | ], 29 | 'database_dir' => base_dir() . DS . 'shared' . DS . 'store', 30 | ] 31 | ]; -------------------------------------------------------------------------------- /src/Libraries/Mailer/Helpers/mailer.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Mailer\Factories\MailerFactory; 16 | use Quantum\Config\Exceptions\ConfigException; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Di\Exceptions\DiException; 19 | use Quantum\Libraries\Mailer\Mailer; 20 | 21 | /** 22 | * @param string|null $adapter 23 | * @return Mailer 24 | * @throws BaseException 25 | * @throws ConfigException 26 | * @throws DiException 27 | * @throws ReflectionException 28 | */ 29 | function mailer(?string $adapter = null): Mailer 30 | { 31 | return MailerFactory::get($adapter); 32 | } -------------------------------------------------------------------------------- /src/Libraries/Captcha/Helpers/captcha.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Captcha\Factories\CaptchaFactory; 16 | use Quantum\Config\Exceptions\ConfigException; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Di\Exceptions\DiException; 19 | use Quantum\Libraries\Captcha\Captcha; 20 | 21 | /** 22 | * @param string|null $adapter 23 | * @return Captcha 24 | * @throws BaseException 25 | * @throws ConfigException 26 | * @throws DiException 27 | * @throws ReflectionException 28 | */ 29 | function captcha(?string $adapter = null): Captcha 30 | { 31 | return CaptchaFactory::get($adapter); 32 | } -------------------------------------------------------------------------------- /src/Libraries/Session/Helpers/session.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Session\Factories\SessionFactory; 16 | use Quantum\Config\Exceptions\ConfigException; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Di\Exceptions\DiException; 19 | use Quantum\Libraries\Session\Session; 20 | 21 | /** 22 | * @param string|null $adapter 23 | * @return Session 24 | * @throws BaseException 25 | * @throws ConfigException 26 | * @throws DiException 27 | * @throws ReflectionException 28 | */ 29 | function session(?string $adapter = null): Session 30 | { 31 | return SessionFactory::get($adapter); 32 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/partials/database-row.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | $column ?> 4 | 5 | 6 | 9 | 16 | 17 | -------------------------------------------------------------------------------- /tests/Unit/Libraries/Mailer/MailerTestCase.php: -------------------------------------------------------------------------------- 1 | \Quantum\Loader\Loader::class, 16 | \Quantum\Http\Request::class => \Quantum\Http\Request::class, 17 | \Quantum\Http\Response::class => \Quantum\Http\Response::class, 18 | ]; 19 | 20 | Di::registerDependencies($coreDependencies); 21 | 22 | $emailFile = base_dir() . DS . 'shared' . DS . 'emails' . DS . $this->adapter->getMessageId() . '.eml'; 23 | 24 | if($this->fs->exists($emailFile)) { 25 | $this->fs->remove($emailFile); 26 | } 27 | 28 | Di::reset(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/Config/Exceptions/ConfigException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Config\Exceptions; 16 | 17 | use Quantum\Config\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class ConfigException 22 | * @package Quantum\Config 23 | */ 24 | class ConfigException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string $name 29 | * @return ConfigException 30 | */ 31 | public static function configCollision(string $name): ConfigException 32 | { 33 | return new static(_message(ExceptionMessages::CONFIG_COLLISION, [$name]), E_WARNING); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Libraries/HttpClient/Exceptions/HttpClientException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\HttpClient\Exceptions; 16 | 17 | use Quantum\Libraries\HttpClient\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class HasherException 22 | * @package Quantum\Libraries\Hasher 23 | */ 24 | class HttpClientException extends BaseException 25 | { 26 | 27 | /** 28 | * @return HttpClientException 29 | */ 30 | 31 | public static function requestNotCreated(): self 32 | { 33 | return new static(ExceptionMessages::REQUEST_NOT_CREATED, E_WARNING); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Middleware/QtMiddleware.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.0.0 13 | */ 14 | 15 | namespace Quantum\Middleware; 16 | 17 | use Quantum\Http\Request; 18 | use Quantum\Http\Response; 19 | use Closure; 20 | 21 | /** 22 | * Class QtMiddleware 23 | * @package Quantum\Middleware 24 | */ 25 | abstract class QtMiddleware 26 | { 27 | 28 | /** 29 | * Apply 30 | * 31 | * Applies the middleware 32 | * 33 | * @param Request $request 34 | * @param Response $response 35 | * @param Closure $next 36 | * @return mixed 37 | */ 38 | abstract public function apply(Request $request, Response $response, Closure $next); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Controllers/OpenApi/OpenApiController.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Controllers\OpenApi; 16 | 17 | /** 18 | * Class OpenApiController 19 | * @package Modules\Api 20 | * @OA\Info( 21 | * title="Quantum API documentation", 22 | * version="2.9.0", 23 | * description=" *Quantum Documentation: https://quantumphp.io/en/docs/v1/overview" 24 | * ), 25 | * @OA\SecurityScheme( 26 | * securityScheme="bearer_token", 27 | * type="apiKey", 28 | * name="Authorization", 29 | * in="header" 30 | * ) 31 | */ 32 | abstract class OpenApiController 33 | { 34 | 35 | } -------------------------------------------------------------------------------- /src/Service/QtService.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Service; 16 | 17 | use Quantum\Service\Exceptions\ServiceException; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class QtService 22 | * @package Quantum\Service 23 | */ 24 | class QtService 25 | { 26 | 27 | /** 28 | * Handles the missing methods of the service 29 | * @param string $method 30 | * @param array $arguments 31 | * @throws BaseException 32 | */ 33 | public function __call(string $method, array $arguments) 34 | { 35 | throw ServiceException::methodNotSupported($method, QtService::class); 36 | } 37 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Controllers/BaseController.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Controllers; 16 | 17 | use Quantum\Router\RouteController; 18 | 19 | /** 20 | * Class BaseController 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | abstract class BaseController extends RouteController 24 | { 25 | 26 | /** 27 | * Status error 28 | */ 29 | const STATUS_ERROR = 'error'; 30 | 31 | /** 32 | * Status success 33 | */ 34 | const STATUS_SUCCESS = 'success'; 35 | 36 | /** 37 | * CSRF verification 38 | * @var bool 39 | */ 40 | public $csrfVerification = false; 41 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/pages/index.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
    5 | 6 |
    7 |

    8 |
    9 |
    10 |
    11 |
    12 |
    13 | 17 |
    18 |
    19 |
    20 | -------------------------------------------------------------------------------- /src/Libraries/Csrf/Helpers/csrf.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\App\Exceptions\BaseException; 16 | use Quantum\App\Exceptions\AppException; 17 | use Quantum\Libraries\Csrf\Csrf; 18 | 19 | /** 20 | * Gets the Csrf instance 21 | * @return Csrf 22 | */ 23 | function csrf(): Csrf 24 | { 25 | return Csrf::getInstance(); 26 | } 27 | 28 | /** 29 | * Generates the CSRF token 30 | * @return string|null 31 | * @throws BaseException 32 | */ 33 | function csrf_token(): ?string 34 | { 35 | $appKey = env('APP_KEY'); 36 | 37 | if (!$appKey) { 38 | throw AppException::missingAppKey(); 39 | } 40 | 41 | return csrf()->generateToken($appKey); 42 | } -------------------------------------------------------------------------------- /src/Libraries/Storage/Helpers/fs.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Storage\Factories\FileSystemFactory; 16 | use Quantum\Config\Exceptions\ConfigException; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Libraries\Storage\FileSystem; 19 | use Quantum\Di\Exceptions\DiException; 20 | 21 | 22 | /** 23 | * Gets the FileSystem handler 24 | * @param string|null $adapter 25 | * @return FileSystem 26 | * @throws BaseException 27 | * @throws ConfigException 28 | * @throws DiException 29 | * @throws ReflectionException 30 | */ 31 | function fs(?string $adapter = null): FileSystem 32 | { 33 | return FileSystemFactory::get($adapter); 34 | } -------------------------------------------------------------------------------- /tests/Unit/Renderer/Adapters/HtmlAdapterTest.php: -------------------------------------------------------------------------------- 1 | "test", 17 | "method" => "GET", 18 | "controller" => "SomeController", 19 | "action" => "test", 20 | "module" => "Test" 21 | ]); 22 | } 23 | 24 | public function testHtmlAdapterRenderView(): void 25 | { 26 | $adapter = new HtmlAdapter(); 27 | 28 | $output = $adapter->render('index', ['name' => 'Tester']); 29 | 30 | $this->assertIsString($output); 31 | 32 | $this->assertSame('

    Hello Tester, this is rendered html view

    ', $output); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/routes/routes.php.tpl: -------------------------------------------------------------------------------- 1 | group('auth', function ($route) { 5 | $route->get('/', 'DashboardController', 'index'); 6 | 7 | $route->get('emails', 'EmailsController', 'list'); 8 | $route->get('email/[:any]', 'EmailsController', 'single'); 9 | $route->get('email/delete/[:any]', 'EmailsController', 'delete'); 10 | 11 | $route->get('logs', 'LogsController', 'list'); 12 | $route->get('logs/view', 'LogsController', 'single'); 13 | 14 | $route->get('database', 'DatabaseController', 'list'); 15 | $route->get('database/view', 'DatabaseController', 'single'); 16 | $route->post('database/create', 'DatabaseController', 'create')->middlewares(['UniqueTable']); 17 | $route->post('database/update', 'DatabaseController', 'update'); 18 | $route->get('database/delete', 'DatabaseController', 'delete'); 19 | })->middlewares(['BasicAuth']); 20 | }; -------------------------------------------------------------------------------- /tests/Unit/Renderer/Adapters/TwigAdapterTest.php: -------------------------------------------------------------------------------- 1 | "test", 17 | "method" => "GET", 18 | "controller" => "SomeController", 19 | "action" => "test", 20 | "module" => "Test" 21 | ]); 22 | } 23 | 24 | public function testHtmlAdapterRenderView(): void 25 | { 26 | $adapter = new TwigAdapter(); 27 | 28 | $output = $adapter->render('index.twig', ['name' => 'Tester']); 29 | 30 | $this->assertIsString($output); 31 | 32 | $this->assertSame('

    Hello Tester, this is rendered twig view

    ', $output); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/Libraries/Database/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Database\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Database 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const INCORRECT_CONFIG = 'The structure of config is not correct'; 26 | 27 | const NOT_SUPPORTED_OPERATOR = 'The operator `{%1}` is not supported'; 28 | 29 | const TABLE_ALREADY_EXISTS = 'The table `{%1}` is already exists'; 30 | 31 | const TABLE_NOT_EXISTS = 'The table `{%1}` does not exists'; 32 | } -------------------------------------------------------------------------------- /src/Libraries/Storage/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Storage\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Session 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const DIRECTORY_NOT_EXISTS = 'The directory {%1} does not exists.'; 26 | 27 | const DIRECTORY_NOT_WRITABLE = 'The directory {%1} is not writable.'; 28 | 29 | const FILE_ALREADY_EXISTS = 'The file {%1} already exists.'; 30 | 31 | const FILE_TYPE_NOT_ALLOWED = 'The file type `{%1}` is not allowed.'; 32 | } -------------------------------------------------------------------------------- /src/Middleware/Exceptions/MiddlewareException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Middleware\Exceptions; 16 | 17 | use Quantum\Middleware\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class MiddlewareException 22 | * @package Quantum\Exceptions 23 | */ 24 | class MiddlewareException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string $name 29 | * @return MiddlewareException 30 | */ 31 | public static function middlewareNotFound(string $name): MiddlewareException 32 | { 33 | return new static(_message(ExceptionMessages::MIDDLEWARE_NOT_FOUND, [$name]), E_ERROR); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Migration/QtMigration.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.7.0 13 | */ 14 | 15 | namespace Quantum\Migration; 16 | 17 | use Quantum\Libraries\Database\Factories\TableFactory; 18 | 19 | /** 20 | * Class QtMigration 21 | * @package Quantum\Migration 22 | */ 23 | abstract class QtMigration 24 | { 25 | 26 | /** 27 | * Upgrades with the specified migration class 28 | * @param TableFactory|null $tableFactory 29 | */ 30 | abstract public function up(?TableFactory $tableFactory); 31 | 32 | /** 33 | * Downgrades with the specified migration class 34 | * @param TableFactory|null $tableFactory 35 | */ 36 | abstract public function down(?TableFactory $tableFactory); 37 | } -------------------------------------------------------------------------------- /src/Libraries/Asset/Helpers/asset.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | use Quantum\Libraries\Asset\Exceptions\AssetException; 16 | use Quantum\Libraries\Lang\Exceptions\LangException; 17 | use Quantum\Libraries\Asset\AssetManager; 18 | 19 | /** 20 | * Gets the AssetFactory instance 21 | * @return AssetManager|null 22 | */ 23 | function asset(): ?AssetManager 24 | { 25 | return AssetManager::getInstance(); 26 | } 27 | 28 | /** 29 | * Dumps the assets 30 | * @param string $type 31 | * @return void 32 | * @throws AssetException 33 | * @throws LangException 34 | */ 35 | function assets(string $type): void 36 | { 37 | AssetManager::getInstance()->dump(AssetManager::STORES[$type]); 38 | } -------------------------------------------------------------------------------- /src/Module/Templates/DefaultApi/src/Controllers/OpenApi/OpenApiController.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Controllers\OpenApi; 16 | 17 | use Quantum\Router\RouteController; 18 | 19 | /** 20 | * Class ApiController 21 | * @package Modules\Api 22 | * @OA\Info( 23 | * title="Quantum API documentation", 24 | * version="2.9.0", 25 | * description=" *Quantum Documentation: https://quantumphp.io/en/docs/v1/overview" 26 | * ), 27 | * @OA\SecurityScheme( 28 | * securityScheme="bearer_token", 29 | * type="apiKey", 30 | * name="Authorization", 31 | * in="header" 32 | * ) 33 | */ 34 | abstract class OpenApiController 35 | { 36 | 37 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/comments.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |

    3 | 4 | 5 | 10 | 11 |

    12 | 13 | 14 | check()): ?> 15 | $post]) ?> 16 | 17 |
    18 |
    19 | report_problem 20 | 21 |
    22 |
    23 | 24 |
    25 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/single.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |
    3 | 4 |

    5 |
    6 | 7 | 8 |
    9 | 10 | 11 | 12 | 13 |
    14 | 15 |
    16 | 17 | $post, 19 | 'comments' => $comments 20 | ]) ?> 21 |
    22 |
    -------------------------------------------------------------------------------- /src/Libraries/Transformer/Transformer.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Transformer; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class TransformerManager 21 | * @package Quantum\Libraries\Transformer 22 | */ 23 | class Transformer 24 | { 25 | 26 | /** 27 | * Applies the transformer on each item of the array 28 | * @param array $data 29 | * @param TransformerInterface $transformer 30 | * @return array 31 | */ 32 | public static function transform(array $data, TransformerInterface $transformer): array 33 | { 34 | return array_map([$transformer, 'transform'], $data); 35 | } 36 | } -------------------------------------------------------------------------------- /src/Libraries/Database/Enums/Key.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Database\Enums; 16 | 17 | /** 18 | * Class Key 19 | * @package Quantum\Libraries\Database 20 | */ 21 | class Key 22 | { 23 | 24 | /** 25 | * Primary key definition 26 | */ 27 | const PRIMARY = 'primary'; 28 | 29 | /** 30 | * Index key definition 31 | */ 32 | const INDEX = 'index'; 33 | 34 | /** 35 | * Unique key definition 36 | */ 37 | const UNIQUE = 'unique'; 38 | 39 | /** 40 | * Full-text key definition 41 | */ 42 | const FULLTEXT = 'fulltext'; 43 | 44 | /** 45 | * Spatial key definition 46 | */ 47 | const SPATIAL = 'spatial'; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tests/Unit/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php: -------------------------------------------------------------------------------- 1 | shouldReceive('getRefreshToken')->andReturnUsing(function () { 15 | $this->currentResponse = (object)$this->tokensGrantResponse; 16 | return 'ref_tok_1234'; 17 | }); 18 | 19 | $tokenServiceMock->shouldReceive('getAccessToken')->andReturn('acc_tok_1234'); 20 | 21 | $tokenServiceMock->shouldReceive('saveTokens')->andReturnUsing(function ($tokens) { 22 | $this->currentResponse = (object)$this->fileMetadataResponse; 23 | return true; 24 | }); 25 | 26 | return $tokenServiceMock; 27 | } 28 | } -------------------------------------------------------------------------------- /src/Libraries/Storage/Contracts/TokenServiceInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Storage\Contracts; 16 | 17 | /** 18 | * Interface TokenServiceInterface 19 | * @package Quantum\Libraries\Storage 20 | */ 21 | interface TokenServiceInterface 22 | { 23 | 24 | /** 25 | * @return string 26 | */ 27 | public function getAccessToken(): string; 28 | 29 | /** 30 | * @return string 31 | */ 32 | public function getRefreshToken(): string; 33 | 34 | /** 35 | * @param string $accessToken 36 | * @param string|null $refreshToken 37 | * @return bool 38 | */ 39 | public function saveTokens(string $accessToken, ?string $refreshToken = null): bool; 40 | 41 | } -------------------------------------------------------------------------------- /src/Libraries/Auth/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Auth\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Libraries\Auth 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const INCORRECT_USER_SCHEMA = 'User schema does not contains all key fields.'; 26 | 27 | const VERIFICATION_CODE_EXPIRED = 'Verification code expired.'; 28 | 29 | const INCORRECT_VERIFICATION_CODE = 'Incorrect verification code.'; 30 | 31 | const INACTIVE_ACCOUNT = 'The account is not activated.'; 32 | 33 | const INCORRECT_CREDENTIALS = 'Incorrect credentials.'; 34 | } -------------------------------------------------------------------------------- /src/Paginator/Exceptions/PaginatorException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Paginator\Exceptions; 16 | 17 | use Quantum\Paginator\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class PaginatorException 22 | * @package Quantum\Paginator 23 | */ 24 | class PaginatorException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string $type 29 | * @param $missingParam 30 | * @return PaginatorException 31 | */ 32 | public static function missingRequiredParams(string $type, $missingParam): PaginatorException 33 | { 34 | return new static(_message(ExceptionMessages::MISSING_REQUIRED_PARAMS, [$missingParam, ucfirst($type)]), E_WARNING); 35 | } 36 | } -------------------------------------------------------------------------------- /src/Service/Helpers/service.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | use Quantum\Service\Exceptions\ServiceException; 16 | use Quantum\Service\Factories\ServiceFactory; 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\Di\Exceptions\DiException; 19 | use Quantum\Service\QtService; 20 | 21 | /** 22 | * Gets or creates service instance 23 | * @param string $serviceClass 24 | * @param bool $singleton 25 | * @return QtService 26 | * @throws ReflectionException 27 | * @throws BaseException 28 | * @throws DiException 29 | * @throws ServiceException 30 | */ 31 | function service(string $serviceClass, bool $singleton = false): QtService 32 | { 33 | return $singleton ? ServiceFactory::get($serviceClass) : ServiceFactory::create($serviceClass); 34 | } 35 | -------------------------------------------------------------------------------- /tests/Unit/Config/Helpers/ConfigHelperFunctionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Config::class, config()); 14 | } 15 | 16 | public function testConfigHelperFunctions() 17 | { 18 | $this->assertFalse(config()->has('not-exists')); 19 | 20 | $this->assertEquals('Not found', config()->get('not-exists', 'Not found')); 21 | 22 | $this->assertEquals(config()->get('test', 'Testing'), 'Testing'); 23 | 24 | $this->assertNull(config()->get('new-key')); 25 | 26 | config()->set('new-key', 'New value'); 27 | 28 | $this->assertTrue(config()->has('new-key')); 29 | 30 | $this->assertEquals('New value', config()->get('new-key')); 31 | 32 | config()->delete('new-key'); 33 | 34 | $this->assertFalse(config()->has('new-key')); 35 | } 36 | } -------------------------------------------------------------------------------- /src/Di/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Di\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Di 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | 26 | const DEPENDENCY_NOT_REGISTERED = 'The dependency `{%1}` is not registered.'; 27 | 28 | const DEPENDENCY_ALREADY_REGISTERED = 'The dependency `{%1}` is already registered.'; 29 | 30 | const DEPENDENCY_NOT_INSTANTIABLE = 'The dependency `{%1}` is not instantiable.'; 31 | 32 | const INVALID_ABSTRACT_DEPENDENCY = 'The dependency `{%1}` is not valid abstract class.'; 33 | 34 | const CIRCULAR_DEPENDENCY = 'Circular dependency detected: `{%1}`'; 35 | } -------------------------------------------------------------------------------- /src/Environment/Helpers/server.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | use Quantum\Environment\Server; 16 | 17 | /** 18 | * Gets Server instance 19 | * @return Server 20 | */ 21 | function server(): Server 22 | { 23 | return Server::getInstance(); 24 | } 25 | 26 | /** 27 | * Gets user IP 28 | * @return string|null 29 | */ 30 | function get_user_ip(): ?string 31 | { 32 | return Server::getInstance()->ip(); 33 | } 34 | 35 | if (!function_exists('getallheaders')) { 36 | 37 | /** 38 | * Get all headers 39 | * Built-in PHP function synonym of apache_request_headers() 40 | * Declaring here for Nginx server 41 | * @return array 42 | */ 43 | function getallheaders(): array 44 | { 45 | return Server::getInstance()->getAllHeaders(); 46 | } 47 | } -------------------------------------------------------------------------------- /src/Libraries/Auth/Helpers/auth.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.7 13 | */ 14 | 15 | use Quantum\Libraries\Auth\Exceptions\AuthException; 16 | use Quantum\Libraries\Auth\Factories\AuthFactory; 17 | use Quantum\Service\Exceptions\ServiceException; 18 | use Quantum\Config\Exceptions\ConfigException; 19 | use Quantum\App\Exceptions\BaseException; 20 | use Quantum\Di\Exceptions\DiException; 21 | use Quantum\Libraries\Auth\Auth; 22 | 23 | /** 24 | * Gets the Auth handler 25 | * @param string|null $adapter 26 | * @return Auth 27 | * @throws AuthException 28 | * @throws BaseException 29 | * @throws ConfigException 30 | * @throws DiException 31 | * @throws ReflectionException 32 | * @throws ServiceException 33 | */ 34 | function auth(?string $adapter = null): Auth 35 | { 36 | return AuthFactory::get($adapter); 37 | } -------------------------------------------------------------------------------- /src/View/Exceptions/ViewException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\View\Exceptions; 16 | 17 | use Quantum\View\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class ViewException 22 | * @package Quantum\View 23 | */ 24 | class ViewException extends BaseException 25 | { 26 | 27 | /** 28 | * @return ViewException 29 | */ 30 | public static function noLayoutSet(): ViewException 31 | { 32 | return new static(ExceptionMessages::LAYOUT_NOT_SET, E_ERROR); 33 | } 34 | 35 | /** 36 | * @return ViewException 37 | */ 38 | public static function viewNotRendered(): ViewException 39 | { 40 | return new static(ExceptionMessages::VIEW_NOT_RENDERED_YET, E_ERROR); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tests/Unit/Libraries/Auth/Helpers/AuthHelperFunctionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Auth::class, auth()); 16 | 17 | $this->assertInstanceOf(SessionAuthAdapter::class, auth()->getAdapter()); 18 | } 19 | 20 | public function testAuthHelperGetSessionAuth() 21 | { 22 | $this->assertInstanceOf(Auth::class, auth(Auth::SESSION)); 23 | 24 | $this->assertInstanceOf(SessionAuthAdapter::class, auth(Auth::SESSION)->getAdapter()); 25 | } 26 | 27 | public function testAuthHelperGetJwtAuth() 28 | { 29 | $this->assertInstanceOf(Auth::class, auth(Auth::JWT)); 30 | 31 | $this->assertInstanceOf(JwtAuthAdapter::class, auth(Auth::JWT)->getAdapter()); 32 | } 33 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 7.3 4 | - 7.4 5 | 6 | services: 7 | - redis-server 8 | - memcached 9 | 10 | before_install: 11 | - sudo apt-get update -qq 12 | - sudo apt-get install -y -qq postfix 13 | 14 | before_script: 15 | - sudo service postfix stop 16 | - smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 & 17 | - echo -e '#!/usr/bin/env bash\nexit 0' | sudo tee /usr/sbin/sendmail 18 | - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' | sudo tee "/home/travis/.phpenv/versions/`php -i | grep "PHP Version" | head -n 1 | grep -o -P '\d+\.\d+\.\d+.*'`/etc/conf.d/sendmail.ini" 19 | 20 | - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini 21 | - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini 22 | 23 | - composer self-update 24 | - composer install --prefer-dist --no-progress --no-suggest 25 | 26 | script: 27 | - XDEBUG_MODE=coverage vendor/bin/phpunit --stderr --coverage-clover coverage.xml 28 | 29 | after_success: 30 | - bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /tests/Unit/Http/Traits/Response/HttpResponseHeaderTest.php: -------------------------------------------------------------------------------- 1 | assertEmpty($response->allHeaders()); 22 | 23 | $this->assertFalse($response->hasHeader('X-Frame-Options')); 24 | 25 | $response->setHeader('X-Frame-Options', 'deny'); 26 | 27 | $this->assertTrue($response->hasHeader('X-Frame-Options')); 28 | 29 | $this->assertEquals('deny', $response->getHeader('X-Frame-Options')); 30 | 31 | $this->assertIsArray($response->allHeaders()); 32 | 33 | $response->deleteHeader('X-Frame-Options'); 34 | 35 | $this->assertFalse($response->hasHeader('X-Frame-Options')); 36 | 37 | $this->assertNull($response->getHeader('X-Frame-Options')); 38 | } 39 | } -------------------------------------------------------------------------------- /tests/Unit/Loader/LoaderTest.php: -------------------------------------------------------------------------------- 1 | loader = new Loader(); 19 | } 20 | 21 | public function testLoaderFileExists() 22 | { 23 | $this->loader->setup(new Setup('config', 'app')); 24 | 25 | $this->assertTrue($this->loader->fileExists()); 26 | 27 | $this->loader->setup(new Setup('config', 'unknown')); 28 | 29 | $this->assertFalse($this->loader->fileExists()); 30 | } 31 | 32 | public function testLoaderSetupAndLoad() 33 | { 34 | $this->loader->setup(new Setup('config', 'app')); 35 | 36 | $content = $this->loader->load(); 37 | 38 | $this->assertEquals(base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', $this->loader->getFilePath()); 39 | 40 | $this->assertIsArray($content); 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /tests/Unit/Router/RouteControllerTest.php: -------------------------------------------------------------------------------- 1 | expectException(RouteControllerException::class); 34 | 35 | $this->expectExceptionMessage('Action `undefinedAction` not defined'); 36 | 37 | $controller = new SomeController(); 38 | 39 | $controller->undefinedAction(); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Softberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Libraries/Csrf/Exceptions/CsrfException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Csrf\Exceptions; 16 | 17 | use Quantum\Libraries\Csrf\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class CsrfException 22 | * @package Quantum\Libraries\Csrf 23 | */ 24 | class CsrfException extends BaseException 25 | { 26 | /** 27 | * @return CsrfException 28 | */ 29 | public static function tokenNotFound(): CsrfException 30 | { 31 | return new static(ExceptionMessages::CSRF_TOKEN_MISSING, E_WARNING); 32 | } 33 | 34 | /** 35 | * @return CsrfException 36 | */ 37 | public static function tokenNotMatched(): CsrfException 38 | { 39 | return new static(ExceptionMessages::CSRF_TOKEN_MISMATCH, E_WARNING); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Middlewares/Auth.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Middlewares; 16 | 17 | use Quantum\Middleware\QtMiddleware; 18 | use Quantum\Http\Response; 19 | use Quantum\Http\Request; 20 | use Closure; 21 | 22 | /** 23 | * Class Auth 24 | * @package Modules\{{MODULE_NAME}} 25 | */ 26 | class Auth extends QtMiddleware 27 | { 28 | 29 | /** 30 | * @param Request $request 31 | * @param Response $response 32 | * @param Closure $next 33 | * @return mixed 34 | */ 35 | public function apply(Request $request, Response $response, Closure $next) 36 | { 37 | if (!auth()->check()) { 38 | redirect(base_url(true) . '/' . current_lang() . '/signin'); 39 | } 40 | 41 | return $next($request, $response); 42 | } 43 | } -------------------------------------------------------------------------------- /src/Environment/Exceptions/EnvException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Environment\Exceptions; 16 | 17 | use Quantum\Environment\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class EnvException 22 | * @package Quantum\Exceptions 23 | */ 24 | class EnvException extends BaseException 25 | { 26 | 27 | /** 28 | * @return EnvException 29 | */ 30 | public static function environmentImmutable(): EnvException 31 | { 32 | return new static(ExceptionMessages::IMMUTABLE_ENVIRONMENT, E_ERROR); 33 | } 34 | 35 | /** 36 | * @return EnvException 37 | */ 38 | public static function environmentNotLoaded(): EnvException 39 | { 40 | return new static(ExceptionMessages::ENVIRONMENT_NOT_LOADED, E_ERROR); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Middlewares/Guest.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Middlewares; 16 | 17 | use Quantum\Middleware\QtMiddleware; 18 | use Quantum\Http\Response; 19 | use Quantum\Http\Request; 20 | use Closure; 21 | 22 | /** 23 | * Class Guest 24 | * @package Modules\{{MODULE_NAME}} 25 | */ 26 | class Guest extends QtMiddleware 27 | { 28 | 29 | /** 30 | * @param Request $request 31 | * @param Response $response 32 | * @param Closure $next 33 | * @return mixed 34 | */ 35 | public function apply(Request $request, Response $response, Closure $next) 36 | { 37 | if (auth()->check()) { 38 | redirect(get_referrer() ?? base_url(true) . '/' . current_lang()); 39 | } 40 | 41 | return $next($request, $response); 42 | } 43 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php: -------------------------------------------------------------------------------- 1 | shouldReceive('getRefreshToken') 16 | ->andReturnUsing(function () { 17 | $this->currentResponse = (object)$this->tokensGrantResponse; 18 | return 'ref_tok_1234'; 19 | }); 20 | 21 | $tokenServiceMock 22 | ->shouldReceive('getAccessToken') 23 | ->andReturn('acc_tok_1234'); 24 | 25 | $tokenServiceMock 26 | ->shouldReceive('saveTokens') 27 | ->andReturnUsing(function ($tokens) { 28 | $this->currentResponse = (object)$this->profileDataResponse; 29 | return true; 30 | }); 31 | 32 | return $tokenServiceMock; 33 | } 34 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/my-posts.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |

    3 |
    4 | 5 | 10 |
    11 | 12 |

    ...

    13 | 14 | 15 | t('common.post')]) ?> 16 | 17 | check()): ?> 18 |
    19 | add 21 |
    22 | 23 |
    -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/partials/email-item.php.tpl: -------------------------------------------------------------------------------- 1 |
  • 2 |
    "> 3 |
    chevron_right
    4 |
    5 |
    6 |
    7 |
    8 | 14 |
    15 |
    16 |
    17 |
    18 | 19 |
    20 |
    21 |
  • -------------------------------------------------------------------------------- /src/Module/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Module\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Module 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const MODULE_ROUTES_NOT_FOUND = 'Routes not found for module `{%1}`'; 26 | 27 | const MODULE_CONFIG_NOT_FOUND = 'Config not found for a module'; 28 | 29 | const MODULE_CREATION_INCOMPLETE = 'Module creation incomplete: missing files.'; 30 | 31 | const MISSING_MODULE_TEMPLATE = 'Template `{%1}` does not exist'; 32 | 33 | const MISSING_MODULE_DIRECTORY = 'Module directory does not exist, skipping config update.'; 34 | 35 | const MODULE_ALREADY_EXISTS = 'A module or prefix named `{%1}` already exists'; 36 | } -------------------------------------------------------------------------------- /src/Libraries/Lang/Exceptions/LangException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Lang\Exceptions; 16 | 17 | use Quantum\Libraries\Lang\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class LangException 22 | * @package Quantum\Libraries\Lang 23 | */ 24 | class LangException extends BaseException 25 | { 26 | 27 | /** 28 | * @return LangException 29 | */ 30 | public static function translationsNotFound(): LangException 31 | { 32 | return new static(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND, E_WARNING); 33 | } 34 | 35 | /** 36 | * @return LangException 37 | */ 38 | public static function misconfiguredDefaultConfig(): LangException 39 | { 40 | return new static(ExceptionMessages::MISCONFIGURED_DEFAULT_LANG, E_WARNING); 41 | } 42 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Logger/Adapters/MessageAdapterTest.php: -------------------------------------------------------------------------------- 1 | debugger = Debugger::getInstance($store); 22 | 23 | $this->debugger->initStore(); 24 | 25 | $this->adapter = new MessageAdapter(); 26 | } 27 | 28 | public function testReportAddsMessageToDebuggerStore() 29 | { 30 | $level = 'info'; 31 | $message = 'Test message'; 32 | 33 | $this->adapter->report($level, $message); 34 | 35 | $storedMessages = $this->debugger->getStoreCell(Debugger::MESSAGES); 36 | 37 | $this->assertArrayHasKey($level, $storedMessages[0]); 38 | 39 | $this->assertEquals($message, $storedMessages[0][$level]); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Libraries/Session/Exceptions/SessionException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Session\Exceptions; 16 | 17 | use Quantum\Libraries\Session\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class SessionException 22 | * @package Quantum\Libraries\Session 23 | */ 24 | class SessionException extends BaseException 25 | { 26 | /** 27 | * @return SessionException 28 | */ 29 | public static function sessionNotStarted(): SessionException 30 | { 31 | return new static(ExceptionMessages::SESSION_NOT_STARTED, E_WARNING); 32 | } 33 | 34 | /** 35 | * @return SessionException 36 | */ 37 | public static function sessionNotDestroyed(): SessionException 38 | { 39 | return new static(ExceptionMessages::SESSION_NOT_DESTROYED, E_WARNING); 40 | } 41 | } -------------------------------------------------------------------------------- /tests/Unit/Http/Traits/Response/HttpResponseStatusTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(200, $response->getStatusCode()); 21 | 22 | $response->setStatusCode(301); 23 | 24 | $this->assertEquals(301, $response->getStatusCode()); 25 | 26 | $this->assertEquals('Moved Permanently', $response->getStatusText()); 27 | } 28 | 29 | public function testHttpStatusGetText() 30 | { 31 | $response = new Response(); 32 | 33 | $this->assertEquals('OK', $response->getText(200)); 34 | 35 | $this->assertEquals('Not Found', $response->getText(404)); 36 | 37 | $this->assertEquals('Internal Server Error', $response->getText(500)); 38 | 39 | $this->expectException(\InvalidArgumentException::class); 40 | 41 | $response->getText(888); 42 | } 43 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Lang/TranslatorTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Translator::class, $translator); 16 | } 17 | 18 | public function testTranslatorLoadTranslations(): void 19 | { 20 | $translator = new Translator('en'); 21 | 22 | $translator->loadTranslations(); 23 | 24 | $this->assertEquals('Testing', $translator->get('custom.test')); 25 | 26 | $this->assertEquals('Information about the value feature', $translator->get('custom.info', ['param' => 'value'])); 27 | } 28 | 29 | public function testTranslatorGetTranslation(): void 30 | { 31 | $translator = new Translator('en'); 32 | 33 | $translator->loadTranslations(); 34 | 35 | $result = $translator->get('custom.info', ['new']); 36 | 37 | $this->assertEquals('Information about the new feature', $result); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Transformers/CommentTransformer.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Transformers; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class CommentTransformer 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class CommentTransformer implements TransformerInterface 24 | { 25 | public function transform($item): array 26 | { 27 | return [ 28 | 'uuid' => $item->uuid, 29 | 'author' => [ 30 | 'firstname' => $item->firstname, 31 | 'lastname' => $item->lastname, 32 | 'image' => $item->user_directory . '/' . $item->image, 33 | ], 34 | 'content' => $item->content, 35 | 'date' => date('Y-m-d H:i', strtotime($item->created_at)), 36 | ]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Transformers/CommentTransformer.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Transformers; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class CommentTransformer 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class CommentTransformer implements TransformerInterface 24 | { 25 | public function transform($item): array 26 | { 27 | return [ 28 | 'uuid' => $item->uuid, 29 | 'author' => [ 30 | 'firstname' => $item->firstname, 31 | 'lastname' => $item->lastname, 32 | 'image' => $item->user_directory . '/' . $item->image, 33 | ], 34 | 'content' => $item->content, 35 | 'date' => date('Y-m-d H:i', strtotime($item->created_at)), 36 | ]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Libraries/Archive/Exceptions/ArchiveException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Archive\Exceptions; 16 | 17 | use Quantum\Libraries\Archive\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class CacheException 22 | * @package Quantum\Libraries\Archive 23 | */ 24 | class ArchiveException extends BaseException 25 | { 26 | /** 27 | * @param string $name 28 | * @return ArchiveException 29 | */ 30 | public static function cantOpen(string $name): ArchiveException 31 | { 32 | return new static(_message(ExceptionMessages::CANT_OPEN, $name), E_WARNING); 33 | } 34 | 35 | /** 36 | * @return ArchiveException 37 | */ 38 | public static function missingArchiveName(): ArchiveException 39 | { 40 | return new static(ExceptionMessages::NAME_NOT_SET, E_WARNING); 41 | } 42 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Captcha/Helpers/CaptchaHelperFunctionsTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf(Captcha::class, captcha()); 16 | 17 | $this->assertInstanceOf(RecaptchaAdapter::class, captcha()->getAdapter()); 18 | } 19 | 20 | public function testCaptchaHelperGetRecaptchaAdapter() 21 | { 22 | $this->assertInstanceOf(Captcha::class, captcha(Captcha::RECAPTCHA)); 23 | 24 | $this->assertInstanceOf(RecaptchaAdapter::class, captcha(Captcha::RECAPTCHA)->getAdapter()); 25 | } 26 | 27 | public function testCaptchaHelperGetHcaptchaAdapter() 28 | { 29 | $this->assertInstanceOf(Captcha::class, captcha(Captcha::HCAPTCHA)); 30 | 31 | $this->assertInstanceOf(HcaptchaAdapter::class, captcha(Captcha::HCAPTCHA)->getAdapter()); 32 | } 33 | } -------------------------------------------------------------------------------- /tests/Unit/App/Adapters/WebAppAdapterTest.php: -------------------------------------------------------------------------------- 1 | webAppAdapter = new WebAppAdapter(); 22 | } 23 | 24 | public function tearDown(): void 25 | { 26 | config()->flush(); 27 | } 28 | 29 | public function testWebAppAdapterStartSuccessfully() 30 | { 31 | $request = Di::get(Request::class); 32 | $request->create('GET', '/test/am/tests'); 33 | 34 | $result = $this->webAppAdapter->start(); 35 | 36 | $this->assertEquals(0, $result); 37 | } 38 | 39 | public function testWebAppAdapterStartFails() 40 | { 41 | $request = Di::get(Request::class); 42 | $request->create('POST', ''); 43 | 44 | $this->expectException(Exception::class); 45 | 46 | $this->webAppAdapter->start(); 47 | } 48 | } -------------------------------------------------------------------------------- /tests/Unit/Service/QtServiceTest.php: -------------------------------------------------------------------------------- 1 | expectException(ServiceException::class); 37 | 38 | $this->expectExceptionMessage('The method `undefinedMethod` is not supported for `' . QtService::class . '`'); 39 | 40 | $service = (new ServiceFactory)->get(TestingService::class); 41 | 42 | $service->undefinedMethod(); 43 | } 44 | 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Mailer/Adapters/MandrillAdapterTest.php: -------------------------------------------------------------------------------- 1 | adapter = new MandrillAdapter(['api_key' => 'xxx111222333']); 19 | } 20 | 21 | public function testMandrillAdapterInstance() 22 | { 23 | $this->assertInstanceOf(MandrillAdapter::class, $this->adapter); 24 | 25 | $this->assertInstanceOf(MailerInterface::class, $this->adapter); 26 | } 27 | 28 | public function testMandrillAdapterSend() 29 | { 30 | $this->adapter->setFrom('john@hotmail.com', 'John Doe'); 31 | 32 | $this->adapter->setAddress('benny@gmail.com', 'Benny'); 33 | 34 | $this->adapter->setSubject('Lorem'); 35 | 36 | $this->adapter->setBody('Lorem ipsum dolor sit amet'); 37 | 38 | $this->assertTrue($this->adapter->send()); 39 | } 40 | } -------------------------------------------------------------------------------- /tests/Unit/Libraries/Mailer/Adapters/SendgridAdapterTest.php: -------------------------------------------------------------------------------- 1 | adapter = new SendgridAdapter(['api_key' => 'xxx111222333']); 19 | } 20 | 21 | public function testSendgridAdapterInstance() 22 | { 23 | $this->assertInstanceOf(SendgridAdapter::class, $this->adapter); 24 | 25 | $this->assertInstanceOf(MailerInterface::class, $this->adapter); 26 | } 27 | 28 | public function testSendgridAdapterSend() 29 | { 30 | $this->adapter->setFrom('john@hotmail.com', 'John Doe'); 31 | 32 | $this->adapter->setAddress('benny@gmail.com', 'Benny'); 33 | 34 | $this->adapter->setSubject('Lorem'); 35 | 36 | $this->adapter->setBody('Lorem ipsum dolor sit amet'); 37 | 38 | $this->assertTrue($this->adapter->send()); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hook/Exceptions/HookException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Hook\Exceptions; 16 | 17 | use Quantum\Hook\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class HookException 22 | * @package Quantum\Exceptions 23 | */ 24 | class HookException extends BaseException 25 | { 26 | /** 27 | * @param string $name 28 | * @return HookException 29 | */ 30 | public static function hookDuplicateName(string $name): HookException 31 | { 32 | return new static(_message(ExceptionMessages::DUPLICATE_HOOK_NAME, [$name]), E_ERROR); 33 | } 34 | 35 | /** 36 | * @param string $name 37 | * @return HookException 38 | */ 39 | public static function unregisteredHookName(string $name): HookException 40 | { 41 | return new static(_message(ExceptionMessages::UNREGISTERED_HOOK_NAME, [$name]), E_WARNING); 42 | } 43 | } -------------------------------------------------------------------------------- /src/Libraries/Hasher/Exceptions/HasherException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Hasher\Exceptions; 16 | 17 | use Quantum\Libraries\Hasher\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class HasherException 22 | * @package Quantum\Libraries\Hasher 23 | */ 24 | class HasherException extends BaseException 25 | { 26 | 27 | /** 28 | * 29 | * @param string $algorithm 30 | * @return self 31 | */ 32 | public static function algorithmNotSupported(string $algorithm): self 33 | { 34 | return new static(_message(ExceptionMessages::ALGORITHM_NOT_SUPPORTED, $algorithm), E_WARNING); 35 | } 36 | 37 | /** 38 | * 39 | * @return self 40 | */ 41 | public static function invalidBcryptCost(): self 42 | { 43 | return new static(ExceptionMessages::INVALID_BCRYPT_COST, E_WARNING); 44 | } 45 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Middlewares/Signout.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Middlewares; 16 | 17 | use Quantum\Http\Response; 18 | use Quantum\Http\Request; 19 | use Closure; 20 | 21 | /** 22 | * Class Signout 23 | * @package Modules\{{MODULE_NAME}} 24 | */ 25 | class Signout extends BaseMiddleware 26 | { 27 | 28 | /** 29 | * @param Request $request 30 | * @param Response $response 31 | * @param Closure $next 32 | * @return mixed 33 | */ 34 | public function apply(Request $request, Response $response, Closure $next) 35 | { 36 | if (!$request->hasHeader('refresh_token')) { 37 | $this->respondWithError( 38 | $request, 39 | $response, 40 | [t('validation.nonExistingRecord', 'token')] 41 | ); 42 | } 43 | 44 | return $next($request, $response); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/pages/email/index.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 18 | 19 |
    No emails found.
    20 | 21 |
    22 | 23 | 26 | 27 | 'Deleting Email', 30 | 'message' => 'Are you sure you want to delete this email?', 31 | ]); 32 | ?> 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/Unit/Libraries/Mailer/Adapters/SendinblueAdapterTest.php: -------------------------------------------------------------------------------- 1 | adapter = new SendinblueAdapter(['api_key' => 'xxx111222333']); 19 | } 20 | 21 | public function testSendinblueAdapterInstance() 22 | { 23 | $this->assertInstanceOf(SendinblueAdapter::class, $this->adapter); 24 | 25 | $this->assertInstanceOf(MailerInterface::class, $this->adapter); 26 | } 27 | 28 | public function testSendinblueAdapterSend() 29 | { 30 | $this->adapter->setFrom('john@hotmail.com', 'John Doe'); 31 | 32 | $this->adapter->setAddress('benny@gmail.com', 'Benny'); 33 | 34 | $this->adapter->setSubject('Lorem'); 35 | 36 | $this->adapter->setBody('Lorem ipsum dolor sit amet'); 37 | 38 | $this->assertTrue($this->adapter->send()); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/config/database.php.tpl: -------------------------------------------------------------------------------- 1 | 'sleekdb', 10 | 11 | 'mysql' => [ 12 | 'driver' => env("DB_DRIVER", "mysql"), 13 | 'host' => env("DB_HOST", "localhost"), 14 | 'dbname' => env("DB_NAME"), 15 | 'username' => env("DB_USERNAME", "root"), 16 | 'password' => env("DB_PASSWORD"), 17 | 'charset' => env("DB_CHARSET", 'utf8'), 18 | ], 19 | 'sqlite' => [ 20 | 'driver' => 'sqlite', 21 | 'database' => 'database.sqlite', 22 | 'prefix' => '', 23 | ], 24 | 'sleekdb' => [ 25 | 'config' => [ 26 | 'auto_cache' => false, 27 | 'cache_lifetime' => null, 28 | 'timeout' => false, 29 | 'search' => [ 30 | 'min_length' => 2, 31 | 'mode' => 'or', 32 | 'score_key' => 'scoreKey', 33 | 'algorithm' => 1 34 | ], 35 | ], 36 | 'database_dir' => base_dir() . DS . 'shared' . DS . 'store', 37 | ] 38 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/config/database.php.tpl: -------------------------------------------------------------------------------- 1 | 'sleekdb', 10 | 11 | 'mysql' => [ 12 | 'driver' => env("DB_DRIVER", "mysql"), 13 | 'host' => env("DB_HOST", "localhost"), 14 | 'dbname' => env("DB_NAME"), 15 | 'username' => env("DB_USERNAME", "root"), 16 | 'password' => env("DB_PASSWORD"), 17 | 'charset' => env("DB_CHARSET", 'utf8'), 18 | ], 19 | 'sqlite' => [ 20 | 'driver' => 'sqlite', 21 | 'database' => 'database.sqlite', 22 | 'prefix' => '', 23 | ], 24 | 'sleekdb' => [ 25 | 'config' => [ 26 | 'auto_cache' => false, 27 | 'cache_lifetime' => null, 28 | 'timeout' => false, 29 | 'search' => [ 30 | 'min_length' => 2, 31 | 'mode' => 'or', 32 | 'score_key' => 'scoreKey', 33 | 'algorithm' => 1 34 | ], 35 | ], 36 | 'database_dir' => base_dir() . DS . 'shared' . DS . 'store', 37 | ] 38 | ]; -------------------------------------------------------------------------------- /src/Paginator/Enums/Pagination.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Paginator\Enums; 16 | 17 | /** 18 | * Class Pagination 19 | * @package Quantum\Paginator 20 | */ 21 | class Pagination 22 | { 23 | 24 | /** 25 | * Pagination class name 26 | */ 27 | const PAGINATION_CLASS = 'pagination'; 28 | 29 | /** 30 | * Active class name 31 | */ 32 | const PAGINATION_CLASS_ACTIVE = 'active'; 33 | 34 | /** 35 | * Parameter name for per page 36 | */ 37 | const PER_PAGE = 'per_page'; 38 | 39 | /** 40 | * Parameter name for page number 41 | */ 42 | const PAGE = 'page'; 43 | 44 | /** 45 | * First page number 46 | */ 47 | const FIRST_PAGE_NUMBER = 1; 48 | 49 | /** 50 | * Minimum page items count 51 | */ 52 | const MINIMUM_PAGE_ITEMS_COUNT = 3; 53 | 54 | /** 55 | * Edge padding 56 | */ 57 | const EDGE_PADDING = 3; 58 | } -------------------------------------------------------------------------------- /src/Environment/Enums/Env.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Environment\Enums; 16 | 17 | /** 18 | * Class Env 19 | * @package Quantum\Environment 20 | */ 21 | final class Env 22 | { 23 | /** 24 | * Production environment - live system used by end users. 25 | */ 26 | public const PRODUCTION = 'production'; 27 | 28 | /** 29 | * Staging environment - pre-production environment for final testing. 30 | */ 31 | public const STAGING = 'staging'; 32 | 33 | /** 34 | * Development environment - used by developers for active development. 35 | */ 36 | public const DEVELOPMENT = 'development'; 37 | 38 | /** 39 | * Testing environment - used for automated tests and quality assurance. 40 | */ 41 | public const TESTING = 'testing'; 42 | 43 | /** 44 | * Local environment - developer's local machine environment. 45 | */ 46 | public const LOCAL = 'local'; 47 | } -------------------------------------------------------------------------------- /src/Libraries/Logger/Adapters/MessageAdapter.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Logger\Adapters; 16 | 17 | use Quantum\Libraries\Logger\Contracts\ReportableInterface; 18 | use DebugBar\DebugBarException; 19 | use Quantum\Debugger\Debugger; 20 | 21 | /** 22 | * Class MessageAdapter 23 | * @package Quantum\Logger 24 | */ 25 | class MessageAdapter implements ReportableInterface 26 | { 27 | 28 | /** 29 | * @param string $level 30 | * @param $message 31 | * @param array|null $context 32 | * @return void 33 | * @throws DebugBarException 34 | */ 35 | public function report(string $level, $message, ?array $context = []) 36 | { 37 | $tab = $context['tab'] ?? Debugger::MESSAGES; 38 | 39 | $debugger = Debugger::getInstance(); 40 | 41 | if ($debugger->isEnabled()) { 42 | $debugger->addToStoreCell($tab, $level, $message); 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Model/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Model\Enums; 16 | 17 | use Quantum\App\Enums\ExceptionMessages as BaseExceptionMessages; 18 | 19 | /** 20 | * Class ExceptionMessages 21 | * @package Quantum\Model 22 | */ 23 | final class ExceptionMessages extends BaseExceptionMessages 24 | { 25 | const INAPPROPRIATE_MODEL_PROPERTY = 'Inappropriate property `{%1}` for fillable object'; 26 | 27 | const WRONG_RELATION = 'The model `{%1}` does not define relation with `{%2}`'; 28 | 29 | const RELATION_TYPE_MISSING = 'Relation type is missing for model `{%1}` with related model `{%2}`'; 30 | 31 | const MISSING_RELATION_KEYS = 'Relation keys `foreign_key` or `local_key` are missing for model `{%1}` with related model `{%2}`'; 32 | 33 | const MISSING_FOREIGN_KEY = 'Foreign key `{%1}` is missing in model `{%2}`'; 34 | 35 | const UNSUPPORTED_RELATION = 'Relation type `{%1}` is not supported'; 36 | } -------------------------------------------------------------------------------- /src/Libraries/Asset/Exceptions/AssetException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Asset\Exceptions; 16 | 17 | use Quantum\Libraries\Asset\Enums\ExceptionMessages; 18 | 19 | /** 20 | * Class AssetException 21 | * @package Quantum\Libraries\Asset 22 | */ 23 | class AssetException extends \Exception 24 | { 25 | /** 26 | * @param string $position 27 | * @param string $name 28 | * @return AssetException 29 | */ 30 | public static function positionInUse(string $position, string $name): AssetException 31 | { 32 | return new self(_message(ExceptionMessages::POSITION_IN_USE, [$position, $name]), E_WARNING); 33 | } 34 | 35 | /** 36 | * @param string|null $name 37 | * @return AssetException 38 | */ 39 | public static function nameInUse(?string $name): AssetException 40 | { 41 | return new self(_message(ExceptionMessages::NAME_IN_USE, [$name]), E_WARNING); 42 | } 43 | } -------------------------------------------------------------------------------- /src/Libraries/Logger/Exceptions/LoggerException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Logger\Exceptions; 16 | 17 | use Quantum\Libraries\Logger\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class LoggerException 22 | * @package Quantum\Logger 23 | */ 24 | class LoggerException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string $name 29 | * @return LoggerException 30 | */ 31 | public static function logPathIsNotDirectory(string $name): LoggerException 32 | { 33 | return new static(_message(ExceptionMessages::LOG_PATH_NOT_DIRECTORY, [$name]), E_ERROR); 34 | } 35 | 36 | /** 37 | * @param string $name 38 | * @return LoggerException 39 | */ 40 | public static function logPathIsNotFile(string $name): LoggerException 41 | { 42 | return new static(_message(ExceptionMessages::LOG_PATH_NOT_FILE, [$name]), E_ERROR); 43 | } 44 | } -------------------------------------------------------------------------------- /tests/_root/modules/Test/Transformers/PostTransformer.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace Quantum\Tests\_root\modules\Test\Transformers; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class PostTransformer 21 | * @package Modules\Api 22 | */ 23 | class PostTransformer implements TransformerInterface 24 | { 25 | 26 | /** 27 | * Transforms the post data 28 | * @param $item 29 | * @return mixed 30 | */ 31 | public function transform($item): array 32 | { 33 | return [ 34 | 'uuid' => $item->uuid, 35 | 'title' => $item->title, 36 | 'content' => markdown_to_html($item->content, true), 37 | 'image' => $item->image ? $item->user_directory . '/' . $item->image : null, 38 | 'date' => date('Y/m/d H:i', strtotime($item->updated_at)), 39 | 'author' => $item->firstname . ' ' . $item->lastname 40 | ]; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Middlewares/Auth.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Middlewares; 16 | 17 | use Quantum\Http\Enums\StatusCode; 18 | use Quantum\Http\Response; 19 | use Quantum\Http\Request; 20 | use Closure; 21 | 22 | /** 23 | * Class Auth 24 | * @package Modules\{{MODULE_NAME}} 25 | */ 26 | class Auth extends BaseMiddleware 27 | { 28 | 29 | /** 30 | * @param Request $request 31 | * @param Response $response 32 | * @param Closure $next 33 | * @return mixed 34 | */ 35 | public function apply(Request $request, Response $response, Closure $next) 36 | { 37 | if (!auth()->check()) { 38 | $this->respondWithError( 39 | $request, 40 | $response, 41 | t('validation.unauthorizedRequest'), 42 | StatusCode::UNAUTHORIZED 43 | ); 44 | } 45 | 46 | return $next($request, $response); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Libraries/Auth/Contracts/AuthenticatableInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Auth\Contracts; 16 | 17 | use Quantum\Libraries\Auth\User; 18 | 19 | /** 20 | * Interface AuthenticatableInterface 21 | * @package Quantum\Libraries\Auth 22 | */ 23 | interface AuthenticatableInterface 24 | { 25 | 26 | /** 27 | * Auth user key 28 | */ 29 | const AUTH_USER = 'auth_user'; 30 | 31 | /** 32 | * Sign In 33 | * @param string $username 34 | * @param string $password 35 | * @return mixed 36 | */ 37 | public function signin(string $username, string $password); 38 | 39 | /** 40 | * Sign Out 41 | * @return bool 42 | */ 43 | public function signout(): bool; 44 | 45 | /** 46 | * Check 47 | * @return bool 48 | */ 49 | public function check(): bool; 50 | 51 | /** 52 | * User 53 | * @return User|null 54 | */ 55 | public function user(): ?User; 56 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Transformers/PostTransformer.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Transformers; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class PostTransformer 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class PostTransformer implements TransformerInterface 24 | { 25 | 26 | /** 27 | * Transforms the post data 28 | * @param $item 29 | * @return mixed 30 | */ 31 | public function transform($item): array 32 | { 33 | return [ 34 | 'uuid' => $item->uuid, 35 | 'title' => $item->title, 36 | 'content' => markdown_to_html($item->content, true), 37 | 'image' => $item->image ? $item->user_directory . '/' . $item->image : null, 38 | 'date' => date('Y/m/d H:i', strtotime($item->updated_at)), 39 | 'author' => $item->firstname . ' ' . $item->lastname 40 | ]; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Transformers/PostTransformer.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Transformers; 16 | 17 | use Quantum\Libraries\Transformer\Contracts\TransformerInterface; 18 | 19 | /** 20 | * Class PostTransformer 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class PostTransformer implements TransformerInterface 24 | { 25 | 26 | /** 27 | * Transforms the post data 28 | * @param $item 29 | * @return mixed 30 | */ 31 | public function transform($item): array 32 | { 33 | return [ 34 | 'uuid' => $item->uuid, 35 | 'title' => $item->title, 36 | 'content' => markdown_to_html($item->content, true), 37 | 'image' => $item->image ? $item->user_directory . '/' . $item->image : null, 38 | 'date' => date('Y/m/d H:i', strtotime($item->updated_at)), 39 | 'author' => $item->firstname . ' ' . $item->lastname 40 | ]; 41 | } 42 | } -------------------------------------------------------------------------------- /src/Libraries/Cookie/Contracts/CookieStorageInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Cookie\Contracts; 16 | 17 | use Quantum\Contracts\StorageInterface; 18 | 19 | /** 20 | * Interface CookieStorageInterface 21 | * @package Quantum\Libraries\Cookie 22 | */ 23 | interface CookieStorageInterface extends StorageInterface 24 | { 25 | 26 | /** 27 | * Sets data by given key 28 | * @param string $key 29 | * @param mixed $value 30 | * @param int $time 31 | * @param string $path 32 | * @param string $domain 33 | * @param bool $secure 34 | * @param bool $httponly 35 | */ 36 | public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false); 37 | 38 | /** 39 | * Deletes data by given key 40 | * @param string $key 41 | * @param string $path 42 | */ 43 | public function delete(string $key, string $path = '/'); 44 | } -------------------------------------------------------------------------------- /src/Module/Templates/DefaultApi/src/Controllers/MainController.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Controllers; 16 | 17 | use Quantum\Router\RouteController; 18 | use Quantum\Http\Response; 19 | 20 | /** 21 | * Class MainController 22 | * @package Modules\Api 23 | */ 24 | class MainController extends RouteController 25 | { 26 | /** 27 | * Status error 28 | */ 29 | const STATUS_ERROR = 'error'; 30 | 31 | /** 32 | * Status success 33 | */ 34 | const STATUS_SUCCESS = 'success'; 35 | 36 | /** 37 | * CSRF verification 38 | * @var bool 39 | */ 40 | public $csrfVerification = false; 41 | 42 | /** 43 | * Action - success response 44 | * @param Response $response 45 | */ 46 | public function index(Response $response) 47 | { 48 | $response->json([ 49 | 'status' => 'success', 50 | 'message' => '{{MODULE_NAME}} module.' 51 | ]); 52 | } 53 | } -------------------------------------------------------------------------------- /src/Router/Exceptions/RouteControllerException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Router\Exceptions; 16 | 17 | use Quantum\Router\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * ControllerException class 22 | * @package Quantum\Router 23 | */ 24 | class RouteControllerException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string|null $name 29 | * @return RouteControllerException 30 | */ 31 | public static function controllerNotDefined(?string $name): RouteControllerException 32 | { 33 | return new static(_message(ExceptionMessages::CONTROLLER_NOT_FOUND, [$name]), E_ERROR); 34 | } 35 | 36 | /** 37 | * @param string $name 38 | * @return RouteControllerException 39 | */ 40 | public static function actionNotDefined(string $name): RouteControllerException 41 | { 42 | return new static(_message(ExceptionMessages::ACTION_NOT_DEFINED, [$name]), E_ERROR); 43 | } 44 | } -------------------------------------------------------------------------------- /src/App/Adapters/AppAdapter.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.8 13 | */ 14 | 15 | namespace Quantum\App\Adapters; 16 | 17 | use Quantum\App\Exceptions\BaseException; 18 | use Quantum\App\Contracts\AppInterface; 19 | use Quantum\Di\Exceptions\DiException; 20 | use Quantum\App\Traits\AppTrait; 21 | use ReflectionException; 22 | use Quantum\Di\Di; 23 | 24 | /** 25 | * Class AppAdapter 26 | * @package Quantum\App 27 | */ 28 | abstract class AppAdapter implements AppInterface 29 | { 30 | 31 | use AppTrait; 32 | 33 | /** 34 | * @var string 35 | */ 36 | private static $baseDir; 37 | 38 | /** 39 | * @throws BaseException 40 | * @throws DiException 41 | * @throws ReflectionException 42 | */ 43 | public function __construct() 44 | { 45 | $this->loadCoreDependencies(); 46 | $this->loadComponentHelperFunctions(); 47 | $this->loadLibraryHelperFunctions(); 48 | $this->loadAppHelperFunctions(); 49 | $this->loadModuleHelperFunctions(); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Libraries/Storage/Exceptions/FileUploadException.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Libraries\Storage\Exceptions; 16 | 17 | use Quantum\Libraries\Storage\Enums\ExceptionMessages; 18 | use Quantum\App\Exceptions\BaseException; 19 | 20 | /** 21 | * Class FileUploadException 22 | * @package Quantum\Libraries\Storage 23 | */ 24 | class FileUploadException extends BaseException 25 | { 26 | 27 | /** 28 | * @param string $name 29 | * @return FileUploadException 30 | */ 31 | public static function fileTypeNotAllowed(string $name): FileUploadException 32 | { 33 | return new static(_message(ExceptionMessages::FILE_TYPE_NOT_ALLOWED, [$name]), E_WARNING); 34 | } 35 | 36 | /** 37 | * @param string $name 38 | * @return FileUploadException 39 | */ 40 | public static function incorrectMimeTypesConfig(string $name): FileUploadException 41 | { 42 | return new static(_message(ExceptionMessages::MISSING_CONFIG, $name), E_ERROR); 43 | } 44 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/partials/my-post-item.php.tpl: -------------------------------------------------------------------------------- 1 |
  • 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

    13 |
    14 |

    15 | 16 | edit 17 | 18 | 19 | delete 20 | 21 |
  • -------------------------------------------------------------------------------- /src/Http/Enums/ContentType.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\Http\Enums; 16 | 17 | /** 18 | * Class ContentType 19 | * @package Quantum\Http 20 | */ 21 | final class ContentType 22 | { 23 | 24 | /** 25 | * HTML content type 26 | */ 27 | public const HTML = 'text/html'; 28 | 29 | /** 30 | * XML content type 31 | */ 32 | public const XML = 'application/xml'; 33 | 34 | /** 35 | * JSON content type 36 | */ 37 | public const JSON = 'application/json'; 38 | 39 | /** 40 | * JSONP content type 41 | */ 42 | public const JSONP = 'application/javascript'; 43 | 44 | /** 45 | * Multipart form data 46 | */ 47 | public const FORM_DATA = 'multipart/form-data'; 48 | 49 | /** 50 | * URL encoded 51 | */ 52 | public const URL_ENCODED = 'application/x-www-form-urlencoded'; 53 | 54 | /** 55 | * Default content type for binary streams 56 | */ 57 | public const OCTET_STREAM = 'application/octet-stream'; 58 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/account/partials/account.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
    5 | 6 | 7 |
    8 |
    9 |
    10 |
    11 | 12 | 13 |
    14 |
    15 |
    16 | 17 | 18 | 21 |
    22 |
    23 |
    -------------------------------------------------------------------------------- /tests/Unit/Libraries/Mailer/Adapters/MailgunAdapterTest.php: -------------------------------------------------------------------------------- 1 | 'xxx11122233', 20 | 'domain' => 'mailgun.example.com', 21 | ]; 22 | 23 | $this->adapter = new MailgunAdapter($config); 24 | } 25 | 26 | public function testMailgunAdapterInstance() 27 | { 28 | $this->assertInstanceOf(MailgunAdapter::class, $this->adapter); 29 | 30 | $this->assertInstanceOf(MailerInterface::class, $this->adapter); 31 | } 32 | 33 | public function testMailgunAdapterSend() 34 | { 35 | $this->adapter->setFrom('john@hotmail.com', 'John Doe'); 36 | 37 | $this->adapter->setAddress('benny@gmail.com', 'Benny'); 38 | 39 | $this->adapter->setSubject('Lorem'); 40 | 41 | $this->adapter->setBody('Lorem ipsum dolor sit amet'); 42 | 43 | $this->assertTrue($this->adapter->send()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/App/Enums/ExceptionMessages.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace Quantum\App\Enums; 16 | 17 | /** 18 | * Class ExceptionMessages 19 | * @package Quantum\App 20 | */ 21 | class ExceptionMessages 22 | { 23 | const APP_KEY_MISSING = 'APP KEY is missing.'; 24 | 25 | const EXECUTION_TERMINATED = 'Execution was terminated.'; 26 | 27 | const METHOD_NOT_SUPPORTED = 'The method `{%1}` is not supported for `{%2}`.'; 28 | 29 | const ADAPTER_NOT_SUPPORTED = 'The adapter `{%1}` is not supported.'; 30 | 31 | const DRIVER_NOT_SUPPORTED = 'The driver `{%1}` is not supported.'; 32 | 33 | const FILE_NOT_FOUND = 'The file `{%1}` not found.'; 34 | 35 | const NOT_FOUND = '{%1} `{%2}` not found.'; 36 | 37 | const NOT_INSTANCE_OF = 'The `{%1}` is not instance of `{%2}`.'; 38 | 39 | const CANT_CONNECT = 'Can not connect to `{%1}`.'; 40 | 41 | const MISSING_CONFIG = 'Could not load config `{%1}` properly.'; 42 | 43 | const UNAVAILABLE_REQUEST_METHOD = 'Provided request method `{%1}` is not available.'; 44 | } -------------------------------------------------------------------------------- /src/Libraries/Session/Contracts/SessionStorageInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Session\Contracts; 16 | 17 | use Quantum\Contracts\StorageInterface; 18 | 19 | /** 20 | * Interface SessionStorageInterface 21 | * @package Quantum\Libraries\Session 22 | */ 23 | interface SessionStorageInterface extends StorageInterface 24 | { 25 | 26 | /** 27 | * Gets flash value by given key 28 | * @param string $key 29 | * @return mixed|string|null 30 | */ 31 | public function getFlash(string $key); 32 | 33 | /** 34 | * Sets flash value by given key 35 | * @param string $key 36 | * @param mixed $value 37 | */ 38 | public function setFlash(string $key, $value); 39 | 40 | /** 41 | * Gets the session ID 42 | * @return string|null 43 | */ 44 | public function getId(): ?string; 45 | 46 | /** 47 | * Update the current session id with a newly generated one 48 | * @return bool 49 | */ 50 | public function regenerateId(): bool; 51 | } -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/layouts/main.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php echo $title ?> 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 |
    31 |
    32 | 33 |
    34 |
    35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/Module/Templates/Toolkit/src/Views/pages/database/index.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
      5 |
    • 6 | addTables 7 |
    • 8 | 9 |
    • 10 | 11 |
    • 12 | 13 |
    14 |
    15 |
    16 | 17 |
    18 | 'createTableModal', 21 | 'inputField' => raw_param('Table Name: '), 22 | 'footerButtons' => [ 23 | raw_param('Cancel'), 24 | raw_param('') 25 | ] 26 | ]); ?> 27 |
    28 |
    -------------------------------------------------------------------------------- /src/Libraries/Auth/Contracts/AuthServiceInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Auth\Contracts; 16 | 17 | use Quantum\Libraries\Auth\User; 18 | 19 | /** 20 | * Interface AuthServiceInterface 21 | * @package Quantum\Libraries\Auth 22 | */ 23 | interface AuthServiceInterface 24 | { 25 | 26 | /** 27 | * Get 28 | * @param string $field 29 | * @param string|null $value 30 | * @return User|null 31 | */ 32 | public function get(string $field, ?string $value): ?User; 33 | 34 | /** 35 | * Add 36 | * @param array $data 37 | * @return User 38 | */ 39 | public function add(array $data): User; 40 | 41 | /** 42 | * Update 43 | * @param string $field 44 | * @param string|null $value 45 | * @param array $data 46 | * @return User|null 47 | */ 48 | public function update(string $field, ?string $value, array $data): ?User; 49 | 50 | /** 51 | * User Schema 52 | * @return array 53 | */ 54 | public function userSchema(): array; 55 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/config/auth.php.tpl: -------------------------------------------------------------------------------- 1 | 'jwt', 10 | 11 | 'session' => [ 12 | 'service' => {{MODULE_NAMESPACE}}\Services\AuthService::class, 13 | ], 14 | 15 | 'jwt' => [ 16 | 'service' => {{MODULE_NAMESPACE}}\Services\AuthService::class, 17 | 'claims' => [ 18 | 'jti' => uniqid(), 19 | 'iss' => 'issuer', 20 | 'aud' => 'audience', 21 | 'iat' => time(), 22 | 'nbf' => time() + 1, 23 | 'exp' => time() + 3600, 24 | ] 25 | ], 26 | 27 | /** 28 | * --------------------------------------------------------- 29 | * Two-factor authentication 30 | * --------------------------------------------------------- 31 | * 32 | * Enables or disables 2-factor authentication 33 | */ 34 | 'two_fa' => env('TWO_FA', true), 35 | 36 | /** 37 | * --------------------------------------------------------- 38 | * OTP expiration 39 | * --------------------------------------------------------- 40 | * 41 | * OTP expires after minutes defined 42 | */ 43 | 'otp_expires' => 2, 44 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Models/User.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Models; 16 | 17 | use Quantum\Model\QtModel; 18 | 19 | /** 20 | * Class User 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class User extends QtModel 24 | { 25 | 26 | /** 27 | * ID column of table 28 | * @var string 29 | */ 30 | public $idColumn = 'id'; 31 | 32 | /** 33 | * The table name 34 | * @var string 35 | */ 36 | public $table = 'users'; 37 | 38 | /** 39 | * Fillable properties 40 | * @var array 41 | */ 42 | public $fillable = [ 43 | 'uuid', 44 | 'firstname', 45 | 'lastname', 46 | 'role', 47 | 'email', 48 | 'password', 49 | 'image', 50 | 'activation_token', 51 | 'remember_token', 52 | 'reset_token', 53 | 'access_token', 54 | 'refresh_token', 55 | 'otp', 56 | 'otp_expires', 57 | 'otp_token', 58 | 'created_at', 59 | 'updated_at', 60 | ]; 61 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Models/User.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Models; 16 | 17 | use Quantum\Model\QtModel; 18 | 19 | /** 20 | * Class User 21 | * @package Modules\{{MODULE_NAME}} 22 | */ 23 | class User extends QtModel 24 | { 25 | 26 | /** 27 | * ID column of table 28 | * @var string 29 | */ 30 | public $idColumn = 'id'; 31 | 32 | /** 33 | * The table name 34 | * @var string 35 | */ 36 | public $table = 'users'; 37 | 38 | /** 39 | * Fillable properties 40 | * @var array 41 | */ 42 | public $fillable = [ 43 | 'uuid', 44 | 'firstname', 45 | 'lastname', 46 | 'role', 47 | 'email', 48 | 'password', 49 | 'image', 50 | 'activation_token', 51 | 'remember_token', 52 | 'reset_token', 53 | 'access_token', 54 | 'refresh_token', 55 | 'otp', 56 | 'otp_expires', 57 | 'otp_token', 58 | 'created_at', 59 | 'updated_at', 60 | ]; 61 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/config/auth.php.tpl: -------------------------------------------------------------------------------- 1 | 'session', 10 | 11 | 'session' => [ 12 | 'service' => {{MODULE_NAMESPACE}}\Services\AuthService::class, 13 | ], 14 | 15 | 'jwt' => [ 16 | 'service' => {{MODULE_NAMESPACE}}\Services\AuthService::class, 17 | 'claims' => [ 18 | 'jti' => uniqid(), 19 | 'iss' => 'issuer', 20 | 'aud' => 'audience', 21 | 'iat' => time(), 22 | 'nbf' => time() + 1, 23 | 'exp' => time() + 3600, 24 | ] 25 | ], 26 | 27 | /** 28 | * --------------------------------------------------------- 29 | * Two-factor authentication 30 | * --------------------------------------------------------- 31 | * 32 | * Enables or disables 2-factor authentication 33 | */ 34 | 'two_fa' => env('TWO_FA', true), 35 | 36 | /** 37 | * --------------------------------------------------------- 38 | * OTP expiration 39 | * --------------------------------------------------------- 40 | * 41 | * OTP expires after minutes defined 42 | */ 43 | 'otp_expires' => 2, 44 | ]; -------------------------------------------------------------------------------- /src/Module/Templates/DemoWeb/src/Views/post/partials/comment-item.php.tpl: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
    5 | 6 | <?php echo htmlspecialchars($comment['author']['firstname']) ?> 10 | 11 | person 12 | 13 | 14 | 15 | 16 |
    17 |

    18 | 19 |

    20 |

    21 | access_time 22 | 23 |

    24 |
    25 |
    26 |
    -------------------------------------------------------------------------------- /src/Libraries/Storage/Contracts/CloudAppInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.5 13 | */ 14 | 15 | namespace Quantum\Libraries\Storage\Contracts; 16 | 17 | use Quantum\Libraries\HttpClient\HttpClient; 18 | 19 | /** 20 | * Interface CloudAppInterface 21 | * @package Quantum\Libraries\Storage 22 | */ 23 | interface CloudAppInterface 24 | { 25 | 26 | /** 27 | * @param string $appKey 28 | * @param string $appSecret 29 | * @param TokenServiceInterface $tokenService 30 | * @param HttpClient $httpClient 31 | */ 32 | public function __construct( 33 | string $appKey, 34 | string $appSecret, 35 | TokenServiceInterface $tokenService, 36 | HttpClient $httpClient 37 | ); 38 | 39 | /** 40 | * Send request 41 | * @param string $url 42 | * @param array $data 43 | * @param array $headers 44 | * @param string $method 45 | * @return mixed 46 | */ 47 | public function sendRequest( 48 | string $url, 49 | array $data = [], 50 | array $headers = [], 51 | string $method = 'POST' 52 | ); 53 | } -------------------------------------------------------------------------------- /src/Module/Templates/DemoApi/src/Middlewares/Comment.php.tpl: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) 11 | * @link http://quantum.softberg.org/ 12 | * @since 2.9.9 13 | */ 14 | 15 | namespace {{MODULE_NAMESPACE}}\Middlewares; 16 | 17 | use Quantum\Libraries\Validation\Rule; 18 | use Quantum\Http\Response; 19 | use Quantum\Http\Request; 20 | use Closure; 21 | 22 | /** 23 | * Class Comment 24 | * @package Modules\{{MODULE_NAME}} 25 | */ 26 | class Comment extends BaseMiddleware 27 | { 28 | 29 | /** 30 | * @param Request $request 31 | * @param Response $response 32 | * @param Closure $next 33 | */ 34 | public function apply(Request $request, Response $response, Closure $next) 35 | { 36 | $this->validateRequest($request, $response); 37 | return $next($request, $response); 38 | } 39 | 40 | /** 41 | * @inheritDoc 42 | */ 43 | protected function defineValidationRules(Request $request) 44 | { 45 | $this->validator->setRules([ 46 | 'content' => [ 47 | Rule::required(), 48 | Rule::minLen(2), 49 | Rule::maxLen(100), 50 | ], 51 | ]); 52 | } 53 | } -------------------------------------------------------------------------------- /tests/_root/shared/Models/TestUserModel.php: -------------------------------------------------------------------------------- 1 | [ 28 | 'type' => Relation::HAS_ONE, 29 | 'foreign_key' => 'user_id', 30 | 'local_key' => 'id' 31 | ], 32 | 33 | TestUserProfessionModel::class => [ 34 | 'type' => Relation::HAS_MANY, 35 | 'foreign_key' => 'user_id', 36 | 'local_key' => 'id' 37 | ], 38 | 39 | TestUserMeetingModel::class => [ 40 | 'type' => Relation::HAS_MANY, 41 | 'foreign_key' => 'user_id', 42 | 'local_key' => 'id' 43 | ], 44 | 45 | TestUserEventModel::class => [ 46 | 'type' => Relation::HAS_MANY, 47 | 'foreign_key' => 'user_id', 48 | 'local_key' => 'id' 49 | ], 50 | ]; 51 | } 52 | } 53 | --------------------------------------------------------------------------------