diff --git a/CHANGELOG.md b/CHANGELOG.md index cd15b0c..4f6a0f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ -Changelog -========= +# Changelog + +## 2.1.7 - 2022-09-07 + +- Added initial Craft 4 compatability. ## 2.1.6 - 2022-03-30 ### Changed + - Updated plugin icon. - Updated `league/oauth1-client` to 1.10.0. - Updated `guzzlehttp/oauth-subscriber` to 0.6.0. @@ -12,9 +16,11 @@ Changelog ## 2.1.5 - 2021-03-10 ### Added + - Added environment variable suggestions support for the OAuth consumer key and secret. ### Changed + - OAuth tokens are now stored in a `twitter_accounts` table instead of in the plugin’s settings. - Deprecated `\dukt\twitter\models\Settings::$token`. - Deprecated `\dukt\twitter\models\Settings::$tokenSecret`. @@ -23,39 +29,47 @@ Changelog - Bumped the schema version to 1.0.2. ### Fixed + - Fixed the icon of the Search widget. - Fixed a bug where the plugin was not working properly with Guzzle 7. ([#27](https://github.com/dukt/twitter/issues/27)) ## 2.1.4 - 2019-02-28 + - Show a warning when the OAuth callback URL contains query parameters which are not supported by Twitter. ## 2.1.3 - 2018-10-18 ### Added + - Added a `craft.twitter.parseTweetData()` method which parses tweet data and returns a Tweet model. - Added `dukt\twitter\web\twig\variables\TwitterVariable::parseTweetData()`. - Added `dukt\twitter\services\Api::parseTweetData()`. ### Fixed + - Fixed a bug where a missing namespace was preventing the Publish service from working properly. ([#13](https://github.com/dukt/twitter/issues/13)) ## 2.1.2 - 2018-09-10 ### Fixed + - Fixed Craft 3 upgrade migration. -## 2.1.1 - 2018-08-25 +## 2.1.1 - 2018-08-25 ### Changed + - Use `Craft::createGuzzleClient()` to instantiate Guzzle clients. - Improved exception handling when requesting the preview of a tweet for a tweet field. ### Fixed -- Fixed a bug where the plugin may cause Twig to be loaded before it should be, and another bug where the extension might not be available if the Template Mode ever changes from CP to Site, or vise-versa. ([#9](https://github.com/dukt/twitter/pull/9)) + +- Fixed a bug where the plugin may cause Twig to be loaded before it should be, and another bug where the extension might not be available if the Template Mode ever changes from CP to Site, or vise-versa. ([#9](https://github.com/dukt/twitter/pull/9)) ## 2.1.0 - 2018-06-14 ### Changed + - The Tweet field now returns a tweet URL instead of a Tweet model. - The Tweet model’s attributes and methods have changed. - Merged `getTweetById()` and `getTweetByUrl()` methods into a single `getTweet()`. @@ -68,18 +82,21 @@ Changelog - Updated nojimage/twitter-text-php dependency to `^2.0`. ### Fixed + - Fixed a bug where the Tweet field would throw an error when trying to show a deleted tweet. ([#7](https://github.com/dukt/twitter/issues/7)) - Fixed a bug where the links generated by the `autoLinkTweet` Twig filter could be wrong. ## 2.0.1 - 2018-05-25 ### Added + - Added support for 280-character tweets. - Added `searchWidgetExtraQuery` config setting. - Added `noOpener` option to the `autoLinkTweet` twig filter. ([#5](https://github.com/dukt/twitter/issues/5)) - Added `noopener` support to `dukt\twitter\lib\AutoLink`. ### Changed + - Updated to require craftcms/cms `^3.0.0-RC1`. - Changed rounded profile images to circle profile images. - Search widget is now filtering retweets by default. @@ -87,6 +104,7 @@ Changelog ## 2.0.0 - 2017-12-05 ### Added + - Craft 3 compatibility. - Added support section to `composer.json`. - Schema Version 1.0.0. @@ -100,6 +118,7 @@ Changelog - Added `dukt\twitter\helpers\TwitterHelper::getUserProfileImageResourceUrl()`. ### Changed + - The `$cacheExpire` parameter is now `null` instead of being set to `0` for the `\Craft\Twitter_ApiService::get()` method. - The `$cacheExpire` parameter is now `null` instead of being set to `0` for the `\Craft\TwitterVariable::get()` method. - Cache keys are now limited to 32 characters. @@ -112,6 +131,7 @@ Changelog - Renamed `dukt\twitter\web\twig\variables\TwitterVariable::getUserImageUrl()` to `dukt\twitter\web\twig\variables\TwitterVariable::getUserProfileImageResourceUrl()`. ### Fixed + - Fixed bug with `dukt\twitter\lib\AutoLink::autoLinkEntities()` method definition. - Fixed cache path. - Fixed an issue where `\Craft\Twitter_ApiService` was relying on `\Craft\FileCache` instead of `\Craft\Twitter_CacheService` for caching. @@ -119,12 +139,14 @@ Changelog - Fixed a bug where `dukt\twitter\services\Api::get()` wouldn’t take the `enableCache` config into account. ### Removed + - Removed `dukt/oauth` dependency. - Removed `dukt\twitter\services\Api::request()`. ## 2.0.0-beta.5 - 2017-09-22 ### Fixed + - Fixed bug with `dukt\twitter\lib\AutoLink::autoLinkEntities()` method definition. - Fixed user profile images for Craft 3.0.0-beta.27 which doesn’t support resource URLs anymore. @@ -171,6 +193,7 @@ Changelog ## 2.0.0-beta.1 - 2017-03-09 ### Added + - Craft 3 compatibility. - Schema Version 1.0.0. - Added `craftcms/cms` dependency. @@ -194,234 +217,255 @@ Changelog - Renamed `dukt\twitter\web\twig\variables\TwitterVariable::getUserImageUrl()` to `dukt\twitter\web\twig\variables\TwitterVariable::getUserProfileImageResourceUrl()`. ### Fixed + - Fixed a bug where `dukt\twitter\services\Api::get()` wouldn’t take the `enableCache` config into account. ### Removed + - Removed `dukt/craft-oauth` dependency. - Removed `dukt\twitter\services\Api::request()`. - ## 1.1.2 - 2017-01-23 ### Added -- Schema Version 1.0.0. -- The plugin can now be installed with composer via `composer require dukt/craft-twitter`. + +- Schema Version 1.0.0. +- The plugin can now be installed with composer via `composer require dukt/craft-twitter`. ### Improved -- Updated `nojimage/twitter-text-php` dependency. +- Updated `nojimage/twitter-text-php` dependency. ## 1.1.1 - 2017-01-10 ### Improved -- Improved search keywords for the Tweet field type. + +- Improved search keywords for the Tweet field type. ### Fixed -- Fixed API caching and removed deprecated `disableCache` config. +- Fixed API caching and removed deprecated `disableCache` config. ## 1.1.0 - 2016-12-14 ### Added -- Added `cacheDuration` config. -- Added `twitterFollowButton()` Twig function. -- Added `twitterGrid()` Twig function. -- Added `twitterMessageButton()` Twig function. -- Added `twitterMoment()` Twig function. -- Added `twitterTimeline()` Twig function. -- Added `twitterTweet()` Twig function. -- Added `twitterTweetButton()` Twig function. -- Added `twitterVideo()` Twig function. -- Added docs URL to the Settings page. + +- Added `cacheDuration` config. +- Added `twitterFollowButton()` Twig function. +- Added `twitterGrid()` Twig function. +- Added `twitterMessageButton()` Twig function. +- Added `twitterMoment()` Twig function. +- Added `twitterTimeline()` Twig function. +- Added `twitterTweet()` Twig function. +- Added `twitterTweetButton()` Twig function. +- Added `twitterVideo()` Twig function. +- Added docs URL to the Settings page. ### Improved -- Improved plugin description. -- Removed `Twitter_TweetFieldType::prepValueFromPost()`. -- Replaced `disableCache` config by `enableCache`. -- Tweet field now accepts a tweet URL or a tweet ID. + +- Improved plugin description. +- Removed `Twitter_TweetFieldType::prepValueFromPost()`. +- Replaced `disableCache` config by `enableCache`. +- Tweet field now accepts a tweet URL or a tweet ID. ### Fixed -- Fixed tweet’s permalink. +- Fixed tweet’s permalink. ## 1.0.32 - 2016-06-20 ### Added -- Added a permanent link to tweets. + +- Added a permanent link to tweets. ### Improved -- Now using the `bigger` Twitter profile image instead of the `normal` one. -- Removed unused disableSave.css. -- Renamed `tweet.css` to `twitter.css`. -- The user's name and the profile image are now clickable in the Search widget. -- Tweets are now clickable in the Search widget. +- Now using the `bigger` Twitter profile image instead of the `normal` one. +- Removed unused disableSave.css. +- Renamed `tweet.css` to `twitter.css`. +- The user's name and the profile image are now clickable in the Search widget. +- Tweets are now clickable in the Search widget. ## 1.0.31 - 2016-06-06 ### Added -- Added time ago to tweet preview in Tweet field. -- Added TwitterHelper::timeAgo(). -- Added TwitterPlugin::getDescription(). -- Added TwitterPlugin::getReleaseFeedUrl(). -- Added twitterTimeAgo twig filter. + +- Added time ago to tweet preview in Tweet field. +- Added TwitterHelper::timeAgo(). +- Added TwitterPlugin::getDescription(). +- Added TwitterPlugin::getReleaseFeedUrl(). +- Added twitterTimeAgo twig filter. ### Improved -- Formatting tweet dates as time ago in Search widget. -- Removed `colspan` from Search widget settings. -- Removed Twitter_SearchWidget::getColspan(). -- Improved time ago calculation. -- Moved TwitterController::actionSettings() to Twitter_SettingsController::actionIndex(). -- Now using PHP Traits for checking plugin dependencies. -- Now using secure profile image urls by default. + +- Formatting tweet dates as time ago in Search widget. +- Removed `colspan` from Search widget settings. +- Removed Twitter_SearchWidget::getColspan(). +- Improved time ago calculation. +- Moved TwitterController::actionSettings() to Twitter_SettingsController::actionIndex(). +- Now using PHP Traits for checking plugin dependencies. +- Now using secure profile image urls by default. ### Fixed -- Fixed the link to Twitter's OAuth provider configuration. +- Fixed the link to Twitter's OAuth provider configuration. ## 1.0.30 - 2016-02-13 ### Added -- Added `TwitterPlugin::getDocumentationUrl()`. + +- Added `TwitterPlugin::getDocumentationUrl()`. ### Improved -- Moved `Twitter_PluginController::actionInstall()` to `Twitter_InstallController:: actionIndex()`. -- Removed `TwitterHelper::log()`. -- Twitter now has its own log files. + +- Moved `Twitter_PluginController::actionInstall()` to `Twitter_InstallController:: actionIndex()`. +- Removed `TwitterHelper::log()`. +- Twitter now has its own log files. ### Fixed -- Fixed link to Twitter OAuth settings. +- Fixed link to Twitter OAuth settings. ## 1.0.29 - 2016-02-13 ### Improved -- Removed dependency auto download and install. -- Removed deprecated CSS resources. + +- Removed dependency auto download and install. +- Removed deprecated CSS resources. ### Fixed -- Fixed an issue with dependency checker. +- Fixed an issue with dependency checker. ## 1.0.28 - 2016-02-13 ### Added -- Added support for [OAuth 1.0+](https://dukt.net/craft/oauth). -- Added support for Craft CMS 2.5. -- Added plugin icons. -- Added `TwitterHelper`. -- Added icon for Search widget. -- Added `Twitter_ApiService`. -- Added `Twitter_CacheService`. -- Added `Twitter_OauthService`. + +- Added support for [OAuth 1.0+](https://dukt.net/craft/oauth). +- Added support for Craft CMS 2.5. +- Added plugin icons. +- Added `TwitterHelper`. +- Added icon for Search widget. +- Added `Twitter_ApiService`. +- Added `Twitter_CacheService`. +- Added `Twitter_OauthService`. ### Improved -- Now using TwitterPlugin::getSettingsUrl() instead of TwitterPlugin::getSettingsHtml()'s redirect method for specifying plugin's settings URL. -- Improved Twitter Search widget error handling. -- Improved Twitter_TweetFieldType to display light errors. -- Removed `TwitterVariable::setToken()`. -- Removed `TwitterVariable::getToken()`. -- Moved `TwitterService::api()` to `Twitter_ApiService::api()`. -- Moved `TwitterService::checkDependencies()` to `Twitter_PluginService::checkDependencies()`. -- Moved `TwitterService::deleteToken()` to `Twitter_OauthService::deleteToken()`. -- Moved `TwitterService::get()` to `Twitter_ApiService::get()`. -- Moved `TwitterService::getToken()` to `Twitter_OauthService::getToken()`. -- Moved `TwitterService::saveToken()` to `Twitter_OauthService::saveToken()`. -- Removed `TwitterService::setToken()`. -- Removed Twitter_OauthController::scope. -- Removed Twitter_OauthController::params. -- Moved `TwitterController::actionConnect()` to `Twitter_OauthController::actionConnect()`. -- Moved `TwitterController::actionDisconnect()` to `Twitter_OauthController::actionDisconnect()`. + +- Now using TwitterPlugin::getSettingsUrl() instead of TwitterPlugin::getSettingsHtml()'s redirect method for specifying plugin's settings URL. +- Improved Twitter Search widget error handling. +- Improved Twitter_TweetFieldType to display light errors. +- Removed `TwitterVariable::setToken()`. +- Removed `TwitterVariable::getToken()`. +- Moved `TwitterService::api()` to `Twitter_ApiService::api()`. +- Moved `TwitterService::checkDependencies()` to `Twitter_PluginService::checkDependencies()`. +- Moved `TwitterService::deleteToken()` to `Twitter_OauthService::deleteToken()`. +- Moved `TwitterService::get()` to `Twitter_ApiService::get()`. +- Moved `TwitterService::getToken()` to `Twitter_OauthService::getToken()`. +- Moved `TwitterService::saveToken()` to `Twitter_OauthService::saveToken()`. +- Removed `TwitterService::setToken()`. +- Removed Twitter_OauthController::scope. +- Removed Twitter_OauthController::params. +- Moved `TwitterController::actionConnect()` to `Twitter_OauthController::actionConnect()`. +- Moved `TwitterController::actionDisconnect()` to `Twitter_OauthController::actionDisconnect()`. ### Fixed -- Fixed Settings URL in templates. -- Fixed a bug with token in Twitter_ApiService::request(). +- Fixed Settings URL in templates. +- Fixed a bug with token in Twitter_ApiService::request(). ## 0.9.25 - 2015-05-10 ### Added -- Added TwitterPluginController. -- Added Twitter_PluginService. + +- Added TwitterPluginController. +- Added Twitter_PluginService. ### Improved -- Plugin now requires OAuth 0.9.70+. -- Logging error when unable to get an account. -- Renamed Twitter Tweets widget to Twitter Search. -- Improved Tweets widget to display a message when no tweets are found. -- Improved example templates. -- Improved plugin settings. + +- Plugin now requires OAuth 0.9.70+. +- Logging error when unable to get an account. +- Renamed Twitter Tweets widget to Twitter Search. +- Improved Tweets widget to display a message when no tweets are found. +- Improved example templates. +- Improved plugin settings. ### Fixed -- Twitter Search widget is now showing a notice when search query is missing. -- Fixed a bug where tweet id was sometimes turned into a float. +- Twitter Search widget is now showing a notice when search query is missing. +- Fixed a bug where tweet id was sometimes turned into a float. ## 0.9.13 - 2015-03-18 ### Added -- Added AnalyticsPlugin::getRequiredPlugins(). -- Added AnalyticsPlugin::getPluginDependencies(). -- Added AnalyticsPlugin::getPluginDependency(). -- Added dependency checker to check dependencies with other plugins. -- Added Tweets widgets to display recent tweets from a Twitter search. + +- Added AnalyticsPlugin::getRequiredPlugins(). +- Added AnalyticsPlugin::getPluginDependencies(). +- Added AnalyticsPlugin::getPluginDependency(). +- Added dependency checker to check dependencies with other plugins. +- Added Tweets widgets to display recent tweets from a Twitter search. ### Improved -- The plugin now requires OAuth 0.9.63 or above. -- Updated Recent Tweets example. -- Improved settings templates. -- Improved the way a token is deleted: deleting the token instead of setting it to null. -- Improved the way Twitter plugin is getting back to the page which initiated the connect action. -- Token providerHandle and pluginHandle are now automatically populated in token response. +- The plugin now requires OAuth 0.9.63 or above. +- Updated Recent Tweets example. +- Improved settings templates. +- Improved the way a token is deleted: deleting the token instead of setting it to null. +- Improved the way Twitter plugin is getting back to the page which initiated the connect action. +- Token providerHandle and pluginHandle are now automatically populated in token response. ## 0.9.10 - 2015-01-11 ### Added -- Added autoLinkTweet twig filter. -- Added embedTweet twig function. -- Added Auto-Linking Tweets templating example. -- Added Embedded Tweets templating example. -- Added twitter-text-php library. + +- Added autoLinkTweet twig filter. +- Added embedTweet twig function. +- Added Auto-Linking Tweets templating example. +- Added Embedded Tweets templating example. +- Added twitter-text-php library. ### Improved -- Disabled cache by default. + +- Disabled cache by default. ### Fixed -- Fixed bug with cache keys. +- Fixed bug with cache keys. ## 0.9.9 - 2015-01-11 ### Added -- Added support for new OAuth authentication logic. +- Added support for new OAuth authentication logic. ## 0.9.5 - 2015-01-11 ### Added -- Added support for Twitter URL containing "statuses". + +- Added support for Twitter URL containing "statuses". ### Fixed -- Fixed a bug where tweet user link was displaying blue instead of grey. +- Fixed a bug where tweet user link was displaying blue instead of grey. ## 0.9.4 - 2015-01-11 ### Added -- Added example templates. -- Added craft.twitter.getUserById(userId, params). -- Added craft()->twitter->api($method, $uri, $params, $headers, $postFields). -- Added cache handling to craft.twitter.get(). -- Added cache handling to craft()->twitter->get(). + +- Added example templates. +- Added craft.twitter.getUserById(userId, params). +- Added craft()->twitter->api($method, $uri, $params, $headers, $postFields). +- Added cache handling to craft.twitter.get(). +- Added cache handling to craft()->twitter->get(). ### Improved -- Improved craft.twitter.get() arguments : craft.twitter.get(uri, params, headers, enableCache, cacheExpire). -- Improved craft()->twitter->get() arguments : craft()->twitter->get($uri, $params, $headers, $enableCache, $cacheExpire). -- Prevent getSettingsHtml from being called if on settings/plugins listing page. +- Improved craft.twitter.get() arguments : craft.twitter.get(uri, params, headers, enableCache, cacheExpire). +- Improved craft()->twitter->get() arguments : craft()->twitter->get($uri, $params, $headers, $enableCache, $cacheExpire). +- Prevent getSettingsHtml from being called if on settings/plugins listing page. ## 0.9.3 - 2015-01-11 ### Added -- Public Beta. \ No newline at end of file + +- Public Beta. diff --git a/README.md b/README.md index 38b6a8a..1c229ff 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dukt/twitter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/dukt/twitter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/dukt/twitter/badges/build.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/build-status/master) [![Code Intelligence Status](https://scrutinizer-ci.com/g/dukt/twitter/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) -# Twitter for Craft CMS 3.x +# Twitter for Craft CMS 4.x Tweet field, search widget, embeds, and authenticated Twitter API requests for Craft CMS. ## Requirements -This plugin requires Craft CMS 3.0.0 or later. +This plugin requires Craft CMS 4.0.0 or later. ## How to install Twitter 2 @@ -15,4 +15,4 @@ Installation instructions can be found in [Twitter 2 Documentation](https://dukt ## Resources - [Twitter 2 Documentation](https://dukt.net/docs/twitter/v2) -- [Twitter 2 Overview](https://dukt.net/twitter) \ No newline at end of file +- [Twitter 2 Overview](https://dukt.net/twitter) diff --git a/composer.json b/composer.json index 475dd93..88c1189 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dukt/twitter", "description": "Tweet field, search widget, embeds, and authenticated Twitter API requests.", - "version": "2.1.6", + "version": "2.1.7", "type": "craft-plugin", "license": "proprietary", "keywords": [ @@ -23,7 +23,7 @@ "rss": "https://github.com/dukt/twitter/commits/v2.atom" }, "require": { - "craftcms/cms": "^3.0.0", + "craftcms/cms": "^4.0", "league/oauth1-client": "^1.10.0", "guzzlehttp/oauth-subscriber": "^0.6.0", "nojimage/twitter-text-php": "^2.0.3" @@ -40,4 +40,4 @@ "documentationUrl": "https://dukt.net/docs/twitter/v2", "changelogUrl": "https://raw.githubusercontent.com/dukt/twitter/master/CHANGELOG.md" } -} \ No newline at end of file +} diff --git a/src/Plugin.php b/src/Plugin.php index 32bb2af..3458486 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -8,6 +8,7 @@ namespace dukt\twitter; use Craft; +use craft\base\Model; use craft\events\RegisterCacheOptionsEvent; use craft\events\RegisterComponentTypesEvent; use craft\events\RegisterUrlRulesEvent; @@ -44,7 +45,7 @@ class Plugin extends \craft\base\Plugin /** * @var bool */ - public $hasCpSettings = true; + public bool $hasCpSettings = true; /** * @var \dukt\twitter\Plugin The plugin instance. @@ -57,7 +58,7 @@ class Plugin extends \craft\base\Plugin /** * @inheritdoc */ - public function init() + public function init() : void { parent::init(); self::$plugin = $this; @@ -116,7 +117,7 @@ public function init() /** * @inheritdoc */ - public function getSettings() + public function getSettings() : ?Model { $settings = parent::getSettings(); $configFile = Craft::$app->getConfig()->getConfigFromFile('twitter'); @@ -144,10 +145,8 @@ public function getSettings() /** * Creates and returns the model used to store the plugin’s settings. - * - * @return \craft\base\Model|null */ - protected function createSettingsModel() + protected function createSettingsModel(): ?Model { return new Settings(); } @@ -158,7 +157,7 @@ protected function createSettingsModel() * * @return string The rendered settings HTML */ - public function getSettingsResponse() + public function getSettingsResponse(): string { $url = UrlHelper::cpUrl('twitter/settings'); diff --git a/src/base/PluginTrait.php b/src/base/PluginTrait.php index e7a94cd..09e6ac8 100644 --- a/src/base/PluginTrait.php +++ b/src/base/PluginTrait.php @@ -9,6 +9,12 @@ use Craft; use dukt\twitter\Plugin; +use \dukt\twitter\services\Twitter; +use \dukt\twitter\services\Accounts; +use \dukt\twitter\services\Api; +use \dukt\twitter\services\Cache; +use \dukt\twitter\services\Oauth; +use \dukt\twitter\services\Publish; /** * PluginTrait implements the common methods and properties for plugin classes. @@ -26,7 +32,7 @@ trait PluginTrait * * @return \dukt\twitter\services\Twitter The twitter service */ - public function getTwitter() + public function getTwitter() : Twitter { /** @var Twitter $this */ return $this->get('twitter'); @@ -37,7 +43,7 @@ public function getTwitter() * * @return \dukt\twitter\services\Accounts The accounts service */ - public function getAccounts() + public function getAccounts() : Accounts { /** @var Twitter $this */ return $this->get('accounts'); @@ -48,7 +54,7 @@ public function getAccounts() * * @return \dukt\twitter\services\Api The api service */ - public function getApi() + public function getApi() : Api { /** @var Twitter $this */ return $this->get('api'); @@ -59,7 +65,7 @@ public function getApi() * * @return \dukt\twitter\services\Cache The cache service */ - public function getCache() + public function getCache() : Cache { /** @var Twitter $this */ return $this->get('cache'); @@ -70,7 +76,7 @@ public function getCache() * * @return \dukt\twitter\services\Oauth The oauth service */ - public function getOauth() + public function getOauth() : Oauth { /** @var Twitter $this */ return $this->get('oauth'); @@ -81,7 +87,7 @@ public function getOauth() * * @return \dukt\twitter\services\Publish The publish service */ - public function getPublish() + public function getPublish() : Publish { /** @var Twitter $this */ return $this->get('publish'); diff --git a/src/models/Settings.php b/src/models/Settings.php index dd61896..6d0c9dc 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -65,7 +65,7 @@ class Settings extends Model /** * @return array */ - public function rules() + public function rules(): array { return [ [['token', 'tokenSecret'], 'string'], diff --git a/src/services/Oauth.php b/src/services/Oauth.php index 24091cd..b687674 100644 --- a/src/services/Oauth.php +++ b/src/services/Oauth.php @@ -12,6 +12,7 @@ use dukt\twitter\Plugin; use yii\base\Component; use League\OAuth1\Client\Credentials\TokenCredentials; +use craft\helpers\App; use craft\helpers\UrlHelper; use \League\OAuth1\Client\Server\Twitter as TwitterProvider; @@ -94,7 +95,7 @@ public function getOauthProvider() { $options = [ 'identifier' => Plugin::getInstance()->getConsumerKey(), - 'secret' => Craft::parseEnv(Plugin::getInstance()->getConsumerSecret()), + 'secret' => App::parseEnv(Plugin::getInstance()->getConsumerSecret()), ]; if (!isset($options['callback_uri'])) { diff --git a/src/web/twig/Extension.php b/src/web/twig/Extension.php index a9b1c4e..1751dee 100644 --- a/src/web/twig/Extension.php +++ b/src/web/twig/Extension.php @@ -10,15 +10,15 @@ use craft\helpers\Template; use dukt\twitter\helpers\TwitterHelper; use dukt\twitter\Plugin; -use Twig_Extension; -use Twig_SimpleFunction; -use Twig_SimpleFilter; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; use GuzzleHttp\Exception\GuzzleException; /** * Twitter Twig Extension */ -class Extension extends Twig_Extension +class Extension extends AbstractExtension { // Public Methods // ========================================================================= @@ -41,8 +41,8 @@ public function getName() public function getFilters() { return [ - new Twig_SimpleFilter('autoLinkTweet', [$this, 'autoLinkTweet']), - new Twig_SimpleFilter('twitterTimeAgo', [$this, 'timeAgo']) + new TwigFilter('autoLinkTweet', [$this, 'autoLinkTweet']), + new TwigFilter('twitterTimeAgo', [$this, 'timeAgo']) ]; } @@ -54,15 +54,15 @@ public function getFilters() public function getFunctions() { return [ - new Twig_SimpleFunction('twitterGrid', [$this, 'twitterGrid']), - new Twig_SimpleFunction('twitterTimeline', [$this, 'twitterTimeline']), - new Twig_SimpleFunction('twitterTweet', [$this, 'twitterTweet']), - new Twig_SimpleFunction('twitterVideo', [$this, 'twitterVideo']), - new Twig_SimpleFunction('twitterMoment', [$this, 'twitterMoment']), - new Twig_SimpleFunction('twitterFollowButton', [$this, 'twitterFollowButton']), - new Twig_SimpleFunction('twitterMessageButton', [$this, 'twitterMessageButton']), - new Twig_SimpleFunction('twitterTweetButton', [$this, 'twitterTweetButton']), - new Twig_SimpleFunction('embedTweet', [$this, 'embedTweet']), + new TwigFunction('twitterGrid', [$this, 'twitterGrid']), + new TwigFunction('twitterTimeline', [$this, 'twitterTimeline']), + new TwigFunction('twitterTweet', [$this, 'twitterTweet']), + new TwigFunction('twitterVideo', [$this, 'twitterVideo']), + new TwigFunction('twitterMoment', [$this, 'twitterMoment']), + new TwigFunction('twitterFollowButton', [$this, 'twitterFollowButton']), + new TwigFunction('twitterMessageButton', [$this, 'twitterMessageButton']), + new TwigFunction('twitterTweetButton', [$this, 'twitterTweetButton']), + new TwigFunction('embedTweet', [$this, 'embedTweet']), ]; } diff --git a/src/widgets/SearchWidget.php b/src/widgets/SearchWidget.php index fc618c1..689d955 100644 --- a/src/widgets/SearchWidget.php +++ b/src/widgets/SearchWidget.php @@ -50,7 +50,7 @@ public static function displayName(): string /** * @inheritdoc */ - public static function icon() + public static function icon(): string { return Craft::getAlias('@dukt/twitter/icons/twitter.svg'); } @@ -61,7 +61,7 @@ public static function icon() /** * @inheritdoc */ - public function rules() + public function rules() : array { $rules = parent::rules(); $rules[] = [['query', 'count'], 'required']; @@ -88,7 +88,7 @@ public function getTitle(): string /** * @inheritdoc */ - public function getBodyHtml() + public function getBodyHtml(): string { $variables = []; $settings = $this->getSettings(); @@ -158,7 +158,7 @@ public function getBodyHtml() /** * @inheritdoc */ - public function getSettingsHtml() + public function getSettingsHtml(): string { return Craft::$app->getView()->renderTemplate('twitter/_components/widgets/Search/settings', [ 'settings' => $this->getSettings()