Skip to content

Commit

Permalink
Merge branch 'release/1.2.13' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Feb 11, 2024
2 parents b95d69e + e923eb0 commit 21b376d
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Example .gitignore file for Craft CMS projects
#
# @author nystudio107
# @copyright Copyright (c) 2017 nystudio107
# @copyright Copyright (c) nystudio107
# @link https://nystudio107.com/
# @package craft-scripts
# @since 1.1.0
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Minify Changelog

## 1.2.13 - 2024.02.10
### Added
* Added `ServicesTrait` for the plugin service component registration

## 1.2.12 - 2024.02.09
### Added
* Add `phpstan` and `ecs` code linting
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-minify",
"description": "A simple plugin that allows you to minify blocks of HTML, CSS, and JS inline in Craft CMS templates.",
"type": "craft-plugin",
"version": "1.2.12",
"version": "1.2.13",
"keywords": [
"craft",
"cms",
Expand Down Expand Up @@ -55,9 +55,6 @@
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft-minify/v1/CHANGELOG.md",
"class": "nystudio107\\minify\\Minify",
"components": {
"minify": "nystudio107\\minify\\services\\MinifyService"
}
"class": "nystudio107\\minify\\Minify"
}
}
10 changes: 7 additions & 3 deletions src/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

Expand All @@ -12,7 +12,7 @@
use Craft;
use craft\base\Plugin;
use nystudio107\minify\models\Settings;
use nystudio107\minify\services\MinifyService;
use nystudio107\minify\services\ServicesTrait;
use nystudio107\minify\twigextensions\MinifyTwigExtension;

/**
Expand All @@ -22,11 +22,15 @@
* @package Minify
* @since 1.2.0
*
* @property MinifyService $minify
* @method Settings getSettings()
*/
class Minify extends Plugin
{
// Traits
// =========================================================================

use ServicesTrait;

/**
* @var Minify
*/
Expand Down
2 changes: 1 addition & 1 deletion src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

Expand Down
4 changes: 1 addition & 3 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

namespace nystudio107\minify\models;

use craft\base\Model;

use nystudio107\minify\Minify;

/**
* Minify Settings model
*
Expand Down
14 changes: 8 additions & 6 deletions src/services/MinifyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

namespace nystudio107\minify\services;

use Craft;

use craft\base\Component;
use JSMin\JSMin;
use Minify_CSSmin;
use Minify_HTML;
use nystudio107\minify\Minify;

/**
Expand Down Expand Up @@ -54,7 +56,7 @@ public function minify($htmlText = "")
'cssMinifier' => '\Minify_CSSmin::minify',
'jsMinifier' => '\JSMin\JSMin::minify',
];
$htmlText = \Minify_HTML::minify($htmlText, $options);
$htmlText = Minify_HTML::minify($htmlText, $options);
}

return $htmlText;
Expand All @@ -70,7 +72,7 @@ public function minify($htmlText = "")
public function htmlMin($htmlText = "")
{
if ($this->shouldMinify) {
$htmlText = \Minify_HTML::minify($htmlText);
$htmlText = Minify_HTML::minify($htmlText);
}

return $htmlText;
Expand All @@ -86,7 +88,7 @@ public function htmlMin($htmlText = "")
public function cssMin($cssText = "")
{
if ($this->shouldMinify) {
$cssText = \Minify_CSSmin::minify($cssText);
$cssText = Minify_CSSmin::minify($cssText);
}

return $cssText;
Expand All @@ -102,7 +104,7 @@ public function cssMin($cssText = "")
public function jsMin($jsText = "")
{
if ($this->shouldMinify) {
$jsText = \JSMin\JSMin::minify($jsText);
$jsText = JSMin::minify($jsText);
}

return $jsText;
Expand Down
53 changes: 53 additions & 0 deletions src/services/ServicesTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

namespace nystudio107\minify\services;

use craft\helpers\ArrayHelper;
use yii\base\InvalidConfigException;

/**
* @author nystudio107
* @package Minify
* @since 1.2.13
*
* @property MinifyService $minify
*/
trait ServicesTrait
{
// Public Methods
// =========================================================================

/**
* @inheritdoc
*/
public function __construct($id, $parent = null, array $config = [])
{
// Merge in the passed config, so it our config can be overridden by Plugins::pluginConfigs['vite']
// ref: https://github.com/craftcms/cms/issues/1989
$config = ArrayHelper::merge([
'components' => [
'minify' => MinifyService::class,
],
], $config);

parent::__construct($id, $parent, $config);
}

/**
* Returns the helper service
*
* @return MinifyService The minify service
* @throws InvalidConfigException
*/
public function getMinify(): MinifyService
{
return $this->get('minify');
}
}
2 changes: 1 addition & 1 deletion src/translations/en/minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/twigextensions/MinifyNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion src/twigextensions/MinifyTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

Expand Down
6 changes: 4 additions & 2 deletions src/twigextensions/MinifyTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
* Minify plugin for Craft CMS 3.x
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2017 nystudio107
* @copyright Copyright (c) nystudio107
* @license MIT License https://opensource.org/licenses/MIT
*/

namespace nystudio107\minify\twigextensions;

use Twig_Extension;

/**
* Minify twig extension
*
* @author nystudio107
* @package Minify
* @since 1.2.0
*/
class MinifyTwigExtension extends \Twig_Extension
class MinifyTwigExtension extends Twig_Extension
{
// Public Methods
// =========================================================================
Expand Down

0 comments on commit 21b376d

Please sign in to comment.