diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fa293f..607053e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Release Notes for Spacing +## 0.7.1 +- Setup a `{{ craft.spacing.config }}` to globally access config values in Twig templates + ## 0.7.0 - Initial release diff --git a/composer.json b/composer.json index 8e22e40..0fad937 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "trendyminds/craft-spacing", "description": "A utility field to insert spacing between your Matrix blocks", "type": "craft-plugin", - "version": "0.7.0", + "version": "0.7.1", "license": "mit", "support": { "email": "dev@trendyminds.com", @@ -37,5 +37,8 @@ "yiisoft/yii2-composer": true, "craftcms/plugin-installer": true } + }, + "require-dev": { + "laravel/pint": "^1.5" } } diff --git a/composer.lock b/composer.lock index c7c416c..088d648 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "48a04acc3b96391b266c932861e4eaf5", + "content-hash": "5e45f25692032b2fc221bddc599a57a5", "packages": [ { "name": "cebe/markdown", @@ -6076,7 +6076,74 @@ "time": "2021-12-30T08:48:48+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "laravel/pint", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/pint.git", + "reference": "e0a8cef58b74662f27355be9cdea0e726bbac362" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/pint/zipball/e0a8cef58b74662f27355be9cdea0e726bbac362", + "reference": "e0a8cef58b74662f27355be9cdea0e726bbac362", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.14.4", + "illuminate/view": "^9.51.0", + "laravel-zero/framework": "^9.2.0", + "mockery/mockery": "^1.5.1", + "nunomaduro/larastan": "^2.4.0", + "nunomaduro/termwind": "^1.15.1", + "pestphp/pest": "^1.22.4" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2023-02-14T16:31:02+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/src/Spacing.php b/src/Spacing.php index 9ab7169..7772e50 100644 --- a/src/Spacing.php +++ b/src/Spacing.php @@ -7,9 +7,11 @@ use craft\events\RegisterComponentTypesEvent; use craft\helpers\Json; use craft\services\Fields; +use craft\web\twig\variables\CraftVariable; use Exception; use Illuminate\Support\Collection; use trendyminds\spacing\fields\Field; +use trendyminds\spacing\variables\Variable; use yii\base\Event; /** @@ -42,6 +44,16 @@ function (RegisterComponentTypesEvent $event) { $event->types[] = Field::class; } ); + + Event::on( + CraftVariable::class, + CraftVariable::EVENT_INIT, + function (Event $event) { + /** @var CraftVariable $variable */ + $variable = $event->sender; + $variable->set('spacing', Variable::class); + } + ); } public static function options(): Collection diff --git a/src/variables/Variable.php b/src/variables/Variable.php new file mode 100644 index 0000000..c6c252d --- /dev/null +++ b/src/variables/Variable.php @@ -0,0 +1,14 @@ +