From f8f5502c40688f1fb2874ce068a739ed07d09388 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 11 Jan 2022 14:34:35 +0200 Subject: [PATCH 1/3] Added `Media::getRoute()` and `Media::getRawRoute()` methods to get page route if available --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Media.php | 40 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9b295da..1c7448e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added support for generic `assets.link()` for external references. No pipeline support * Added support for `assets.addJsModule()` with full pipeline support * Added `Utils::getExtensionsByMime()` method to get all the registered extensions for the specific mime type + * Added `Media::getRoute()` and `Media::getRawRoute()` methods to get page route if available 2. [](#improved) * Improved `Utils::download()` method to allow overrides on download name, mime and expires header * Improved `onPageFallBackUrl` event diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index 24bc2a6c3..6c0a6c390 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -60,6 +60,46 @@ class Media extends AbstractMedia } } + /** + * Return raw route to the page. + * + * @return string|null Route to the page or null if media isn't for a page. + */ + public function getRawRoute(): ?string + { + $path = $this->getPath(); + if ($path) { + /** @var Pages $pages */ + $pages = $this->getGrav()['pages']; + $page = $pages->get($path); + if ($page) { + return $page->rawRoute(); + } + } + + return null; + } + + /** + * Return page route. + * + * @return string|null Route to the page or null if media isn't for a page. + */ + public function getRoute(): ?string + { + $path = $this->getPath(); + if ($path) { + /** @var Pages $pages */ + $pages = $this->getGrav()['pages']; + $page = $pages->get($path); + if ($page) { + return $page->route(); + } + } + + return null; + } + /** * @param string $offset * @return bool From 308383b09388cdff393154fb025298cced0486a4 Mon Sep 17 00:00:00 2001 From: "pmoreno.rodriguez" <60596353+pmoreno-rodriguez@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:55:24 +0100 Subject: [PATCH 2/3] Update README.md (#3517) Changed the Twig Templating address to https://twig.symfony.com/. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f0e679a9..562726dfd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform. Ther The underlying architecture of Grav is designed to use well-established and _best-in-class_ technologies to ensure that Grav is simple to use and easy to extend. Some of these key technologies include: -* [Twig Templating](https://twig.sensiolabs.org/): for powerful control of the user interface +* [Twig Templating](https://twig.symfony.com/): for powerful control of the user interface * [Markdown](https://en.wikipedia.org/wiki/Markdown): for easy content creation * [YAML](https://yaml.org): for simple configuration * [Parsedown](https://parsedown.org/): for fast Markdown and Markdown Extra support From fb2c4f48f770fc5039ed0c19c10e9b07ebbe749e Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 11 Jan 2022 17:55:45 +0100 Subject: [PATCH 3/3] add php 8.1 to test (#3504) now released https://www.php.net/releases/8.1/en.php --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ea22ad291..90ed324b9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - php: [ 8.0, 7.4, 7.3] + php: [ 8.1, 8.0, 7.4, 7.3] os: [ubuntu-latest] steps: