├── .github └── workflows │ └── tests.yml ├── .gitignore ├── CREDITS.md ├── LICENSE.md ├── README.md ├── composer.json ├── contracts ├── Database │ ├── MultisiteInterface.php │ ├── NestedSetInterface.php │ ├── SoftDeleteInterface.php │ ├── SortableInterface.php │ ├── SortableRelationInterface.php │ ├── TreeInterface.php │ └── ValidationInterface.php ├── Element │ ├── FilterElement.php │ ├── FormElement.php │ └── ListElement.php ├── Support │ └── OctoberPackage.php └── Twig │ ├── CallsAnyMethod.php │ └── CallsMethods.php ├── helpers ├── AjaxException.php ├── App.php ├── ApplicationException.php ├── Arr.php ├── Artisan.php ├── Auth.php ├── Backend.php ├── BackendAuth.php ├── BackendMenu.php ├── BackendUi.php ├── Block.php ├── Broadcast.php ├── Bus.php ├── Cache.php ├── Cms.php ├── Config.php ├── Cookie.php ├── Crypt.php ├── Currency.php ├── Date.php ├── Db.php ├── DbDongle.php ├── Event.php ├── File.php ├── Flash.php ├── ForbiddenException.php ├── Form.php ├── Hash.php ├── Html.php ├── Http.php ├── Ini.php ├── Input.php ├── Lang.php ├── Log.php ├── Mail.php ├── Manifest.php ├── Markdown.php ├── Model.php ├── NotFoundException.php ├── Notification.php ├── Password.php ├── Queue.php ├── Redirect.php ├── Redis.php ├── Request.php ├── Resizer.php ├── Response.php ├── Route.php ├── Schema.php ├── Seeder.php ├── Session.php ├── Site.php ├── Storage.php ├── Str.php ├── System.php ├── SystemException.php ├── Twig.php ├── Ui.php ├── Url.php ├── ValidationException.php ├── Validator.php ├── View.php └── Yaml.php ├── phpbench.json ├── phpcs.xml ├── phpunit.xml ├── src ├── Argon │ ├── Argon.php │ ├── ArgonServiceProvider.php │ └── README.md ├── Assetic │ ├── Asset │ │ ├── AssetCache.php │ │ ├── AssetCollection.php │ │ ├── AssetCollectionInterface.php │ │ ├── AssetInterface.php │ │ ├── BaseAsset.php │ │ ├── FileAsset.php │ │ ├── GlobAsset.php │ │ ├── HttpAsset.php │ │ ├── Iterator │ │ │ ├── AssetCollectionFilterIterator.php │ │ │ └── AssetCollectionIterator.php │ │ └── StringAsset.php │ ├── AssetManager.php │ ├── AssetWriter.php │ ├── AsseticServiceProvider.php │ ├── Cache │ │ ├── ArrayCache.php │ │ ├── CacheInterface.php │ │ └── FilesystemCache.php │ ├── Combiner.php │ ├── Exception │ │ ├── Exception.php │ │ └── FilterException.php │ ├── Factory │ │ ├── AssetFactory.php │ │ └── Resource │ │ │ ├── DirectoryResource.php │ │ │ ├── DirectoryResourceFilterIterator.php │ │ │ ├── DirectoryResourceIterator.php │ │ │ ├── FileResource.php │ │ │ ├── IteratorResourceInterface.php │ │ │ └── ResourceInterface.php │ ├── Filter │ │ ├── BaseCssFilter.php │ │ ├── CallablesFilter.php │ │ ├── CssCacheBustingFilter.php │ │ ├── CssImportFilter.php │ │ ├── CssMinFilter.php │ │ ├── CssRewriteFilter.php │ │ ├── DependencyExtractorInterface.php │ │ ├── FilterCollection.php │ │ ├── FilterInterface.php │ │ ├── HashableInterface.php │ │ ├── JSMinFilter.php │ │ ├── JSqueezeFilter.php │ │ ├── JavascriptImporter.php │ │ ├── LessCompiler.php │ │ ├── LessphpFilter.php │ │ ├── ScssCompiler.php │ │ ├── ScssphpFilter.php │ │ └── StylesheetMinify.php │ ├── FilterManager.php │ ├── README.md │ ├── Traits │ │ └── HasDeepHasher.php │ └── Util │ │ ├── CssUtils.php │ │ ├── LessUtils.php │ │ ├── SassUtils.php │ │ └── VarUtils.php ├── Auth │ ├── AuthException.php │ ├── Concerns │ │ ├── HasGuard.php │ │ ├── HasImpersonation.php │ │ ├── HasProviderProxy.php │ │ ├── HasSession.php │ │ ├── HasStatefulGuard.php │ │ ├── HasThrottle.php │ │ └── HasUser.php │ ├── Manager.php │ ├── Migrations │ │ ├── 2013_10_01_000001_Db_Users.php │ │ ├── 2013_10_01_000002_Db_Groups.php │ │ ├── 2013_10_01_000003_Db_Users_Groups.php │ │ ├── 2013_10_01_000004_Db_Preferences.php │ │ ├── 2013_10_01_000005_Db_Throttle.php │ │ └── 2017_10_01_000006_Db_Roles.php │ └── Models │ │ ├── Group.php │ │ ├── Preferences.php │ │ ├── Role.php │ │ ├── Throttle.php │ │ └── User.php ├── Combine │ ├── Combiner.php │ ├── CombinerServiceProvider.php │ ├── JavascriptMinify.php │ ├── JsCompile.php │ ├── LessCompile.php │ ├── ScssCompile.php │ └── StylesheetMinify.php ├── Composer │ ├── Concerns │ │ ├── HasAssertions.php │ │ ├── HasAutoloader.php │ │ ├── HasOctoberCommands.php │ │ ├── HasOutput.php │ │ └── HasRequirements.php │ ├── Manager.php │ └── resources │ │ ├── file_get_contents.php │ │ └── putenv.php ├── Config │ ├── FileLoader.php │ ├── README.md │ └── Repository.php ├── Database │ ├── Attach │ │ ├── File.php │ │ └── FileException.php │ ├── Builder.php │ ├── Collection.php │ ├── Concerns │ │ ├── HasAttributes.php │ │ ├── HasEagerLoadAttachRelation.php │ │ ├── HasEvents.php │ │ ├── HasJsonable.php │ │ ├── HasNicerPagination.php │ │ ├── HasRelationships.php │ │ └── HasReplication.php │ ├── Connections │ │ ├── Connection.php │ │ ├── ExtendsConnection.php │ │ ├── MySqlConnection.php │ │ ├── PostgresConnection.php │ │ ├── SQLiteConnection.php │ │ └── SqlServerConnection.php │ ├── Connectors │ │ └── ConnectionFactory.php │ ├── DatabaseServiceProvider.php │ ├── Dongle.php │ ├── ExpandoModel.php │ ├── Factories │ │ ├── Factory.php │ │ └── HasFactory.php │ ├── MigrationServiceProvider.php │ ├── Migrations │ │ ├── 2013_10_01_000001_Db_Deferred_Bindings.php │ │ ├── 2013_10_01_000002_Db_Files.php │ │ └── 2015_10_01_000003_Db_Revisions.php │ ├── Model.php │ ├── ModelBehavior.php │ ├── ModelException.php │ ├── Models │ │ ├── DeferredBinding.php │ │ └── Revision.php │ ├── MorphPivot.php │ ├── NestedTreeScope.php │ ├── Pivot.php │ ├── QueryBuilder.php │ ├── README.md │ ├── Relations │ │ ├── AttachMany.php │ │ ├── AttachOne.php │ │ ├── AttachOneOrMany.php │ │ ├── BelongsTo.php │ │ ├── BelongsToMany.php │ │ ├── DeferOneOrMany.php │ │ ├── DefinedConstraints.php │ │ ├── HasMany.php │ │ ├── HasManyThrough.php │ │ ├── HasOne.php │ │ ├── HasOneOrMany.php │ │ ├── HasOneThrough.php │ │ ├── MorphMany.php │ │ ├── MorphOne.php │ │ ├── MorphOneOrMany.php │ │ ├── MorphTo.php │ │ ├── MorphToMany.php │ │ └── Relation.php │ ├── Replicator.php │ ├── Schema │ │ └── Blueprint.php │ ├── Scopes │ │ ├── MultisiteScope.php │ │ ├── NestedTreeScope.php │ │ ├── SoftDeleteScope.php │ │ └── SortableScope.php │ ├── SortableScope.php │ ├── Traits │ │ ├── BaseIdentifier.php │ │ ├── Defaultable.php │ │ ├── DeferredBinding.php │ │ ├── Encryptable.php │ │ ├── Hashable.php │ │ ├── Multisite.php │ │ ├── NestedTree.php │ │ ├── Nullable.php │ │ ├── Purgeable.php │ │ ├── Revisionable.php │ │ ├── SimpleTree.php │ │ ├── Sluggable.php │ │ ├── SluggableTree.php │ │ ├── SoftDelete.php │ │ ├── Sortable.php │ │ ├── SortableRelation.php │ │ ├── UserFootprints.php │ │ └── Validation.php │ ├── TreeCollection.php │ ├── Updater.php │ └── Updates │ │ ├── Migration.php │ │ └── Seeder.php ├── Element │ ├── ElementBase.php │ ├── ElementHolder.php │ ├── Filter │ │ └── ScopeDefinition.php │ ├── Form │ │ ├── FieldDefinition.php │ │ └── FieldsetDefinition.php │ ├── Lists │ │ └── ColumnDefinition.php │ ├── Navigation │ │ └── ItemDefinition.php │ └── OptionDefinition.php ├── Events │ ├── Dispatcher.php │ ├── EventServiceProvider.php │ ├── FakeDispatcher.php │ └── PriorityDispatcher.php ├── Exception │ ├── AjaxException.php │ ├── ApplicationException.php │ ├── ErrorHandler.php │ ├── ExceptionBase.php │ ├── ForbiddenException.php │ ├── NotFoundException.php │ ├── SystemException.php │ └── ValidationException.php ├── Extension │ ├── Container.php │ ├── Extendable.php │ ├── ExtendableTrait.php │ ├── ExtensionBase.php │ ├── ExtensionTrait.php │ └── README.md ├── Filesystem │ ├── Definitions.php │ ├── Filesystem.php │ ├── FilesystemServiceProvider.php │ ├── README.md │ └── Zip.php ├── Flash │ ├── FlashBag.php │ └── FlashServiceProvider.php ├── Foundation │ ├── Application.php │ ├── Bootstrap │ │ ├── LoadConfiguration.php │ │ ├── LoadEnvironmentFromHost.php │ │ ├── RegisterClassLoader.php │ │ └── RegisterOctober.php │ ├── Console │ │ ├── ClearCompiledCommand.php │ │ ├── Kernel.php │ │ ├── ProjectSetCommand.php │ │ ├── RouteCacheCommand.php │ │ ├── RouteListCommand.php │ │ └── ServeCommand.php │ ├── Exception │ │ └── Handler.php │ ├── Http │ │ ├── Kernel.php │ │ └── Middleware │ │ │ ├── CheckForMaintenanceMode.php │ │ │ └── EncryptCookies.php │ ├── Providers │ │ ├── AppDeferSupportServiceProvider.php │ │ ├── AppSupportServiceProvider.php │ │ ├── ArtisanServiceProvider.php │ │ ├── ExecutionContextProvider.php │ │ └── LogServiceProvider.php │ └── resources │ │ └── server.php ├── Halcyon │ ├── Builder.php │ ├── Collection.php │ ├── Concerns │ │ └── HasEvents.php │ ├── Datasource │ │ ├── AutoDatasource.php │ │ ├── Datasource.php │ │ ├── DatasourceInterface.php │ │ ├── DbDatasource.php │ │ ├── FileDatasource.php │ │ ├── Resolver.php │ │ └── ResolverInterface.php │ ├── Exception │ │ ├── CreateDirectoryException.php │ │ ├── CreateFileException.php │ │ ├── DeleteFileException.php │ │ ├── FileExistsException.php │ │ ├── InvalidDirectoryNameException.php │ │ ├── InvalidExtensionException.php │ │ ├── InvalidFileNameException.php │ │ ├── MissingFileNameException.php │ │ └── ModelException.php │ ├── HalcyonServiceProvider.php │ ├── Migrations │ │ └── 2021_10_01_000001_Db_Templates.php │ ├── Model.php │ ├── Processors │ │ ├── Processor.php │ │ └── SectionParser.php │ ├── README.md │ └── Traits │ │ └── Validation.php ├── Html │ ├── BlockBuilder.php │ ├── FormBuilder.php │ ├── Helper.php │ ├── HtmlBuilder.php │ ├── HtmlServiceProvider.php │ ├── README.md │ ├── UrlMixin.php │ ├── UrlServiceProvider.php │ └── helpers.php ├── Mail │ ├── FakeMailer.php │ ├── MailManager.php │ ├── MailParser.php │ ├── MailServiceProvider.php │ ├── Mailable.php │ └── Mailer.php ├── Network │ └── Http.php ├── Parse │ ├── Bracket.php │ ├── Ini.php │ ├── Markdown.php │ ├── MarkdownData.php │ ├── ParseServiceProvider.php │ ├── Parsedown │ │ ├── Parsedown.php │ │ └── ParsedownExtra.php │ ├── Syntax │ │ ├── FieldParser.php │ │ ├── Parser.php │ │ ├── README.md │ │ └── SyntaxModelTrait.php │ ├── Twig.php │ └── Yaml.php ├── Resize │ ├── BrokenImage.php │ ├── ResizeBuilder.php │ ├── ResizeServiceProvider.php │ └── Resizer.php ├── Router │ ├── CoreRedirector.php │ ├── CoreRouter.php │ ├── Helper.php │ ├── README.md │ ├── Router.php │ ├── RoutingServiceProvider.php │ └── Rule.php ├── Scaffold │ ├── Console │ │ ├── CreateCommand.php │ │ ├── CreateComponent.php │ │ ├── CreateContentField.php │ │ ├── CreateController.php │ │ ├── CreateFactory.php │ │ ├── CreateFilterWidget.php │ │ ├── CreateFormWidget.php │ │ ├── CreateJob.php │ │ ├── CreateMigration.php │ │ ├── CreateModel.php │ │ ├── CreatePlugin.php │ │ ├── CreateReportWidget.php │ │ ├── CreateSeeder.php │ │ ├── CreateTest.php │ │ ├── command │ │ │ └── command.stub │ │ ├── component │ │ │ ├── component.stub │ │ │ └── default.stub │ │ ├── contentfield │ │ │ └── contentfield.stub │ │ ├── controller │ │ │ ├── _list_toolbar.stub │ │ │ ├── config_form.stub │ │ │ ├── config_list.stub │ │ │ ├── controller.stub │ │ │ ├── create.stub │ │ │ ├── create_design.stub │ │ │ ├── index.stub │ │ │ ├── preview.stub │ │ │ ├── preview_design.stub │ │ │ ├── update.stub │ │ │ └── update_design.stub │ │ ├── factory │ │ │ ├── factory.stub │ │ │ └── factory_app.stub │ │ ├── filterwidget │ │ │ ├── filterwidget.stub │ │ │ ├── javascript.stub │ │ │ ├── partial.stub │ │ │ ├── partial_form.stub │ │ │ └── stylesheet.stub │ │ ├── formwidget │ │ │ ├── formwidget.stub │ │ │ ├── javascript.stub │ │ │ ├── partial.stub │ │ │ └── stylesheet.stub │ │ ├── job │ │ │ ├── job.queued.stub │ │ │ └── job.stub │ │ ├── migration │ │ │ ├── create_app_table.stub │ │ │ ├── create_table.stub │ │ │ ├── update_app_table.stub │ │ │ └── update_table.stub │ │ ├── model │ │ │ ├── columns.stub │ │ │ ├── fields.stub │ │ │ └── model.stub │ │ ├── plugin │ │ │ ├── composer.stub │ │ │ ├── plugin.stub │ │ │ └── version.stub │ │ ├── reportwidget │ │ │ ├── reportwidget.stub │ │ │ └── widget.stub │ │ ├── seeder │ │ │ ├── create_app_seeder.stub │ │ │ └── create_seeder.stub │ │ └── test │ │ │ ├── phpunit.app.stub │ │ │ ├── phpunit.plugin.stub │ │ │ └── test.stub │ ├── GeneratorCommand.php │ ├── GeneratorCommandBase.php │ └── ScaffoldServiceProvider.php ├── Support │ ├── Arr.php │ ├── ClassLoader.php │ ├── Collection.php │ ├── Debug │ │ └── HtmlDumper.php │ ├── Facade.php │ ├── Facades │ │ ├── Auth.php │ │ ├── Block.php │ │ ├── Config.php │ │ ├── Currency.php │ │ ├── DbDongle.php │ │ ├── Event.php │ │ ├── File.php │ │ ├── Flash.php │ │ ├── Form.php │ │ ├── Html.php │ │ ├── Ini.php │ │ ├── Input.php │ │ ├── Mail.php │ │ ├── Markdown.php │ │ ├── Resizer.php │ │ ├── Schema.php │ │ ├── Site.php │ │ ├── Str.php │ │ ├── Twig.php │ │ ├── Url.php │ │ ├── Validator.php │ │ └── Yaml.php │ ├── ModuleServiceProvider.php │ ├── README.md │ ├── SafeCollection.php │ ├── ServiceProvider.php │ ├── Singleton.php │ ├── Str.php │ ├── Traits │ │ ├── Emitter.php │ │ ├── KeyParser.php │ │ └── Singleton.php │ ├── helpers.php │ └── polyfills.php ├── Translation │ ├── FileLoader.php │ ├── README.md │ ├── TranslationServiceProvider.php │ └── Translator.php └── Validation │ ├── Concerns │ └── FormatsMessages.php │ ├── Factory.php │ ├── ValidationServiceProvider.php │ └── Validator.php └── tests ├── Assetic ├── MockAsset.php └── StylesheetMinifyTest.php ├── Benchmark ├── GeneralBench.php └── Router │ └── RouterBench.php ├── Database ├── DongleTest.php ├── ModelAddersTest.php ├── SortableTest.php ├── Traits │ ├── EncryptableTest.php │ ├── SluggableTest.php │ └── ValidationTest.php └── UpdaterTest.php ├── Events └── EventDispatcherTest.php ├── Extension ├── ExtendableTest.php └── ExtensionTest.php ├── Halcyon ├── DatasourceResolverTest.php ├── HalcyonModelTest.php ├── SectionParserTest.php └── ValidationTraitTest.php ├── Html ├── HtmlBuilderTest.php └── HtmlHelperTest.php ├── Mail └── MailerTest.php ├── Network └── HttpTest.php ├── Parse ├── BracketTest.php ├── IniTest.php ├── MarkdownTest.php ├── SyntaxFieldParserTest.php └── SyntaxParserTest.php ├── Router ├── RouteTest.php └── RouterHelperTest.php ├── Scaffold └── ScaffoldBaseTest.php ├── Support ├── CountableTest.php ├── EmitterTest.php └── HttpBuildQueryTest.php ├── TestCase.php ├── Translation └── TranslatorTest.php ├── fixtures ├── config │ └── sample-config.php ├── database │ └── SampleClass.php ├── halcyon │ ├── models │ │ ├── Content.php │ │ ├── Menu.php │ │ └── Page.php │ └── themes │ │ ├── theme1 │ │ ├── content │ │ │ └── welcome.htm │ │ ├── menus │ │ │ └── mainmenu.htm │ │ └── pages │ │ │ ├── about.htm │ │ │ ├── home.htm │ │ │ └── level1 │ │ │ ├── level2 │ │ │ └── level3 │ │ │ │ └── level4 │ │ │ │ └── level5 │ │ │ │ ├── contact.htm │ │ │ │ └── level6 │ │ │ │ └── unknown.htm │ │ │ └── team.htm │ │ └── theme2 │ │ └── pages │ │ └── home.htm ├── lang │ └── en │ │ └── lang.php └── parse │ ├── array.ini │ ├── basic.ini │ ├── comments-clean.ini │ ├── comments.ini │ ├── complex.ini │ ├── multilines-value.ini │ ├── object.ini │ ├── sections.ini │ ├── simple.ini │ └── subsections.ini └── phpunit.xml /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - 2.x 7 | - 3.x 8 | - develop 9 | pull_request: 10 | 11 | jobs: 12 | phpUnitTests: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | max-parallel: 6 16 | matrix: 17 | phpVersions: ['8.0', '8.1', '8.2', '8.3'] 18 | fail-fast: false 19 | name: PHP ${{ matrix.phpVersions }} 20 | steps: 21 | - name: Checkout changes 22 | uses: actions/checkout@v1 23 | - name: Install PHP 24 | uses: shivammathur/setup-php@master 25 | with: 26 | php-version: ${{ matrix.phpVersions }} 27 | - name: Install Composer dependencies 28 | run: composer install --no-interaction --no-progress --no-suggest --no-scripts 29 | - name: Run Tests 30 | run: ./vendor/bin/phpunit ./tests 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Composer files 2 | /vendor 3 | composer.phar 4 | composer.lock 5 | 6 | # Editor files 7 | .idea 8 | .vscode 9 | 10 | # Other files 11 | .DS_Store 12 | php_errors.log 13 | .phpunit.result.cache -------------------------------------------------------------------------------- /CREDITS.md: -------------------------------------------------------------------------------- 1 | # Credits 2 | 3 | This library was created with help from the following packages: 4 | 5 | "Laravel", Copyright (c) Taylor Otwell 6 | https://github.com/laravel/framework 7 | 8 | "Parsedown", Copyright (c) 2013-2018 Emanuil Rusev, erusev.com 9 | https://github.com/erusev/parsedown 10 | 11 | "Assetic", Copyright (c) 2010-2015 OpenSky Project Inc 12 | https://github.com/kriswallsmith/assetic 13 | 14 | "http_build_url() for PHP", Copyright (c) 2015 Jake A. Smith 15 | https://github.com/jakeasmith/http_build_url 16 | 17 | "Twig extensions", Copyright (c) 2016 Vojta Svoboda 18 | https://github.com/vojtasvoboda/oc-twigextensions-plugin 19 | 20 | "October Code", Copyright (c) 2022 Sergey Kasyanov 21 | https://github.com/SergeyKasyanov/vscode-october-extension 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | October Rain 2 | ======= 3 | 4 | This repository contains the core library of October CMS. If you want to build a website using October, visit the main [October repository](http://github.com/octobercms/october). 5 | 6 | ## License 7 | 8 | The October CMS platform is licensed software, see [End User License Agreement](./LICENSE.md) (EULA) for more details. 9 | -------------------------------------------------------------------------------- /contracts/Database/MultisiteInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/** 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Argon/Argon.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class StringAsset extends BaseAsset 11 | { 12 | private $string; 13 | private $lastModified; 14 | 15 | /** 16 | * __construct 17 | * 18 | * @param string $content The content of the asset 19 | * @param array $filters Filters for the asset 20 | * @param string $sourceRoot The source asset root directory 21 | * @param string $sourcePath The source asset path 22 | */ 23 | public function __construct($content, $filters = [], $sourceRoot = null, $sourcePath = null) 24 | { 25 | $this->string = $content; 26 | 27 | parent::__construct($filters, $sourceRoot, $sourcePath); 28 | } 29 | 30 | /** 31 | * load 32 | */ 33 | public function load(FilterInterface $additionalFilter = null) 34 | { 35 | $this->doLoad($this->string, $additionalFilter); 36 | } 37 | 38 | /** 39 | * setLastModified 40 | */ 41 | public function setLastModified($lastModified) 42 | { 43 | $this->lastModified = $lastModified; 44 | } 45 | 46 | /** 47 | * getLastModified 48 | */ 49 | public function getLastModified() 50 | { 51 | return $this->lastModified; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Assetic/AsseticServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('assetic', function ($app) { 17 | $combiner = new Combiner; 18 | $combiner->setStoragePath(storage_path('cms/combiner/assets')); 19 | $combiner->registerDefaultFilters(); 20 | return $combiner; 21 | }); 22 | } 23 | 24 | /** 25 | * provides the returned services. 26 | * @return array 27 | */ 28 | public function provides() 29 | { 30 | return [ 31 | 'assetic', 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Assetic/Cache/ArrayCache.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class ArrayCache implements CacheInterface 9 | { 10 | private $cache = array(); 11 | 12 | /** 13 | * @see CacheInterface::has() 14 | */ 15 | public function has($key) 16 | { 17 | return isset($this->cache[$key]); 18 | } 19 | 20 | /** 21 | * @see CacheInterface::get() 22 | */ 23 | public function get($key) 24 | { 25 | if (!$this->has($key)) { 26 | throw new \RuntimeException('There is no cached value for '.$key); 27 | } 28 | 29 | return $this->cache[$key]; 30 | } 31 | 32 | /** 33 | * @see CacheInterface::set() 34 | */ 35 | public function set($key, $value) 36 | { 37 | $this->cache[$key] = $value; 38 | } 39 | 40 | /** 41 | * @see CacheInterface::remove() 42 | */ 43 | public function remove($key) 44 | { 45 | unset($this->cache[$key]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Assetic/Cache/CacheInterface.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface CacheInterface 9 | { 10 | /** 11 | * Checks if the cache has a value for a key. 12 | * 13 | * @param string $key A unique key 14 | * 15 | * @return Boolean Whether the cache has a value for this key 16 | */ 17 | public function has($key); 18 | 19 | /** 20 | * Returns the value for a key. 21 | * 22 | * @param string $key A unique key 23 | * 24 | * @return string|null The value in the cache 25 | */ 26 | public function get($key); 27 | 28 | /** 29 | * Sets a value in the cache. 30 | * 31 | * @param string $key A unique key 32 | * @param string $value The value to cache 33 | */ 34 | public function set($key, $value); 35 | 36 | /** 37 | * Removes a value from the cache. 38 | * 39 | * @param string $key A unique key 40 | */ 41 | public function remove($key); 42 | } 43 | -------------------------------------------------------------------------------- /src/Assetic/Exception/Exception.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface Exception 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/Assetic/Exception/FilterException.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class FilterException extends \RuntimeException implements Exception 9 | { 10 | private $originalMessage; 11 | private $input; 12 | 13 | public function __construct($message, $code = 0, \Exception $previous = null) 14 | { 15 | parent::__construct($message, $code, $previous); 16 | 17 | $this->originalMessage = $message; 18 | } 19 | 20 | public function setInput($input) 21 | { 22 | $this->input = $input; 23 | $this->updateMessage(); 24 | 25 | return $this; 26 | } 27 | 28 | public function getInput() 29 | { 30 | return $this->input; 31 | } 32 | 33 | private function updateMessage() 34 | { 35 | $message = $this->originalMessage; 36 | 37 | if (!empty($this->input)) { 38 | $message .= "\n\nInput:\n".$this->input; 39 | } 40 | 41 | $this->message = $message; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Assetic/Factory/Resource/DirectoryResourceFilterIterator.php: -------------------------------------------------------------------------------- 1 | 7 | * @access private 8 | */ 9 | class DirectoryResourceFilterIterator extends \RecursiveFilterIterator 10 | { 11 | protected $pattern; 12 | 13 | public function __construct(\RecursiveDirectoryIterator $iterator, $pattern = null) 14 | { 15 | parent::__construct($iterator); 16 | 17 | $this->pattern = $pattern; 18 | } 19 | 20 | public function accept() 21 | { 22 | $file = $this->current(); 23 | $name = $file->getBasename(); 24 | 25 | if ($file->isDir()) { 26 | return '.' != $name[0]; 27 | } 28 | 29 | return null === $this->pattern || 0 < preg_match($this->pattern, $name); 30 | } 31 | 32 | public function getChildren() 33 | { 34 | return new self(new \RecursiveDirectoryIterator($this->current()->getPathname(), \RecursiveDirectoryIterator::FOLLOW_SYMLINKS), $this->pattern); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Assetic/Factory/Resource/DirectoryResourceIterator.php: -------------------------------------------------------------------------------- 1 | 7 | * @access private 8 | */ 9 | class DirectoryResourceIterator extends \RecursiveIteratorIterator 10 | { 11 | /** 12 | * current 13 | */ 14 | public function current() 15 | { 16 | return new FileResource(parent::current()->getPathname()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Assetic/Factory/Resource/FileResource.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | class FileResource implements ResourceInterface 9 | { 10 | protected $path; 11 | 12 | /** 13 | * __construct 14 | * 15 | * @param string $path The path to a file 16 | */ 17 | public function __construct($path) 18 | { 19 | $this->path = $path; 20 | } 21 | 22 | public function isFresh($timestamp) 23 | { 24 | return file_exists($this->path) && filemtime($this->path) <= $timestamp; 25 | } 26 | 27 | public function getContent() 28 | { 29 | return file_exists($this->path) ? file_get_contents($this->path) : ''; 30 | } 31 | 32 | public function __toString() 33 | { 34 | return $this->path; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Assetic/Factory/Resource/IteratorResourceInterface.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface IteratorResourceInterface extends ResourceInterface, \IteratorAggregate 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/Assetic/Factory/Resource/ResourceInterface.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface ResourceInterface 9 | { 10 | /** 11 | * Checks if a timestamp represents the latest resource. 12 | * 13 | * @param integer $timestamp A UNIX timestamp 14 | * 15 | * @return Boolean True if the timestamp is up to date 16 | */ 17 | public function isFresh($timestamp); 18 | 19 | /** 20 | * Returns the content of the resource. 21 | * 22 | * @return string The content 23 | */ 24 | public function getContent(); 25 | 26 | /** 27 | * Returns a unique string for the current resource. 28 | * 29 | * @return string A unique string to identity the current resource 30 | */ 31 | public function __toString(); 32 | } 33 | -------------------------------------------------------------------------------- /src/Assetic/Filter/BaseCssFilter.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | abstract class BaseCssFilter implements FilterInterface 11 | { 12 | /** 13 | * @see CssUtils::filterReferences() 14 | */ 15 | protected function filterReferences($content, $callback, $limit = -1, &$count = 0) 16 | { 17 | return CssUtils::filterReferences($content, $callback, $limit, $count); 18 | } 19 | 20 | /** 21 | * @see CssUtils::filterUrls() 22 | */ 23 | protected function filterUrls($content, $callback, $limit = -1, &$count = 0) 24 | { 25 | return CssUtils::filterUrls($content, $callback, $limit, $count); 26 | } 27 | 28 | /** 29 | * @see CssUtils::filterImports() 30 | */ 31 | protected function filterImports($content, $callback, $limit = -1, &$count = 0, $includeUrl = true) 32 | { 33 | return CssUtils::filterImports($content, $callback, $limit, $count, $includeUrl); 34 | } 35 | 36 | /** 37 | * @see CssUtils::filterIEFilters() 38 | */ 39 | protected function filterIEFilters($content, $callback, $limit = -1, &$count = 0) 40 | { 41 | return CssUtils::filterIEFilters($content, $callback, $limit, $count); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Assetic/Filter/CallablesFilter.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class CallablesFilter implements FilterInterface, DependencyExtractorInterface 12 | { 13 | private $loader; 14 | private $dumper; 15 | private $extractor; 16 | 17 | /** 18 | * @param callable|null $loader 19 | * @param callable|null $dumper 20 | * @param callable|null $extractor 21 | */ 22 | public function __construct($loader = null, $dumper = null, $extractor = null) 23 | { 24 | $this->loader = $loader; 25 | $this->dumper = $dumper; 26 | $this->extractor = $extractor; 27 | } 28 | 29 | public function filterLoad(AssetInterface $asset) 30 | { 31 | if (null !== $callable = $this->loader) { 32 | $callable($asset); 33 | } 34 | } 35 | 36 | public function filterDump(AssetInterface $asset) 37 | { 38 | if (null !== $callable = $this->dumper) { 39 | $callable($asset); 40 | } 41 | } 42 | 43 | public function getChildren(AssetFactory $factory, $content, $loadPath = null) 44 | { 45 | if (null !== $callable = $this->extractor) { 46 | return $callable($factory, $content, $loadPath); 47 | } 48 | 49 | return array(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Assetic/Filter/CssCacheBustingFilter.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class CssCacheBustingFilter extends BaseCssFilter 12 | { 13 | private $version; 14 | private $format = '%s?%s'; 15 | 16 | public function setVersion($version) 17 | { 18 | $this->version = $version; 19 | } 20 | 21 | public function setFormat($versionFormat) 22 | { 23 | $this->format = $versionFormat; 24 | } 25 | 26 | public function filterLoad(AssetInterface $asset) 27 | { 28 | } 29 | 30 | public function filterDump(AssetInterface $asset) 31 | { 32 | if (!$this->version) { 33 | return; 34 | } 35 | 36 | $version = $this->version; 37 | $format = $this->format; 38 | 39 | $asset->setContent($this->filterReferences( 40 | $asset->getContent(), 41 | function ($matches) use ($version, $format) { 42 | if (0 === strpos($matches['url'], 'data:')) { 43 | return $matches[0]; 44 | } 45 | 46 | return str_replace( 47 | $matches['url'], 48 | sprintf($format, $matches['url'], $version), 49 | $matches[0] 50 | ); 51 | } 52 | )); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Assetic/Filter/DependencyExtractorInterface.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | interface DependencyExtractorInterface extends FilterInterface 12 | { 13 | /** 14 | * Returns child assets. 15 | * 16 | * @param AssetFactory $factory The asset factory 17 | * @param string $content The asset content 18 | * @param string $loadPath An optional load path 19 | * 20 | * @return AssetInterface[] Child assets 21 | */ 22 | public function getChildren(AssetFactory $factory, $content, $loadPath = null); 23 | } 24 | -------------------------------------------------------------------------------- /src/Assetic/Filter/FilterInterface.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | interface FilterInterface 11 | { 12 | /** 13 | * Filters an asset after it has been loaded. 14 | * 15 | * @param AssetInterface $asset An asset 16 | */ 17 | public function filterLoad(AssetInterface $asset); 18 | 19 | /** 20 | * Filters an asset just before it's dumped. 21 | * 22 | * @param AssetInterface $asset An asset 23 | */ 24 | public function filterDump(AssetInterface $asset); 25 | } 26 | -------------------------------------------------------------------------------- /src/Assetic/Filter/HashableInterface.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | interface HashableInterface 9 | { 10 | /** 11 | * Generates a hash for the object 12 | * 13 | * @return string Object hash 14 | */ 15 | public function hash(); 16 | } 17 | -------------------------------------------------------------------------------- /src/Assetic/Filter/JSMinFilter.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class JSMinFilter implements FilterInterface 16 | { 17 | /** 18 | * filterLoad 19 | */ 20 | public function filterLoad(AssetInterface $asset) 21 | { 22 | } 23 | 24 | /** 25 | * filterDump will use JSMin to minify the asset and checks the filename 26 | * for "min.js" to issues arising from double minification. 27 | */ 28 | public function filterDump(AssetInterface $asset) 29 | { 30 | $contents = $asset->getContent(); 31 | 32 | $isMinifiedAlready = strpos($asset->getSourcePath(), '.min.js') !== false; 33 | if (!$isMinifiedAlready) { 34 | $contents = JSMin::minify($contents); 35 | } 36 | 37 | $asset->setContent($contents); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Assetic/README.md: -------------------------------------------------------------------------------- 1 | # Rain Assetic Resources 2 | 3 | Assetic is a simple library that lets you compile and combine basic LESS and SCSS files. 4 | 5 | ## Basic usage 6 | 7 | You may use the `parse` methods to parse LESS or SCSS respectively, the first argument is the asset paths and the second argument is the options. The file extension determines which compiler is used, either `.less` or `.scss`. 8 | 9 | ```php 10 | $combiner = new October\Rain\Assetic\Combiner; 11 | 12 | echo $combiner->parse([ 13 | '/path/to/src/styles.less', 14 | '/path/to/src/theme.less' 15 | ], [ 16 | 'production' => true 17 | ]); 18 | ``` 19 | 20 | The following options are supported 21 | 22 | Options | Usage 23 | ------- | --------- 24 | `production` | Combine with production filters (eg: minification). 25 | `targetPath` | Sets the target output path for rewriting asset locations. 26 | `useCache` | Use a file based cache to speed up performance. 27 | `deepHashKey` | Cache key used for busting deep hashing. 28 | -------------------------------------------------------------------------------- /src/Assetic/Util/LessUtils.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | abstract class LessUtils extends CssUtils 10 | { 11 | const REGEX_IMPORTS = '/@import(?:-once)? (?:\([a-z]*\) )?(?:url\()?(\'|"|)(?P[^\'"\)\n\r]*)\1\)?;?/'; 12 | const REGEX_IMPORTS_NO_URLS = '/@import(?:-once)? (?:\([a-z]*\) )?(?!url\()(\'|"|)(?P[^\'"\)\n\r]*)\1;?/'; 13 | const REGEX_COMMENTS = '/((?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)|\/\/[^\n]+)/'; 14 | } 15 | -------------------------------------------------------------------------------- /src/Assetic/Util/SassUtils.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | abstract class SassUtils extends CssUtils 18 | { 19 | const REGEX_COMMENTS = '/((?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)|\/\/[^\n]+)/'; 20 | } 21 | -------------------------------------------------------------------------------- /src/Auth/Concerns/HasProviderProxy.php: -------------------------------------------------------------------------------- 1 | userModel; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2013_10_01_000001_Db_Users.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('first_name')->nullable(); 13 | $table->string('last_name')->nullable(); 14 | $table->string('login')->unique()->index(); 15 | $table->string('email')->unique(); 16 | $table->string('password'); 17 | $table->string('activation_code')->nullable()->index(); 18 | $table->string('persist_code')->nullable(); 19 | $table->string('reset_password_code')->nullable()->index(); 20 | $table->text('permissions')->nullable(); 21 | $table->boolean('is_activated')->default(0); 22 | $table->boolean('is_superuser')->default(false); 23 | $table->timestamp('activated_at')->nullable(); 24 | $table->timestamp('last_login')->nullable(); 25 | $table->integer('role_id')->unsigned()->nullable()->index(); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | public function down() 31 | { 32 | Schema::drop('users'); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2013_10_01_000002_Db_Groups.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('name')->unique(); 13 | $table->string('code')->nullable()->index(); 14 | $table->text('description')->nullable(); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::drop('groups'); 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2013_10_01_000003_Db_Users_Groups.php: -------------------------------------------------------------------------------- 1 | integer('user_id')->unsigned(); 12 | $table->integer('group_id')->unsigned(); 13 | $table->primary(['user_id', 'group_id']); 14 | }); 15 | } 16 | 17 | public function down() 18 | { 19 | Schema::drop('users_groups'); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2013_10_01_000004_Db_Preferences.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->integer('user_id')->unsigned(); 13 | $table->string('namespace', 100); 14 | $table->string('group', 50); 15 | $table->string('item', 150); 16 | $table->text('value')->nullable(); 17 | $table->index(['user_id', 'namespace', 'group', 'item'], 'user_item_index'); 18 | }); 19 | } 20 | 21 | public function down() 22 | { 23 | Schema::drop('preferences'); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2013_10_01_000005_Db_Throttle.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->integer('user_id')->unsigned()->nullable()->index(); 13 | $table->string('ip_address')->nullable()->index(); 14 | $table->integer('attempts')->default(0); 15 | $table->timestamp('last_attempt_at')->nullable(); 16 | $table->boolean('is_suspended')->default(0); 17 | $table->timestamp('suspended_at')->nullable(); 18 | $table->boolean('is_banned')->default(0); 19 | $table->timestamp('banned_at')->nullable(); 20 | }); 21 | } 22 | 23 | public function down() 24 | { 25 | Schema::drop('throttle'); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /src/Auth/Migrations/2017_10_01_000006_Db_Roles.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('name')->unique(); 13 | $table->text('permissions')->nullable(); 14 | $table->timestamps(); 15 | }); 16 | } 17 | 18 | public function down() 19 | { 20 | Schema::drop('roles'); 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /src/Auth/Models/Group.php: -------------------------------------------------------------------------------- 1 | 'required|between:4,16|unique:groups', 22 | ]; 23 | 24 | /** 25 | * @var array belongsToMany relationship 26 | */ 27 | public $belongsToMany = [ 28 | 'users' => [User::class, 'table' => 'users_groups'] 29 | ]; 30 | 31 | /** 32 | * @var array fillable fields 33 | */ 34 | protected $fillable = [ 35 | 'name', 36 | 'code', 37 | 'description', 38 | ]; 39 | 40 | /** 41 | * delete the group 42 | * @return bool 43 | */ 44 | public function delete() 45 | { 46 | $this->users()->detach(); 47 | return parent::delete(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Combine/Combiner.php: -------------------------------------------------------------------------------- 1 | minify($text); 17 | } 18 | 19 | /** 20 | * compileLess 21 | */ 22 | public function compileLess(array $text, $options = []) 23 | { 24 | return (new LessCompile)->compile($text, $options); 25 | } 26 | 27 | /** 28 | * compileScss 29 | */ 30 | public function compileScss(array $text, $options = []) 31 | { 32 | return (new ScssCompile)->compile($text, $options); 33 | } 34 | 35 | /** 36 | * minifyJs 37 | */ 38 | public function minifyJs(array $text, $options = []) 39 | { 40 | return (new JavascriptMinify)->minify($text); 41 | } 42 | 43 | /** 44 | * compileJs 45 | */ 46 | public function compileJs(array $text, $options = []) 47 | { 48 | return (new JsCompile)->compile($text, $options); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Combine/CombinerServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('combiner', function ($app) { 20 | return new Combiner; 21 | }); 22 | } 23 | 24 | /** 25 | * provides the returned services. 26 | * @return array 27 | */ 28 | public function provides() 29 | { 30 | return [ 31 | 'combiner', 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Combine/JavascriptMinify.php: -------------------------------------------------------------------------------- 1 | minify(file_get_contents($path)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Combine/LessCompile.php: -------------------------------------------------------------------------------- 1 | null, 20 | 'compress' => false, 21 | ], $options)); 22 | 23 | $parser = new Less_Parser([ 24 | 'compress' => (bool) $compress 25 | ]); 26 | 27 | $parser->parse($less); 28 | 29 | // Set the LESS variables after parsing to override them 30 | if ($vars) { 31 | $parser->ModifyVars($vars); 32 | } 33 | 34 | return $parser->getCss(); 35 | } 36 | 37 | /** 38 | * compileFile 39 | */ 40 | public function compileFile($path, $options = []) 41 | { 42 | return $this->compile(file_get_contents($path), $options); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Combine/ScssCompile.php: -------------------------------------------------------------------------------- 1 | null, 20 | 'compress' => false, // @todo 21 | ], $options)); 22 | 23 | $parser = new Compiler(); 24 | 25 | if ($vars) { 26 | $parser->addVariables($vars); 27 | } 28 | 29 | $result = $parser->compileString($scss); 30 | 31 | return $result->getCss(); 32 | } 33 | 34 | /** 35 | * compileFile 36 | */ 37 | public function compileFile($path, $options = []) 38 | { 39 | return $this->compile(file_get_contents($path), $options); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Composer/Concerns/HasOctoberCommands.php: -------------------------------------------------------------------------------- 1 | addRepository( 17 | 'octobercms', 18 | 'composer', 19 | $url, 20 | [ 21 | 'only' => ['october/*', '*-plugin', '*-theme'] 22 | ] 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Composer/Concerns/HasOutput.php: -------------------------------------------------------------------------------- 1 | output = new NullIO(); 30 | } 31 | else { 32 | $this->output = $output; 33 | } 34 | } 35 | 36 | /** 37 | * setOutputCommand 38 | */ 39 | public function setOutputCommand(Command $command, InputInterface $input) 40 | { 41 | $this->setOutput(new ConsoleIO($input, $command->getOutput(), $command->getHelperSet())); 42 | } 43 | 44 | /** 45 | * setOutputBuffer 46 | */ 47 | public function setOutputBuffer() 48 | { 49 | $this->setOutput(new BufferIO()); 50 | } 51 | 52 | /** 53 | * getOutputBuffer 54 | */ 55 | public function getOutputBuffer(): string 56 | { 57 | if ($this->output instanceof BufferIO) { 58 | return $this->output->getOutput(); 59 | } 60 | 61 | return ''; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Composer/resources/file_get_contents.php: -------------------------------------------------------------------------------- 1 | pluck($value, $key)->all(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Database/Connections/Connection.php: -------------------------------------------------------------------------------- 1 | getQueryGrammar(), 20 | $this->getPostProcessor() 21 | ); 22 | } 23 | 24 | /** 25 | * logQuery in the connection's query log 26 | * @param string $query 27 | * @param array $bindings 28 | * @param float|null $time 29 | * @return void 30 | */ 31 | public function logQuery($query, $bindings, $time = null) 32 | { 33 | if (isset($this->events)) { 34 | $this->events->dispatch('illuminate.query', [$query, $bindings, $time, $this->getName()]); 35 | } 36 | 37 | parent::logQuery($query, $bindings, $time); 38 | } 39 | 40 | /** 41 | * fireConnectionEvent for this connection 42 | * @param string $event 43 | * @return void 44 | */ 45 | protected function fireConnectionEvent($event) 46 | { 47 | if (isset($this->events)) { 48 | $this->events->dispatch('connection.'.$this->getName().'.'.$event, $this); 49 | } 50 | 51 | parent::fireConnectionEvent($event); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Database/Connections/MySqlConnection.php: -------------------------------------------------------------------------------- 1 | registerUpdater(); 19 | } 20 | 21 | /** 22 | * registerUpdater is like the migrator service, but it updates plugins. 23 | */ 24 | protected function registerUpdater() 25 | { 26 | $this->app->singleton('db.updater', function ($app) { 27 | return new Updater; 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Database/Migrations/2013_10_01_000001_Db_Deferred_Bindings.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('master_type'); 13 | $table->string('master_field'); 14 | $table->string('slave_type'); 15 | $table->integer('slave_id'); 16 | $table->string('session_key'); 17 | $table->mediumText('pivot_data')->nullable(); 18 | $table->boolean('is_bind')->default(true); 19 | $table->integer('sort_order')->nullable(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | public function down() 25 | { 26 | Schema::dropIfExists('deferred_bindings'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/Database/Migrations/2013_10_01_000002_Db_Files.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('disk_name'); 13 | $table->string('file_name'); 14 | $table->integer('file_size'); 15 | $table->string('content_type'); 16 | $table->string('title')->nullable(); 17 | $table->text('description')->nullable(); 18 | $table->string('field')->nullable(); 19 | $table->integer('attachment_id')->nullable(); 20 | $table->string('attachment_type')->nullable(); 21 | $table->boolean('is_public')->default(true); 22 | $table->integer('sort_order')->nullable(); 23 | $table->timestamps(); 24 | 25 | $table->index(['attachment_type', 'attachment_id', 'field'], 'files_master_index'); 26 | }); 27 | } 28 | 29 | public function down() 30 | { 31 | Schema::dropIfExists('files'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/Database/Migrations/2015_10_01_000003_Db_Revisions.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('revisionable_type'); 13 | $table->integer('revisionable_id'); 14 | $table->integer('user_id')->unsigned()->nullable()->index(); 15 | $table->string('field')->nullable()->index(); 16 | $table->string('cast')->nullable(); 17 | $table->text('old_value')->nullable(); 18 | $table->text('new_value')->nullable(); 19 | $table->timestamps(); 20 | $table->index(['revisionable_id', 'revisionable_type']); 21 | }); 22 | } 23 | 24 | public function down() 25 | { 26 | Schema::dropIfExists('revisions'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/Database/ModelBehavior.php: -------------------------------------------------------------------------------- 1 | model = $model; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Database/ModelException.php: -------------------------------------------------------------------------------- 1 | model = $model; 24 | $this->errors = $model->errors(); 25 | $this->evalErrors(); 26 | } 27 | 28 | /** 29 | * getModel returns the model with invalid attributes 30 | */ 31 | public function getModel(): Model 32 | { 33 | return $this->model; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Database/Models/Revision.php: -------------------------------------------------------------------------------- 1 | cast === 'date') { 28 | return $this->asDateTime($value); 29 | } 30 | 31 | return $value; 32 | } 33 | 34 | /** 35 | * getOldValueAttribute returns "old value" casted as the saved type 36 | */ 37 | public function getOldValueAttribute($value) 38 | { 39 | if ($value === null) { 40 | return null; 41 | } 42 | 43 | if ($this->cast === 'date') { 44 | return $this->asDateTime($value); 45 | } 46 | 47 | return $value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Database/NestedTreeScope.php: -------------------------------------------------------------------------------- 1 | relationName = $relationName; 28 | 29 | parent::__construct($query, $farParent, $parent, $firstKey, $secondKey, $localKey, $secondLocalKey); 30 | 31 | $this->addDefinedConstraints(); 32 | } 33 | 34 | /** 35 | * parentSoftDeletes determines whether close parent of the relation uses Soft Deletes. 36 | * @return bool 37 | */ 38 | public function parentSoftDeletes() 39 | { 40 | $uses = class_uses_recursive(get_class($this->parent)); 41 | 42 | return in_array(\October\Rain\Database\Traits\SoftDelete::class, $uses) || 43 | in_array(\Illuminate\Database\Eloquent\SoftDeletes::class, $uses); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Database/Relations/Relation.php: -------------------------------------------------------------------------------- 1 | 'App\Post', 10 | * 'videos' => 'App\Video', 11 | * ]); 12 | * 13 | * 14 | * @package october\database 15 | * @author Alexey Bobkov, Samuel Georges 16 | */ 17 | abstract class Relation extends RelationBase 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Database/Schema/Blueprint.php: -------------------------------------------------------------------------------- 1 | unsignedBigInteger($column)->nullable(); 23 | 24 | $this->unsignedBigInteger('site_root_id')->nullable(); 25 | 26 | $this->index([$column, 'site_root_id'], $indexName); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Database/Scopes/NestedTreeScope.php: -------------------------------------------------------------------------------- 1 | getQuery()->orderBy($model->getLeftColumnName()); 21 | } 22 | 23 | /** 24 | * extend the Eloquent query builder. 25 | */ 26 | public function extend(BuilderBase $builder) 27 | { 28 | $removeOnMethods = ['reorder', 'orderBy', 'groupBy']; 29 | 30 | foreach ($removeOnMethods as $method) { 31 | $builder->macro($method, function ($builder, ...$args) use ($method) { 32 | $builder 33 | ->withoutGlobalScope($this) 34 | ->getQuery() 35 | ->$method(...$args) 36 | ; 37 | 38 | return $builder; 39 | }); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Database/Scopes/SoftDeleteScope.php: -------------------------------------------------------------------------------- 1 | isSoftDeleteEnabled()) { 21 | $builder->whereNull($model->getQualifiedDeletedAtColumn()); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Database/Scopes/SortableScope.php: -------------------------------------------------------------------------------- 1 | getQuery()->orderBy($model->getQualifiedSortOrderColumn()); 21 | } 22 | 23 | /** 24 | * extend the Eloquent query builder. 25 | */ 26 | public function extend(BuilderBase $builder) 27 | { 28 | $removeOnMethods = ['reorder', 'orderBy', 'groupBy']; 29 | 30 | foreach ($removeOnMethods as $method) { 31 | $builder->macro($method, function ($builder, ...$args) use ($method) { 32 | $builder 33 | ->withoutGlobalScope($this) 34 | ->getQuery() 35 | ->$method(...$args) 36 | ; 37 | 38 | return $builder; 39 | }); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Database/SortableScope.php: -------------------------------------------------------------------------------- 1 | command)) { 19 | return; 20 | } 21 | 22 | $styled = $style ? "<$style>$string" : $string; 23 | 24 | $this->command->getOutput()->writeln($styled); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Element/ElementHolder.php: -------------------------------------------------------------------------------- 1 | touchedElements; 27 | } 28 | 29 | /** 30 | * get an element from the holder instance. 31 | * @param string $key 32 | * @param mixed $default 33 | * @return mixed 34 | */ 35 | public function get($key, $default = null) 36 | { 37 | if (isset($this->touchedElements[$key])) { 38 | return $this->touchedElements[$key]; 39 | } 40 | 41 | if (isset($this->config[$key])) { 42 | return $this->touchedElements[$key] = $this->config[$key]; 43 | } 44 | 45 | return parent::get($key, $default); 46 | } 47 | 48 | /** 49 | * getIterator for the elements. 50 | */ 51 | public function getIterator(): Traversable 52 | { 53 | return new Collection($this->config); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Element/Navigation/ItemDefinition.php: -------------------------------------------------------------------------------- 1 | order(-1) 28 | ; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Events/Dispatcher.php: -------------------------------------------------------------------------------- 1 | getLaravelDispatcher() : $dispatcher, 20 | $eventsToFake 21 | ); 22 | } 23 | 24 | /** 25 | * fire proxies to dispatch 26 | */ 27 | public function fire(...$args) 28 | { 29 | return parent::dispatch(...$args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Exception/AjaxException.php: -------------------------------------------------------------------------------- 1 | $contents]; 24 | } 25 | elseif (!is_array($contents)) { 26 | $contents = []; 27 | } 28 | 29 | $this->contents = $contents; 30 | 31 | parent::__construct(json_encode($contents)); 32 | } 33 | 34 | /** 35 | * getContents returns invalid fields. 36 | */ 37 | public function getContents() 38 | { 39 | return $this->contents; 40 | } 41 | 42 | /** 43 | * addContent is used to add extra data to an AJAX exception 44 | */ 45 | public function addContent(string $key, $val) 46 | { 47 | $this->contents[$key] = $val; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Exception/ApplicationException.php: -------------------------------------------------------------------------------- 1 | app->singleton('flash', function () { 14 | return new FlashBag; 15 | }); 16 | 17 | $this->app->alias('flash', FlashBag::class); 18 | } 19 | 20 | /** 21 | * provides gets the services provided by the provider 22 | */ 23 | public function provides() 24 | { 25 | return ['flash']; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Foundation/Bootstrap/LoadEnvironmentFromHost.php: -------------------------------------------------------------------------------- 1 | getEnvironmentConfiguration()) { 22 | $hostname = $_SERVER['HTTP_HOST'] ?? null; 23 | 24 | if ($hostname && isset($config['hosts'][$hostname])) { 25 | putenv("APP_ENV={$config['hosts'][$hostname]}"); 26 | } 27 | } 28 | } 29 | 30 | /** 31 | * getEnvironmentConfiguration loads the file-based environment configuration 32 | */ 33 | protected function getEnvironmentConfiguration(): ?array 34 | { 35 | $configPath = base_path().'/config/environment.php'; 36 | 37 | if (!file_exists($configPath)) { 38 | return null; 39 | } 40 | 41 | try { 42 | $config = require $configPath; 43 | } 44 | catch (Exception $ex) { 45 | $config = []; 46 | } 47 | 48 | return (array) $config; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Foundation/Bootstrap/RegisterClassLoader.php: -------------------------------------------------------------------------------- 1 | basePath() 20 | ); 21 | 22 | $app->instance(ClassLoader::class, $loader); 23 | 24 | $loader->register(); 25 | 26 | $loader->addNamespace('App\\', ''); 27 | 28 | $loader->addDirectories([ 29 | 'modules', 30 | 'plugins' 31 | ]); 32 | 33 | $app->after(function () use ($loader) { 34 | $loader->build(); 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Foundation/Console/ClearCompiledCommand.php: -------------------------------------------------------------------------------- 1 | laravel->getCachedClassesPath())) { 15 | @unlink($classesPath); 16 | } 17 | 18 | parent::handle(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Foundation/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | bootstrap(); 37 | 38 | $this->app['events']->dispatch('console.schedule', [$schedule]); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Foundation/Console/RouteCacheCommand.php: -------------------------------------------------------------------------------- 1 | getFreshApplication()['router']->registerLateRoutes(); 15 | 16 | return tap($routes->getRoutes(), function ($routes) { 17 | $routes->refreshNameLookups(); 18 | $routes->refreshActionLookups(); 19 | }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Foundation/Console/RouteListCommand.php: -------------------------------------------------------------------------------- 1 | registerLateRoutes(); 21 | } 22 | 23 | parent::__construct($router); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Foundation/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | app->maintenanceMode()->data(); 28 | 29 | return Response::make( 30 | View::make($view, [ 31 | 'message' => $ex->getMessage(), 32 | 'retryAfter' => $data['retry'] ?? null, 33 | ]), 34 | $ex->getStatusCode(), 35 | $ex->getHeaders() 36 | ); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Foundation/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | disableFor($except); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Foundation/Providers/AppDeferSupportServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('execution.context', function ($app) { 16 | 17 | $requestPath = $this->normalizeUrl($app['request']->path()); 18 | 19 | $backendUri = $this->normalizeUrl($app['config']->get('backend.uri', 'backend')); 20 | 21 | if (starts_with($requestPath, $backendUri)) { 22 | return 'backend'; 23 | } 24 | 25 | return 'frontend'; 26 | }); 27 | } 28 | 29 | /** 30 | * normalizeUrl adds leading slash from a URL. 31 | * 32 | * @param string $url URL to normalize. 33 | * @return string Returns normalized URL. 34 | */ 35 | protected function normalizeUrl($url) 36 | { 37 | if (substr($url, 0, 1) !== '/') { 38 | $url = '/'.$url; 39 | } 40 | 41 | if (!strlen($url)) { 42 | $url = '/'; 43 | } 44 | 45 | return $url; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Foundation/resources/server.php: -------------------------------------------------------------------------------- 1 | invalidPath = $path; 25 | 26 | $this->message = "Error creating directory [{$path}]. Please check write permissions."; 27 | 28 | return $this; 29 | } 30 | 31 | /** 32 | * getInvalidPath is the affected directory path 33 | */ 34 | public function getInvalidPath(): string 35 | { 36 | return File::nicePath($this->invalidPath); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/CreateFileException.php: -------------------------------------------------------------------------------- 1 | invalidPath = $path; 25 | 26 | $this->message = "Error creating file [{$path}]. Please check write permissions."; 27 | 28 | return $this; 29 | } 30 | 31 | /** 32 | * getInvalidPath is the affected directory path 33 | */ 34 | public function getInvalidPath(): string 35 | { 36 | return File::nicePath($this->invalidPath); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/DeleteFileException.php: -------------------------------------------------------------------------------- 1 | invalidPath = $path; 25 | 26 | $this->message = "Error deleting file [{$path}]. Please check write permissions."; 27 | 28 | return $this; 29 | } 30 | 31 | /** 32 | * getInvalidPath is the affected directory path 33 | */ 34 | public function getInvalidPath(): string 35 | { 36 | return File::nicePath($this->invalidPath); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/FileExistsException.php: -------------------------------------------------------------------------------- 1 | invalidPath = $path; 25 | 26 | $this->message = "A file already exists at [{$path}]."; 27 | 28 | return $this; 29 | } 30 | 31 | /** 32 | * getInvalidPath is the affected directory path 33 | */ 34 | public function getInvalidPath(): string 35 | { 36 | return File::nicePath($this->invalidPath); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/InvalidDirectoryNameException.php: -------------------------------------------------------------------------------- 1 | invalidDirName = $invalidDirName; 24 | 25 | $this->message = "The specified directory name [{$invalidDirName}] is invalid."; 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * getInvalidDirectoryName gets the affected file name 32 | */ 33 | public function getInvalidDirectoryName(): string 34 | { 35 | return $this->invalidDirName; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/InvalidFileNameException.php: -------------------------------------------------------------------------------- 1 | invalidFileName = $invalidFileName; 24 | 25 | $this->message = "The specified file name [{$invalidFileName}] is invalid."; 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * getInvalidFileName gets the affected file name 32 | */ 33 | public function getInvalidFileName(): string 34 | { 35 | return $this->invalidFileName; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/MissingFileNameException.php: -------------------------------------------------------------------------------- 1 | model = $model; 24 | 25 | $this->message = "No file name attribute (fileName) specified for model [{$model}]."; 26 | 27 | return $this; 28 | } 29 | 30 | /** 31 | * getModel gets the affected Halcyon model 32 | */ 33 | public function getModel(): string 34 | { 35 | return $this->model; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Halcyon/Exception/ModelException.php: -------------------------------------------------------------------------------- 1 | model = $model; 25 | $this->errors = $model->errors(); 26 | $this->evalErrors(); 27 | } 28 | 29 | /** 30 | * getModel returns the model with invalid attributes 31 | */ 32 | public function getModel(): Model 33 | { 34 | return $this->model; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Halcyon/HalcyonServiceProvider.php: -------------------------------------------------------------------------------- 1 | app['halcyon']); 22 | 23 | Model::setEventDispatcher($this->app['events']); 24 | 25 | Model::setCacheManager($this->app['cache']); 26 | } 27 | 28 | /** 29 | * Register the service provider. 30 | * 31 | * @return void 32 | */ 33 | public function register() 34 | { 35 | Model::clearBootedModels(); 36 | 37 | Model::clearExtendedClasses(); 38 | 39 | Model::flushEventListeners(); 40 | 41 | $this->app->singleton('halcyon', function ($app) { 42 | return new Resolver; 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Halcyon/Migrations/2021_10_01_000001_Db_Templates.php: -------------------------------------------------------------------------------- 1 | increments('id'); 12 | $table->string('source')->index(); 13 | $table->string('path')->index(); 14 | $table->longText('content'); 15 | $table->integer('file_size')->unsigned(); 16 | $table->dateTime('updated_at')->nullable(); 17 | $table->dateTime('deleted_at')->nullable(); 18 | }); 19 | } 20 | 21 | public function down() 22 | { 23 | Schema::dropIfExists('templates'); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /src/Html/README.md: -------------------------------------------------------------------------------- 1 | ## Rain Html 2 | 3 | An extension of `illuminate\html` and more. 4 | 5 | ### HTML helpers 6 | 7 | These additional helpers are available in the `Helper` class. 8 | 9 | **nameToArray** 10 | 11 | Converts a HTML array string to a PHP array. Empty values are removed. 12 | 13 | ```php 14 | // Converts to PHP array ['user', 'location', 'city'] 15 | $array = Helper::nameToArray('user[location][city]'); 16 | ``` 17 | 18 | **strip** 19 | 20 | Removes HTML from a string. 21 | ```php 22 | // Outputs: Fatal Error! Oh noes! 23 | echo Html::strip('Fatal Error! Oh noes!'); 24 | ``` 25 | -------------------------------------------------------------------------------- /src/Mail/MailServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('mail.manager', function ($app) { 19 | // @deprecated use mailer.beforeResolve or callBeforeResolving 20 | $this->app['events']->dispatch('mailer.beforeRegister', [$this]); 21 | 22 | // Inheritance 23 | $manager = new MailManager($app); 24 | 25 | // @deprecated use mailer.resolve or callAfterResolving 26 | $this->app['events']->dispatch('mailer.register', [$this, $manager]); 27 | 28 | return $manager; 29 | }); 30 | 31 | $this->app->bind('mailer', function ($app) { 32 | return $app->make('mail.manager')->mailer(); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Parse/MarkdownData.php: -------------------------------------------------------------------------------- 1 | text = $text; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Parse/ParseServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('parse.markdown', function ($app) { 17 | return new Markdown; 18 | }); 19 | 20 | $this->app->singleton('parse.yaml', function ($app) { 21 | return new Yaml; 22 | }); 23 | 24 | $this->app->singleton('parse.twig', function ($app) { 25 | return new Twig; 26 | }); 27 | 28 | $this->app->singleton('parse.ini', function ($app) { 29 | return new Ini; 30 | }); 31 | } 32 | 33 | /** 34 | * provides the returned services. 35 | * @return array 36 | */ 37 | public function provides() 38 | { 39 | return [ 40 | 'parse.markdown', 41 | 'parse.yaml', 42 | 'parse.twig', 43 | 'parse.ini' 44 | ]; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Parse/Twig.php: -------------------------------------------------------------------------------- 1 | createTemplate($contents); 24 | return $template->render($vars); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Resize/ResizeBuilder.php: -------------------------------------------------------------------------------- 1 | app->singleton('resizer', function ($app) { 20 | return new ResizeBuilder; 21 | }); 22 | } 23 | 24 | /** 25 | * provides the returned services. 26 | * @return array 27 | */ 28 | public function provides() 29 | { 30 | return ['resizer']; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Router/README.md: -------------------------------------------------------------------------------- 1 | # URL Router 2 | 3 | URL route patterns follow an easy to read syntax and use in-place named parameters, so there is no need to use regular expressions in most cases. 4 | 5 | ## Creating a route 6 | 7 | You should prepare your route like so: 8 | 9 | ```php 10 | $router = new Router; 11 | 12 | // New route with ID: myRouteId 13 | $router->route('myRouteId', '/post/:id'); 14 | 15 | // New route with ID: anotherRouteId 16 | $router->route('anotherRouteId', '/profile/:username'); 17 | ``` 18 | 19 | ## Route matching 20 | 21 | Once you have prepared your route you can match it like this: 22 | 23 | ```php 24 | if ($router->match('/post/2')) { 25 | 26 | // Returns: [id => 2] 27 | $params = $router->getParameters(); 28 | 29 | // Returns: myRouteId 30 | $routeId = $router->matchedRoute(); 31 | } 32 | ``` 33 | 34 | ## Reverse matching 35 | 36 | You can also reverse match a route by it's identifier: 37 | 38 | ```php 39 | // Returns: /post/2 40 | $url = $router->url('myRouteId', ['id' => 2]); 41 | ``` -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateCommand.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the command. Eg: ProcessJobs} 16 | {--o|overwrite : Overwrite existing files with generated ones}'; 17 | 18 | /** 19 | * @var string description of the console command 20 | */ 21 | protected $description = 'Creates a new console command.'; 22 | 23 | /** 24 | * @var string type of class being generated 25 | */ 26 | protected $typeLabel = 'Command'; 27 | 28 | /** 29 | * makeStubs makes all stubs 30 | */ 31 | public function makeStubs() 32 | { 33 | $this->makeStub('command/command.stub', 'console/{{studly_name}}.php'); 34 | } 35 | 36 | /** 37 | * prepareVars prepares variables for stubs 38 | */ 39 | protected function prepareVars(): array 40 | { 41 | return [ 42 | 'name' => $this->argument('name'), 43 | 'namespace' => $this->argument('namespace'), 44 | ]; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateComponent.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the component. Eg: Posts} 16 | {--o|overwrite : Overwrite existing files with generated ones}'; 17 | 18 | /** 19 | * @var string name of console command 20 | */ 21 | protected $name = 'create:component'; 22 | 23 | /** 24 | * @var string description of the console command 25 | */ 26 | protected $description = 'Creates a new plugin component.'; 27 | 28 | /** 29 | * @var string type of class being generated 30 | */ 31 | protected $typeLabel = 'Component'; 32 | 33 | /** 34 | * makeStubs makes all stubs 35 | */ 36 | public function makeStubs() 37 | { 38 | $this->makeStub('component/component.stub', 'components/{{studly_name}}.php'); 39 | $this->makeStub('component/default.stub', 'components/{{lower_name}}/default.htm'); 40 | } 41 | 42 | /** 43 | * prepareVars prepares variables for stubs 44 | */ 45 | protected function prepareVars(): array 46 | { 47 | return [ 48 | 'name' => $this->argument('name'), 49 | 'namespace' => $this->argument('namespace'), 50 | ]; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateContentField.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the content field. Eg: IconPicker} 16 | {--o|overwrite : Overwrite existing files with generated ones}'; 17 | 18 | /** 19 | * @var string description of the console command 20 | */ 21 | protected $description = 'Creates a new content field.'; 22 | 23 | /** 24 | * @var string type of class being generated 25 | */ 26 | protected $typeLabel = 'Content Field'; 27 | 28 | /** 29 | * makeStubs makes all stubs 30 | */ 31 | public function makeStubs() 32 | { 33 | $this->makeStub('contentfield/contentfield.stub', 'contentfields/{{studly_name}}.php'); 34 | } 35 | 36 | /** 37 | * prepareVars prepares variables for stubs 38 | */ 39 | protected function prepareVars(): array 40 | { 41 | return [ 42 | 'name' => $this->argument('name'), 43 | 'namespace' => $this->argument('namespace'), 44 | ]; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateJob.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the job class to generate. (eg: ImportPosts)} 16 | {--s|sync : Indicates that job should be synchronous} 17 | {--o|overwrite : Overwrite existing files with generated ones}'; 18 | 19 | /** 20 | * @var string description of the console command 21 | */ 22 | protected $description = 'Creates a new job class.'; 23 | 24 | /** 25 | * @var string typeLabel of class being generated 26 | */ 27 | protected $typeLabel = 'Job'; 28 | 29 | /** 30 | * makeStubs makes all stubs 31 | */ 32 | public function makeStubs() 33 | { 34 | if ($this->option('sync')) { 35 | $this->makeStub('job/job.stub', 'jobs/{{studly_name}}.php'); 36 | } 37 | else { 38 | $this->makeStub('job/job.queued.stub', 'jobs/{{studly_name}}.php'); 39 | } 40 | } 41 | 42 | /** 43 | * prepareVars prepares variables for stubs 44 | */ 45 | protected function prepareVars(): array 46 | { 47 | return [ 48 | 'name' => $this->argument('name'), 49 | 'namespace' => $this->argument('namespace'), 50 | ]; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateReportWidget.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the report widget. Eg: TopPages} 16 | {--o|overwrite : Overwrite existing files with generated ones}'; 17 | 18 | /** 19 | * @var string description of the console command 20 | */ 21 | protected $description = 'Creates a new report widget.'; 22 | 23 | /** 24 | * @var string type of class being generated 25 | */ 26 | protected $typeLabel = 'Report Widget'; 27 | 28 | /** 29 | * makeStubs makes all stubs 30 | */ 31 | public function makeStubs() 32 | { 33 | $this->makeStub('reportwidget/reportwidget.stub', 'reportwidgets/{{studly_name}}.php'); 34 | $this->makeStub('reportwidget/widget.stub', 'reportwidgets/{{lower_name}}/partials/_{{lower_name}}.php'); 35 | } 36 | 37 | /** 38 | * prepareVars prepares variables for stubs 39 | */ 40 | protected function prepareVars(): array 41 | { 42 | return [ 43 | 'name' => $this->argument('name'), 44 | 'namespace' => $this->argument('namespace'), 45 | ]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Scaffold/Console/CreateSeeder.php: -------------------------------------------------------------------------------- 1 | (eg: Acme.Blog)} 15 | {name : The name of the job class to generate. (eg: PostSeeder)} 16 | {--o|overwrite : Overwrite existing files with generated ones}'; 17 | 18 | /** 19 | * @var string description of the console command 20 | */ 21 | protected $description = 'Creates a new seeder class.'; 22 | 23 | /** 24 | * @var string typeLabel of class being generated 25 | */ 26 | protected $typeLabel = 'Seeder'; 27 | 28 | /** 29 | * makeStubs makes all stubs 30 | */ 31 | public function makeStubs() 32 | { 33 | if ($this->isAppNamespace()) { 34 | $this->makeStub('seeder/create_app_seeder.stub', 'database/seeders/{{studly_name}}.php'); 35 | } else { 36 | $this->makeStub('seeder/create_seeder.stub', 'updates/seeders/{{studly_name}}.php'); 37 | } 38 | } 39 | 40 | /** 41 | * prepareVars prepares variables for stubs 42 | */ 43 | protected function prepareVars(): array 44 | { 45 | return [ 46 | 'name' => $this->argument('name'), 47 | 'namespace' => $this->argument('namespace'), 48 | ]; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Scaffold/Console/command/command.stub: -------------------------------------------------------------------------------- 1 | argument('user'); 28 | 29 | $this->output->writeln("Hello {$username}!"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Scaffold/Console/component/component.stub: -------------------------------------------------------------------------------- 1 | '{{title_name}} Component', 16 | 'description' => 'No description provided yet...' 17 | ]; 18 | } 19 | 20 | /** 21 | * @link https://docs.octobercms.com/3.x/element/inspector-types.html 22 | */ 23 | public function defineProperties() 24 | { 25 | return []; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Scaffold/Console/component/default.stub: -------------------------------------------------------------------------------- 1 |

This is the default markup for component {{name}}

2 | 3 | You can delete this file if you want 4 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/_list_toolbar.stub: -------------------------------------------------------------------------------- 1 |
2 | {% if design == 'popup' %} 3 | 11 | {% else %} 12 | 15 | 16 | '{{title_singular_name}}']) ?> 17 | 18 | {% endif %} 19 | 20 |
21 | 22 | 33 |
34 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/config_form.stub: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Behavior Config 3 | # =================================== 4 | 5 | # Record name 6 | name: {{title_singular_name}} 7 | 8 | # Model Form Field configuration 9 | form: {{namespace_local}}/models/{{lower_model}}/fields.yaml 10 | 11 | # Model Class name 12 | modelClass: {{namespace_php}}\Models\{{studly_model}} 13 | 14 | # Default redirect location 15 | defaultRedirect: {{namespace_path}}/{{lower_name}} 16 | 17 | {% if design %} 18 | # Form Design 19 | design: 20 | displayMode: {{design}} 21 | 22 | {% endif %} 23 | # Create page 24 | create: 25 | title: backend::lang.form.create_title 26 | redirect: {{namespace_path}}/{{lower_name}}/update/:id 27 | redirectClose: {{namespace_path}}/{{lower_name}} 28 | 29 | # Update page 30 | update: 31 | title: backend::lang.form.update_title 32 | redirect: {{namespace_path}}/{{lower_name}} 33 | redirectClose: {{namespace_path}}/{{lower_name}} 34 | 35 | # Preview page 36 | preview: 37 | title: backend::lang.form.preview_title 38 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/config_list.stub: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Behavior Config 3 | # =================================== 4 | 5 | # Model List Column configuration 6 | list: {{namespace_local}}/models/{{lower_model}}/columns.yaml 7 | 8 | # Model Class name 9 | modelClass: {{namespace_php}}\Models\{{studly_model}} 10 | 11 | # List Title 12 | title: Manage {{title_plural_name}} 13 | 14 | {% if design == 'popup' %} 15 | # Link each record to popup form design 16 | recordOnClick: popup 17 | {% else %} 18 | # Link URL for each record 19 | recordUrl: {{namespace_path}}/{{lower_name}}/update/:id 20 | {% endif %} 21 | 22 | # Message to display if the list is empty 23 | noRecordsMessage: backend::lang.list.no_records 24 | 25 | # Records to display per page 26 | recordsPerPage: 20 27 | 28 | # Display page numbers with pagination, disable to improve performance 29 | showPageNumbers: true 30 | 31 | # Displays the list column set up button 32 | showSetup: true 33 | 34 | # Displays the sorting link on each column 35 | showSorting: true 36 | 37 | # Default sorting column 38 | defaultSort: 39 | column: id 40 | direction: asc 41 | 42 | # Display checkboxes next to each record 43 | showCheckboxes: true 44 | 45 | # Toolbar widget configuration 46 | toolbar: 47 | # Partial for toolbar buttons 48 | buttons: list_toolbar 49 | 50 | # Search widget configuration 51 | search: 52 | prompt: backend::lang.list.search_prompt 53 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/controller.stub: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | formRenderDesign() ?> 9 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/index.stub: -------------------------------------------------------------------------------- 1 | 2 | listRender() ?> 3 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/preview.stub: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | fatalError): ?> 9 | 10 |
11 | formRenderPreview() ?> 12 |
13 | 14 | 15 | 16 |

fatalError) ?>

17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/preview_design.stub: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | formRenderDesign() ?> 9 | -------------------------------------------------------------------------------- /src/Scaffold/Console/controller/update_design.stub: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | formRenderDesign() ?> 9 | -------------------------------------------------------------------------------- /src/Scaffold/Console/factory/factory.stub: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function definition() 15 | { 16 | return [ 17 | // 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Scaffold/Console/factory/factory_app.stub: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function definition() 15 | { 16 | return [ 17 | // 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Scaffold/Console/filterwidget/javascript.stub: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a sample JavaScript file used by {{name}} 3 | * 4 | * You can delete this file if you want 5 | */ 6 | -------------------------------------------------------------------------------- /src/Scaffold/Console/filterwidget/partial.stub: -------------------------------------------------------------------------------- 1 | 6 | label)) ?> 7 | 8 | 1 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Scaffold/Console/filterwidget/partial_form.stub: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 8 |
9 |
10 |
11 | 14 |
15 | 18 |
19 |
20 | -------------------------------------------------------------------------------- /src/Scaffold/Console/filterwidget/stylesheet.stub: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a sample StyleSheet file used by {{name}} 3 | * 4 | * You can delete this file if you want 5 | */ 6 | -------------------------------------------------------------------------------- /src/Scaffold/Console/formwidget/formwidget.stub: -------------------------------------------------------------------------------- 1 | prepareVars(); 21 | return $this->makePartial('{{lower_name}}'); 22 | } 23 | 24 | public function prepareVars() 25 | { 26 | $this->vars['name'] = $this->formField->getName(); 27 | $this->vars['value'] = $this->getLoadValue(); 28 | $this->vars['model'] = $this->model; 29 | } 30 | 31 | public function loadAssets() 32 | { 33 | $this->addCss('css/{{lower_name}}.css'); 34 | $this->addJs('js/{{lower_name}}.js'); 35 | } 36 | 37 | public function getSaveValue($value) 38 | { 39 | return $value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Scaffold/Console/formwidget/javascript.stub: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a sample JavaScript file used by {{name}} 3 | * 4 | * You can delete this file if you want 5 | */ 6 | -------------------------------------------------------------------------------- /src/Scaffold/Console/formwidget/partial.stub: -------------------------------------------------------------------------------- 1 | previewMode): ?> 2 | 3 |
4 | 5 |
6 | 7 | 8 | 9 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Scaffold/Console/formwidget/stylesheet.stub: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a sample StyleSheet file used by {{name}} 3 | * 4 | * You can delete this file if you want 5 | */ 6 | -------------------------------------------------------------------------------- /src/Scaffold/Console/job/job.queued.stub: -------------------------------------------------------------------------------- 1 | id(); 20 | {% if timestamps %} 21 | $table->timestamps(); 22 | {% endif %}{% if softDeletes %} 23 | $table->softDeletes(); 24 | {% endif %} 25 | }); 26 | } 27 | 28 | /** 29 | * down reverses the migration 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('{{table}}'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /src/Scaffold/Console/migration/create_table.stub: -------------------------------------------------------------------------------- 1 | id(); 21 | {% if timestamps %} 22 | $table->timestamps(); 23 | {% endif %}{% if softDeletes %} 24 | $table->softDeletes(); 25 | {% endif %} 26 | }); 27 | } 28 | 29 | /** 30 | * down reverses the migration 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('{{table}}'); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /src/Scaffold/Console/migration/update_app_table.stub: -------------------------------------------------------------------------------- 1 | [ 19 | 'title' => 'Name', 20 | 'default' => '{{title_name}} Report Widget', 21 | 'type' => 'string', 22 | 'validation' => [ 23 | 'required' => [ 24 | 'message' => 'The Name field is required' 25 | ], 26 | 'regex' => [ 27 | 'message' => 'The Name field can contain only Latin letters.', 28 | 'pattern' => '^[a-zA-Z]+$' 29 | ] 30 | ] 31 | ], 32 | ]; 33 | } 34 | 35 | public function render() 36 | { 37 | try { 38 | $this->prepareVars(); 39 | } 40 | catch (Exception $ex) { 41 | $this->vars['error'] = $ex->getMessage(); 42 | } 43 | 44 | return $this->makePartial('{{lower_name}}'); 45 | } 46 | 47 | public function prepareVars() 48 | { 49 | } 50 | 51 | protected function loadAssets() 52 | { 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Scaffold/Console/reportwidget/widget.stub: -------------------------------------------------------------------------------- 1 |
2 |

property('title')) ?>

3 | 4 | 5 |

This is the default partial content.

6 | 7 |

8 | 9 |
10 | -------------------------------------------------------------------------------- /src/Scaffold/Console/seeder/create_app_seeder.stub: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests 15 | ./tests/browser 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Scaffold/Console/test/phpunit.plugin.stub: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests 15 | ./tests/browser 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Scaffold/Console/test/test.stub: -------------------------------------------------------------------------------- 1 | assertTrue(true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Support/Arr.php: -------------------------------------------------------------------------------- 1 | $value) { 22 | list($innerKey, $innerValue) = call_user_func($callback, $key, $value); 23 | 24 | $results[$innerKey] = $innerValue; 25 | } 26 | 27 | return $results; 28 | } 29 | 30 | /** 31 | * trans will translate an array, usually for dropdown and checkboxlist options 32 | */ 33 | public static function trans(array $arr): array 34 | { 35 | array_walk_recursive($arr, function(&$value, $key) { 36 | if (is_string($value)) { 37 | $value = Lang::get($value); 38 | } 39 | }); 40 | 41 | return $arr; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Support/Collection.php: -------------------------------------------------------------------------------- 1 | pluck($value, $key)->all(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Support/Debug/HtmlDumper.php: -------------------------------------------------------------------------------- 1 | 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000', 15 | 'num' => 'color:#a71d5d', 16 | 'const' => 'color:#795da3', 17 | 'str' => 'color:#df5000', 18 | 'cchr' => 'color:#222', 19 | 'note' => 'color:#a71d5d', 20 | 'ref' => 'color:#a0a0a0', 21 | 'public' => 'color:#795da3', 22 | 'protected' => 'color:#795da3', 23 | 'private' => 'color:#795da3', 24 | 'meta' => 'color:#b729d9', 25 | 'key' => 'color:#df5000', 26 | 'index' => 'color:#a71d5d', 27 | ]; 28 | } 29 | -------------------------------------------------------------------------------- /src/Support/Facades/Auth.php: -------------------------------------------------------------------------------- 1 | input($key, $default); 23 | } 24 | 25 | /** 26 | * getFacadeAccessor returns the registered name of the component 27 | * @return string 28 | */ 29 | protected static function getFacadeAccessor() 30 | { 31 | return 'request'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Support/Facades/Mail.php: -------------------------------------------------------------------------------- 1 | app->beforeResolving($name, $callback); 29 | 30 | if ($this->app->resolved($name)) { 31 | $callback($this->app->make($name), $this->app); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Support/Traits/Singleton.php: -------------------------------------------------------------------------------- 1 | init(); 41 | } 42 | 43 | /** 44 | * init the singleton free from constructor parameters 45 | */ 46 | protected function init() 47 | { 48 | } 49 | 50 | /** 51 | * __clone 52 | * @ignore 53 | */ 54 | public function __clone() 55 | { 56 | trigger_error('Cloning '.__CLASS__.' is not allowed.', E_USER_ERROR); 57 | } 58 | 59 | /** 60 | * __wakeup 61 | * @ignore 62 | */ 63 | public function __wakeup() 64 | { 65 | trigger_error('Unserializing '.__CLASS__.' is not allowed.', E_USER_ERROR); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Translation/FileLoader.php: -------------------------------------------------------------------------------- 1 | = 10 17 | */ 18 | protected $path; 19 | 20 | /** 21 | * @var array paths are used by default for the loader. 22 | * 23 | * @todo Can be removed if Laravel >= 10 24 | */ 25 | protected $paths; 26 | 27 | /** 28 | * loadNamespaceOverrides loads a local namespaced translation group for overrides 29 | */ 30 | protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace) 31 | { 32 | $paths = (array) $this->path ?: $this->paths; 33 | 34 | return collect($paths) 35 | ->reduce(function ($output, $path) use ($lines, $locale, $group, $namespace) { 36 | $namespace = str_replace('.', '/', $namespace); 37 | $file = "{$path}/{$namespace}/{$locale}/{$group}.php"; 38 | 39 | if ($this->files->exists($file)) { 40 | return array_replace_recursive($lines, $this->files->getRequire($file)); 41 | } 42 | 43 | return $lines; 44 | }, []); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Translation/README.md: -------------------------------------------------------------------------------- 1 | # Translation 2 | 3 | An extension of illuminate\translation. 4 | 5 | Modules and plugins can have localization files in the /lang directory. Plugin and module localization files are registered automatically. 6 | 7 | ## Accessing localization strings 8 | 9 | ```php 10 | // Get a localization string from the CMS module 11 | echo Lang::get('cms::errors.page.not_found'); 12 | 13 | // Get a localization string from the october/blog plugin. 14 | echo Lang::get('october.blog::messages.post.added'); 15 | ``` 16 | 17 | ## Overriding localization strings 18 | 19 | System users can override localization strings without altering the modules' and plugins' files. This is done by adding localization files to the app/lang directory. To override a plugin's localization: 20 | 21 | ``` 22 | app 23 | lang 24 | en 25 | vendorname 26 | pluginname 27 | file.php 28 | ``` 29 | 30 | Example: lang/en/october/blog/errors.php 31 | 32 | To override a module's localization: 33 | 34 | ``` 35 | app 36 | lang 37 | en 38 | modulename 39 | file.php 40 | ``` 41 | 42 | Example: lang/en/cms/errors.php 43 | -------------------------------------------------------------------------------- /src/Validation/Factory.php: -------------------------------------------------------------------------------- 1 | resolver)) { 16 | return new Validator($this->translator, $data, $rules, $messages, $customAttributes); 17 | } 18 | 19 | return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Validation/ValidationServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('validator', function ($app) { 17 | $validator = new Factory($app['translator'], $app); 18 | 19 | if (isset($app['db'], $app['validation.presence'])) { 20 | $validator->setPresenceVerifier($app['validation.presence']); 21 | } 22 | 23 | // Replacers for custom rules in Validator class 24 | $validator->replacer('unique_site', function ($message, $attribute, $rule, $parameters) { 25 | return __('validation.unique', ['attribute' => $attribute]); 26 | }); 27 | 28 | return $validator; 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Benchmark/GeneralBench.php: -------------------------------------------------------------------------------- 1 | parse('**Hello**'); 24 | } 25 | 26 | /** 27 | * @Subject 28 | */ 29 | public function benchB() 30 | { 31 | \Str::markdown('**Hello**'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Database/ModelAddersTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(['id' => 'int'], $model->getCasts()); 10 | 11 | $model->addCasts(['foo' => 'int']); 12 | 13 | $this->assertEquals(['id' => 'int', 'foo' => 'int'], $model->getCasts()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/Database/SortableTest.php: -------------------------------------------------------------------------------- 1 | addConnection([ 9 | 'driver' => 'sqlite', 10 | 'database' => ':memory:', 11 | 'prefix' => '' 12 | ]); 13 | $capsule->setAsGlobal(); 14 | $capsule->bootEloquent(); 15 | } 16 | 17 | public function testOrderByIsAutomaticallyAdded() 18 | { 19 | $model = new TestModel; 20 | $query = $model->newQuery()->toSql(); 21 | 22 | $this->assertEquals('select * from "test" order by "test"."sort_order" asc', $query); 23 | } 24 | 25 | public function testOrderByCanBeOverridden() 26 | { 27 | $model = new TestModel; 28 | $query1 = $model->newQuery()->orderBy('name')->orderBy('email', 'desc')->toSql(); 29 | $query2 = $model->newQuery()->orderBy('sort_order')->orderBy('name')->toSql(); 30 | 31 | $this->assertEquals('select * from "test" order by "name" asc, "email" desc', $query1); 32 | $this->assertEquals('select * from "test" order by "sort_order" asc, "name" asc', $query2); 33 | } 34 | } 35 | 36 | class TestModel extends \October\Rain\Database\Model 37 | { 38 | use \October\Rain\Database\Traits\Sortable; 39 | 40 | protected $table = 'test'; 41 | } 42 | -------------------------------------------------------------------------------- /tests/Database/UpdaterTest.php: -------------------------------------------------------------------------------- 1 | updater = new Updater(); 12 | } 13 | 14 | public function testClassNameGetsParsedCorrectly() 15 | { 16 | $reflector = new ReflectionClass(TestPlugin\SampleClass::class); 17 | $filePath = $reflector->getFileName(); 18 | 19 | $classFullName = $this->updater->getClassFromFile($filePath); 20 | 21 | $this->assertEquals(TestPlugin\SampleClass::class, $classFullName); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/Events/EventDispatcherTest.php: -------------------------------------------------------------------------------- 1 | setLaravelDispatcher(new Dispatcher); 20 | 21 | Event::swap(new FakeDispatcher($dispatcher)); 22 | 23 | Event::fire(EventDispatcherTest::class); 24 | 25 | Event::assertDispatched(EventDispatcherTest::class); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/Extension/ExtensionTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('foo', $subject->behaviorAttribute); 12 | 13 | ExtensionTestExampleBehaviorClass1::extend(function ($extension) { 14 | $extension->behaviorAttribute = 'bar'; 15 | }); 16 | 17 | $subject = new ExtensionTestExampleExtendableClass; 18 | $this->assertEquals('bar', $subject->behaviorAttribute); 19 | } 20 | } 21 | 22 | /* 23 | * Example class that has extensions enabled 24 | */ 25 | class ExtensionTestExampleExtendableClass extends Extendable 26 | { 27 | public $implement = ['ExtensionTestExampleBehaviorClass1']; 28 | } 29 | 30 | /** 31 | * Example behavior classes 32 | */ 33 | class ExtensionTestExampleBehaviorClass1 extends ExtensionBase 34 | { 35 | public $behaviorAttribute = 'foo'; 36 | } 37 | -------------------------------------------------------------------------------- /tests/Halcyon/DatasourceResolverTest.php: -------------------------------------------------------------------------------- 1 | $theme1, 17 | 'theme2' => $theme2, 18 | 'theme3' => $theme3 19 | ]); 20 | 21 | $this->assertTrue($resolver->hasDatasource('theme1')); 22 | $this->assertTrue($resolver->hasDatasource('theme2')); 23 | $this->assertTrue($resolver->hasDatasource('theme3')); 24 | $this->assertFalse($resolver->hasDatasource('theme4')); 25 | } 26 | 27 | public function testDefaultDatasource() 28 | { 29 | $resolver = new Resolver; 30 | $resolver->setDefaultDatasource('theme1'); 31 | $this->assertEquals('theme1', $resolver->getDefaultDatasource()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Halcyon/ValidationTraitTest.php: -------------------------------------------------------------------------------- 1 | getMockForTrait('October\Rain\Halcyon\Traits\Validation'); 8 | 9 | $rules = [ 10 | 'field' => 'required', 11 | 'field.two' => 'required|boolean', 12 | 'field[three]' => 'required|date', 13 | 'field[three][child]' => 'required', 14 | 'field[four][][name]' => 'required', 15 | 'field[five' => 'required|string', 16 | 'field][six' => 'required|string', 17 | 'field]seven' => 'required|string', 18 | ]; 19 | $rules = self::callProtectedMethod($mock, 'processRuleFieldNames', [$rules]); 20 | 21 | $this->assertEquals([ 22 | 'field' => 'required', 23 | 'field.two' => 'required|boolean', 24 | 'field.three' => 'required|date', 25 | 'field.three.child' => 'required', 26 | 'field.four.*.name' => 'required', 27 | 'field[five' => 'required|string', 28 | 'field][six' => 'required|string', 29 | 'field]seven' => 'required|string', 30 | ], $rules); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Support/CountableTest.php: -------------------------------------------------------------------------------- 1 | 'bar', 8 | 'foo2' => 'bar2' 9 | ]; 10 | 11 | $this->assertTrue(is_countable($array)); 12 | 13 | $collection = collect([ 14 | 'foo' => 'bar', 15 | 'foo2' => 'bar2' 16 | ]); 17 | 18 | $this->assertTrue(is_countable($collection)); 19 | 20 | $arrayObj = new ArrayObject([ 21 | 'foo' => 'bar', 22 | 'foo2' => 'bar2' 23 | ]); 24 | 25 | $this->assertTrue(is_countable($arrayObj)); 26 | 27 | $string = 'Test string'; 28 | 29 | $this->assertFalse(is_countable($string)); 30 | 31 | $int = 5; 32 | 33 | $this->assertFalse(is_countable($int)); 34 | 35 | $emptyArray = []; 36 | 37 | $this->assertTrue(is_countable($emptyArray)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Translation/TranslatorTest.php: -------------------------------------------------------------------------------- 1 | translator = $translator; 22 | } 23 | 24 | public function testSimilarWordsParsing() 25 | { 26 | $this->assertEquals( 27 | 'Displayed records: 1-100 of 10', 28 | $this->translator->get('lang.test.pagination', ['from' => 1, 'to' => 100, 'total' => 10]) 29 | ); 30 | } 31 | 32 | public function testOverrideWithSet() 33 | { 34 | $this->assertEquals('lang.test.hello_override', $this->translator->get('lang.test.hello_override')); 35 | $this->translator->set('lang.test.hello_override', 'Hello Override!'); 36 | $this->assertEquals('Hello Override!', $this->translator->get('lang.test.hello_override')); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/fixtures/database/SampleClass.php: -------------------------------------------------------------------------------- 1 | sampleClass = Arr::class; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/models/Content.php: -------------------------------------------------------------------------------- 1 | 'The :attribute field is required.' 38 | ]; 39 | 40 | public $attributeNames = [ 41 | 'title' => 'title', 42 | 'viewBag.meta_title' => 'meta title' 43 | ]; 44 | 45 | public $rules = [ 46 | 'title' => 'required', 47 | 'viewBag.meta_title' => 'required' 48 | ]; 49 | } 50 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/content/welcome.htm: -------------------------------------------------------------------------------- 1 |

Hi friend

-------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/menus/mainmenu.htm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/pages/about.htm: -------------------------------------------------------------------------------- 1 | title = "About" 2 | == 3 |

Us

4 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/pages/home.htm: -------------------------------------------------------------------------------- 1 | title = "hello" 2 | == 3 | 6 | == 7 |

World!

8 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/pages/level1/level2/level3/level4/level5/contact.htm: -------------------------------------------------------------------------------- 1 | title = "Contact" 2 | == 3 |

Us

4 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/pages/level1/level2/level3/level4/level5/level6/unknown.htm: -------------------------------------------------------------------------------- 1 | title = "Unknown" 2 | == 3 |

Page

4 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme1/pages/level1/team.htm: -------------------------------------------------------------------------------- 1 | title = "Team" 2 | == 3 |

Join Us

4 | -------------------------------------------------------------------------------- /tests/fixtures/halcyon/themes/theme2/pages/home.htm: -------------------------------------------------------------------------------- 1 | title = "Cold" 2 | == 3 |

Chisel

-------------------------------------------------------------------------------- /tests/fixtures/lang/en/lang.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'pagination' => 'Displayed records: :from-:to of :total', 6 | 'hello_october' => 'Hello October!' 7 | ], 8 | ]; 9 | -------------------------------------------------------------------------------- /tests/fixtures/parse/array.ini: -------------------------------------------------------------------------------- 1 | [products] 2 | excludeStatuses[] = 1 3 | excludeStatuses[] = 42 4 | excludeStatuses[] = 69 -------------------------------------------------------------------------------- /tests/fixtures/parse/basic.ini: -------------------------------------------------------------------------------- 1 | title = "Plugin components" 2 | url = "/demo/plugins" 3 | layout = "default" 4 | 5 | [demoTodo] 6 | min = 1.2 7 | max = 3 -------------------------------------------------------------------------------- /tests/fixtures/parse/comments-clean.ini: -------------------------------------------------------------------------------- 1 | [owner] 2 | name = "John Doe" 3 | organization = "Acme Widgets Inc." 4 | 5 | [database] 6 | server = "192.0.2.62" 7 | port = 143 8 | file = "payroll.dat" -------------------------------------------------------------------------------- /tests/fixtures/parse/comments.ini: -------------------------------------------------------------------------------- 1 | ; last modified 1 April 2001 by John Doe 2 | [owner] 3 | name=John Doe 4 | ; name=Adam Person 5 | organization=Acme Widgets Inc. 6 | 7 | [database] 8 | ; use IP address in case network name resolution is not working 9 | server=192.0.2.62 10 | ; server=127.0.0.1 11 | port=143 12 | file="payroll.dat" -------------------------------------------------------------------------------- /tests/fixtures/parse/multilines-value.ini: -------------------------------------------------------------------------------- 1 | var = "\Test\Path\" 2 | editorContent = "

Some 3 |
\"Multi-line\""" 4 |
text 5 |

" -------------------------------------------------------------------------------- /tests/fixtures/parse/object.ini: -------------------------------------------------------------------------------- 1 | [viewBag] 2 | code = "signin-snippet" 3 | name = "Sign in snippet" 4 | properties[type] = "string" 5 | properties[title] = "Redirection page" 6 | properties[default] = "/clients" -------------------------------------------------------------------------------- /tests/fixtures/parse/sections.ini: -------------------------------------------------------------------------------- 1 | var1 = "value 1" 2 | var2 = "value 21" 3 | 4 | [section] 5 | sectionVar1 = "section value 1" 6 | sectionVar2 = "section value 2" 7 | 8 | [section data] 9 | sectionVar3 = "section value 3" 10 | sectionVar4 = "section value 4" 11 | 12 | [emptysection] -------------------------------------------------------------------------------- /tests/fixtures/parse/simple.ini: -------------------------------------------------------------------------------- 1 | var1 = "value 1" 2 | var2 = "value 21" -------------------------------------------------------------------------------- /tests/fixtures/parse/subsections.ini: -------------------------------------------------------------------------------- 1 | var1 = "value 1" 2 | var2 = "value 21" 3 | 4 | [section] 5 | sectionVar1 = "section value 1" 6 | sectionVar2 = "section value 2" 7 | subsection[] = "subsection value 1" 8 | subsection[] = "subsection value 2" 9 | sectionVar3 = "section value 3" 10 | 11 | [section data] 12 | sectionVar3 = "section value 3" 13 | sectionVar4 = "section value 4" 14 | subsection[] = "subsection value 1" 15 | subsection[] = "subsection value 2" -------------------------------------------------------------------------------- /tests/phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./ 16 | 17 | 18 | --------------------------------------------------------------------------------