Skip to content

Commit f90d045

Browse files
committed
Use services etc
1 parent 35c48d3 commit f90d045

File tree

12 files changed

+261
-252
lines changed

12 files changed

+261
-252
lines changed

.craftplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"pluginName":"imgixurl","pluginDescription":"Build imgix urls from assets, including secure images.","pluginVersion":"2.0.0","pluginAuthorName":"sprokets","pluginVendorName":"sprokets","pluginAuthorUrl":"https://sprokets.net","pluginAuthorGithub":"craft-imgixurl","codeComments":"yes","pluginComponents":["settings","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
1+
{"pluginName":"Imgix Url","pluginDescription":"Imgix Url","pluginVersion":"3.0.0","pluginAuthorName":"sprokets","pluginVendorName":"sprokets","pluginAuthorUrl":"https://www.sprokets.com","pluginAuthorGithub":"sprokets/craft-imgixurl","codeComments":"yes","pluginComponents":["services","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# imgixurl Changelog
1+
# Imgix Url Changelog
22

33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## 2.0.0 - 2018-02-14
7+
## 3.0.0 - 2019-03-29
88
### Added
99
- Initial release

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 sprokets
3+
Copyright (c) 2019 sprokets
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# imgixurl plugin for Craft CMS 3.x
1+
# Imgix Url plugin for Craft CMS 3.x
22

3-
Build imgix urls from assets, including secure images.
3+
Imgix Url
44

55
![Screenshot](resources/img/plugin-logo.png)
66

@@ -18,26 +18,26 @@ To install the plugin, follow these instructions.
1818

1919
2. Then tell Composer to load the plugin:
2020

21-
composer require craft-imgixurl/imgixurl
21+
composer require sprokets/craft-imgixurl/imgix-url
2222

23-
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for imgixurl.
23+
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Imgix Url.
2424

25-
## imgixurl Overview
25+
## Imgix Url Overview
2626

2727
-Insert text here-
2828

29-
## Configuring imgixurl
29+
## Configuring Imgix Url
3030

3131
-Insert text here-
3232

33-
## Using imgixurl
33+
## Using Imgix Url
3434

3535
-Insert text here-
3636

37-
## imgixurl Roadmap
37+
## Imgix Url Roadmap
3838

3939
Some things to do, and ideas for potential features:
4040

4141
* Release it
4242

43-
Brought to you by [sprokets](https://sprokets.net)
43+
Brought to you by [sprokets](https://www.sprokets.com)

composer.json

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
{
2-
"name": "sprokets/imgixurl",
3-
"description": "Build imgix urls from assets, including secure images.",
4-
"type": "craft-plugin",
5-
"version": "2.0.4",
6-
"keywords": [
7-
"craft",
8-
"cms",
9-
"craftcms",
10-
"craft-plugin",
11-
"imgixurl"
12-
],
13-
"support": {
14-
"docs": "https://github.com/craft-imgixurl/imgixurl/blob/master/README.md",
15-
"issues": "https://github.com/craft-imgixurl/imgixurl/issues"
16-
},
17-
"license": "MIT",
18-
"authors": [
19-
{
20-
"name": "sprokets",
21-
"homepage": "https://sprokets.net"
2+
"name": "sprokets/imgix-url",
3+
"description": "Imgix Url",
4+
"type": "craft-plugin",
5+
"version": "3.0.0",
6+
"keywords": [
7+
"craft",
8+
"cms",
9+
"craftcms",
10+
"craft-plugin",
11+
"imgix url"
12+
],
13+
"support": {
14+
"docs": "https://github.com/sprokets/craft-imgixurl/imgix-url/blob/master/README.md",
15+
"issues": "https://github.com/sprokets/craft-imgixurl/imgix-url/issues"
16+
},
17+
"license": "MIT",
18+
"authors": [
19+
{
20+
"name": "sprokets",
21+
"homepage": "https://www.sprokets.com"
22+
}
23+
],
24+
"require": {
25+
"craftcms/cms": "^3.0.0-RC1"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"sprokets\\imgixurl\\": "src/"
30+
}
31+
},
32+
"extra": {
33+
"name": "Imgix Url",
34+
"handle": "imgix-url",
35+
"hasCpSettings": false,
36+
"hasCpSection": false,
37+
"changelogUrl": "https://raw.githubusercontent.com/sprokets/craft-imgixurl/imgix-url/master/CHANGELOG.md",
38+
"components": {
39+
"imgixUrlService": "sprokets\\imgixurl\\services\\ImgixUrlService"
40+
},
41+
"class": "sprokets\\imgixurl\\ImgixUrl"
2242
}
23-
],
24-
"require": {
25-
"craftcms/cms": "^3.0.0-RC1"
26-
},
27-
"autoload": {
28-
"psr-4": {
29-
"sprokets\\imgixurl\\": "src/"
30-
}
31-
},
32-
"extra": {
33-
"name": "imgixurl",
34-
"handle": "imgixurl",
35-
"hasCpSettings": true,
36-
"hasCpSection": false,
37-
"changelogUrl": "https://raw.githubusercontent.com/craft-imgixurl/imgixurl/master/CHANGELOG.md",
38-
"class": "sprokets\\imgixurl\\Imgixurl"
39-
}
4043
}

src/Imgixurl.php

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22
/**
3-
* imgixurl plugin for Craft CMS 3.x
3+
* Imgix Url plugin for Craft CMS 3.x
44
*
5-
* Build imgix urls from assets, including secure images.
5+
* Imgix Url
66
*
7-
* @link https://sprokets.net
8-
* @copyright Copyright (c) 2018 sprokets
7+
* @link https://www.sprokets.com
8+
* @copyright Copyright (c) 2019 sprokets
99
*/
1010

1111
namespace sprokets\imgixurl;
1212

13-
use sprokets\imgixurl\variables\ImgixurlVariable;
14-
use sprokets\imgixurl\models\Settings;
13+
use sprokets\imgixurl\services\ImgixUrlService as ImgixUrlServiceService;
14+
use sprokets\imgixurl\variables\ImgixUrlVariable;
1515

1616
use Craft;
1717
use craft\base\Plugin;
@@ -32,22 +32,21 @@
3232
* https://craftcms.com/docs/plugins/introduction
3333
*
3434
* @author sprokets
35-
* @package Imgixurl
36-
* @since 2.0.0
35+
* @package ImgixUrl
36+
* @since 3.0.0
3737
*
38-
* @property Settings $settings
39-
* @method Settings getSettings()
38+
* @property ImgixUrlServiceService $imgixUrlService
4039
*/
41-
class Imgixurl extends Plugin
40+
class ImgixUrl extends Plugin
4241
{
4342
// Static Properties
4443
// =========================================================================
4544

4645
/**
4746
* Static property that is an instance of this plugin class so that it can be accessed via
48-
* Imgixurl::$plugin
47+
* ImgixUrl::$plugin
4948
*
50-
* @var Imgixurl
49+
* @var ImgixUrl
5150
*/
5251
public static $plugin;
5352

@@ -59,14 +58,14 @@ class Imgixurl extends Plugin
5958
*
6059
* @var string
6160
*/
62-
public $schemaVersion = '2.0.0';
61+
public $schemaVersion = '3.0.0';
6362

6463
// Public Methods
6564
// =========================================================================
6665

6766
/**
6867
* Set our $plugin static property to this class so that it can be accessed via
69-
* Imgixurl::$plugin
68+
* ImgixUrl::$plugin
7069
*
7170
* Called after the plugin class is instantiated; do any one-time initialization
7271
* here such as hooks and events.
@@ -87,25 +86,50 @@ public function init()
8786
function (Event $event) {
8887
/** @var CraftVariable $variable */
8988
$variable = $event->sender;
90-
$variable->set('imgixurl', ImgixurlVariable::class);
89+
$variable->set('imgixUrl', ImgixUrlVariable::class);
9190
}
9291
);
9392

93+
// Do something after we're installed
94+
Event::on(
95+
Plugins::class,
96+
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
97+
function (PluginEvent $event) {
98+
if ($event->plugin === $this) {
99+
// We were just installed
100+
}
101+
}
102+
);
94103

104+
/**
105+
* Logging in Craft involves using one of the following methods:
106+
*
107+
* Craft::trace(): record a message to trace how a piece of code runs. This is mainly for development use.
108+
* Craft::info(): record a message that conveys some useful information.
109+
* Craft::warning(): record a warning message that indicates something unexpected has happened.
110+
* Craft::error(): record a fatal error that should be investigated as soon as possible.
111+
*
112+
* Unless `devMode` is on, only Craft::warning() & Craft::error() will log to `craft/storage/logs/web.log`
113+
*
114+
* It's recommended that you pass in the magic constant `__METHOD__` as the second parameter, which sets
115+
* the category to the method (prefixed with the fully qualified class name) where the constant appears.
116+
*
117+
* To enable the Yii debug toolbar, go to your user account in the AdminCP and check the
118+
* [] Show the debug toolbar on the front end & [] Show the debug toolbar on the Control Panel
119+
*
120+
* http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html
121+
*/
122+
Craft::info(
123+
Craft::t(
124+
'imgix-url',
125+
'{name} plugin loaded',
126+
['name' => $this->name]
127+
),
128+
__METHOD__
129+
);
95130
}
96131

97132
// Protected Methods
98133
// =========================================================================
99134

100-
/**
101-
* Creates and returns the model used to store the plugin’s settings.
102-
*
103-
* @return \craft\base\Model|null
104-
*/
105-
protected function createSettingsModel()
106-
{
107-
return new Settings();
108-
}
109-
110-
111135
}

src/config.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/models/Settings.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)