Skip to content

Commit

Permalink
feat: Craft 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
nstCactus committed Aug 23, 2022
1 parent d68e0c5 commit 9ed7fe9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## Unreleased


## 2.0.0-beta.1 - 2022-08-23
### Added
- Support for Craft 4


## 1.5.1 – 2022-08-23
### Fixed
- Fix an incorrect default value for the `highlight.pre_tags` &
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"require": {
"craftcms/cms": "^3.5.0",
"craftcms/cms": "^4.0.0",
"yiisoft/yii2-elasticsearch": "^2.1.0"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Elasticsearch extends Plugin
public const EVENT_ERROR_NO_ATTACHMENT_PROCESSOR = 'errorNoAttachmentProcessor';
public const PLUGIN_HANDLE = 'elasticsearch';

public $hasCpSettings = true;
public bool $hasCpSettings = true;

public function init(): void
{
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/CpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class CpController extends Controller
{
/** @var ElasticsearchPlugin */
public $plugin;
public $allowAnonymous = ['testConnection', 'reindexPerformAction'];

protected array|bool|int $allowAnonymous = ['testConnection', 'reindexPerformAction'];

public function init(): void
{
Expand Down Expand Up @@ -169,7 +170,7 @@ protected function getSiteIds(Request $request): array
* @throws \Exception If reindexing the entry fails for some reason.
* @throws \yii\web\BadRequestHttpException if the request body is missing a `params` property
*/
protected function reindexElement()
protected function reindexElement(): ?string
{
$request = Craft::$app->getRequest();

Expand Down
2 changes: 1 addition & 1 deletion src/jobs/IndexElementJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IndexElementJob extends BaseJob
/**
* @inheritdoc
*/
public function execute($queue)
public function execute($queue): void
{
$sites = Craft::$app->getSites();
$site = $sites->getSiteById($this->siteId);
Expand Down
1 change: 1 addition & 0 deletions src/services/ElementIndexerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ protected function getElementIndexableContent(Element $element)
'preview/preview',
[
'elementType' => get_class($element),
'canonicalId' => $element->canonicalId,
'sourceId' => $element->id,
'siteId' => $element->siteId,
'draftId' => null,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/RefreshElasticsearchIndexUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function id(): string
* Returns the path to the utility's SVG icon.
* @return string|null The path to the utility SVG icon
*/
public static function iconPath()
public static function iconPath(): ?string
{
return Craft::getAlias('@lhs/elasticsearch/resources/cp/img/utility-icon.svg');
}
Expand Down

0 comments on commit 9ed7fe9

Please sign in to comment.