Skip to content

Commit

Permalink
Merge pull request #258 from lsst-epo/253-upgrade-craft-to-v4102
Browse files Browse the repository at this point in the history
Updated Craft to `v4.10.2`
  • Loading branch information
ericdrosas87 authored Jul 9, 2024
2 parents a4dd812 + f0d4342 commit 5013c4a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 33 deletions.
2 changes: 1 addition & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"require": {
"carlcs/craft-assetmetadata": "^4.0",
"castiron/next-builds": "^1.1",
"craftcms/cms": "4.8.4",
"craftcms/cms": "4.10.2",
"craftcms/contact-form": "3.1.0",
"craftcms/contact-form-honeypot": "2.1.0",
"craftcms/google-cloud": "2.1.0",
Expand Down
42 changes: 21 additions & 21 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/plugins/nextbuilds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

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

## 1.1.2 - 2024-6-28
### Fixed
- When a page is updated (enabled, disabled, deleted) the appropriate query param is sent to revalidate the navigation menu in the client

## 1.1.1 - 2024-6-27
### Fixed
- Revalidate request is now firing after entry-save event trigger completes DB update
Expand Down
2 changes: 1 addition & 1 deletion api/plugins/nextbuilds/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "castiron/next-builds",
"description": "Start Next.js page builds from Craft.",
"type": "craft-plugin",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"craft",
"cms",
Expand Down
21 changes: 13 additions & 8 deletions api/plugins/nextbuilds/src/NextBuilds.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
use craft\base\Plugin;
use craft\elements\Entry;
use craft\events\ModelEvent;
use craft\events\ElementStructureEvent;
use craft\events\MoveElementEvent;
use craft\helpers\ElementHelper;
use craft\services\Plugins;
use craft\events\PluginEvent;
use castiron\nextbuilds\services\Request as NextRequestService;

use craft\services\Structures;
use yii\base\Event;

/**
Expand Down Expand Up @@ -106,15 +107,17 @@ function (PluginEvent $event) {
Entry::EVENT_AFTER_SAVE,
function (ModelEvent $event) {
$entry = $event->sender;

if (
$this->settings->activeSections[$entry->section->handle] &&
!ElementHelper::isDraftOrRevision($entry) &&
!($entry->duplicateOf && $entry->getIsCanonical() && !$entry->updatingFromDerivative) &&
!ElementHelper::rootElement($entry)->isProvisionalDraft &&
!$entry->resaving
) {
Craft::$app->onAfterRequest(function() use ($entry) {
$this->request->buildPagesFromEntry($entry);
$revalidateMenu = ($entry->type->handle == "pages");
Craft::$app->onAfterRequest(function() use ($entry, $revalidateMenu) {
$this->request->buildPagesFromEntry($entry, $revalidateMenu);
});
}
}
Expand All @@ -131,18 +134,20 @@ function (Event $event) {
!($entry->duplicateOf && $entry->getIsCanonical() && !$entry->updatingFromDerivative) &&
!ElementHelper::rootElement($entry)->isProvisionalDraft
) {
Craft::$app->onAfterRequest(function() use ($entry) {
$this->request->buildPagesFromEntry($entry);
$revalidateMenu = ($entry->type->handle == "pages");
Craft::$app->onAfterRequest(function() use ($entry, $revalidateMenu) {
$this->request->buildPagesFromEntry($entry, $revalidateMenu);
});
}
}
);

Event::on(
Entry::class,
Entry::EVENT_AFTER_MOVE_IN_STRUCTURE,
function (ElementStructureEvent $event) {
Structures::class,
Structures::EVENT_AFTER_INSERT_ELEMENT,
function (MoveElementEvent $event) {
$entry = $event->sender;

if (
$this->settings->activeSections[$entry->section->handle] &&
!ElementHelper::isDraftOrRevision($entry) &&
Expand Down
7 changes: 5 additions & 2 deletions api/plugins/nextbuilds/src/services/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ class Request extends Component
* @return void
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function buildPagesFromEntry(Entry $entry)
public function buildPagesFromEntry(Entry $entry, string $revalidateMenu)
{
$settings = NextBuilds::getInstance()->getSettings();
$client = new Client();

$endpoint = $this->getSettingsData($settings->nextApiBaseUrl) . self::NEXT_ENDPOINT_REVALIDATE;
$endpoint = $this->getSettingsData($settings->nextApiBaseUrl) . self::NEXT_ENDPOINT_REVALIDATE;
$params = [
'uri' => $entry->uri,
'secret' => $this->getSettingsData($settings->nextSecretToken)
];
if ($revalidateMenu) {
$params["tags"] = ["navigation"];
}
$requestUrl = $endpoint . '?' . http_build_query($params);
Craft::info("Request URL: " .$requestUrl, "REVALIDATE_STATUS");

Expand Down

0 comments on commit 5013c4a

Please sign in to comment.