Skip to content

Commit

Permalink
Merge branch 'release/1.1.2' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Apr 14, 2018
2 parents 0137724 + 1a4e909 commit 8e0b930
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 62 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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

## 1.1.2 - 2018.04.14
### Changed
* RouteMap now returns the URI (aka path) instead of fully qualified URLs
* Code cleanup

## 1.1.1 - 2018.03.02
### Changed
* Fixed deprecation errors from Craft CMS 3 RC13
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-routemap",
"description": "Returns a list of Craft/Vue/React route rules and element URLs for ServiceWorkers from Craft entries",
"type": "craft-plugin",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"craft",
"cms",
Expand Down
7 changes: 3 additions & 4 deletions src/RouteMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,16 @@ function (ElementEvent $event) {
);
/** @var Element $element */
$element = $event->element;
$isNewElement = $event->isNew;
$bustCache = true;
// Only bust the cache if the element is ENABLED or LIVE
if (($element->getStatus() != Element::STATUS_ENABLED)
&& ($element->getStatus() != Entry::STATUS_LIVE)
if (($element->getStatus() !== Element::STATUS_ENABLED)
&& ($element->getStatus() !== Entry::STATUS_LIVE)
) {
$bustCache = false;
}
if ($bustCache) {
Craft::debug(
"Cache busted due to saving: " . get_class($element) . " - " . $element->title,
'Cache busted due to saving: ' . \get_class($element) . ' - ' . $element->title,
__METHOD__
);
RouteMap::$plugin->routes->invalidateCache();
Expand Down
18 changes: 9 additions & 9 deletions src/controllers/RoutesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RoutesController extends Controller
*
* @return string
*/
public function actionGetAllUrls(array $criteria = [], $siteId = null)
public function actionGetAllUrls(array $criteria = [], $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getAllUrls($criteria, $siteId));
}
Expand All @@ -64,7 +64,7 @@ public function actionGetAllUrls(array $criteria = [], $siteId = null)
*
* @return string
*/
public function actionGetSectionUrls(string $section, array $criteria = [], $siteId = null)
public function actionGetSectionUrls(string $section, array $criteria = [], $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId));
}
Expand All @@ -78,7 +78,7 @@ public function actionGetSectionUrls(string $section, array $criteria = [], $sit
*
* @return string
*/
public function actionGetCategoryUrls(string $category, array $criteria = [], $siteId = null)
public function actionGetCategoryUrls(string $category, array $criteria = [], $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId));
}
Expand All @@ -91,7 +91,7 @@ public function actionGetCategoryUrls(string $category, array $criteria = [], $s
*
* @return string
*/
public function actionGetAllRouteRules(string $format = 'Craft', $siteId = null)
public function actionGetAllRouteRules(string $format = 'Craft', $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getAllRouteRules($format, $siteId));
}
Expand All @@ -105,7 +105,7 @@ public function actionGetAllRouteRules(string $format = 'Craft', $siteId = null)
*
* @return string
*/
public function actionGetSectionRouteRules(string $section, string $format = 'Craft', $siteId = null)
public function actionGetSectionRouteRules(string $section, string $format = 'Craft', $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getSectionRouteRules($section, $format, $siteId));
}
Expand All @@ -119,7 +119,7 @@ public function actionGetSectionRouteRules(string $section, string $format = 'Cr
*
* @return string
*/
public function actionGetCategoryRouteRules(string $category, string $format = 'Craft', $siteId = null)
public function actionGetCategoryRouteRules(string $category, string $format = 'Craft', $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getCategoryRouteRules($category, $format, $siteId));
}
Expand All @@ -132,7 +132,7 @@ public function actionGetCategoryRouteRules(string $category, string $format = '
*
* @return string
*/
public function actionGetRouteRules($siteId = null, $includeGlobal = true)
public function actionGetRouteRules($siteId = null, $includeGlobal = true): string
{
return $this->asJson(RouteMap::$plugin->routes->getRouteRules($siteId, $includeGlobal));
}
Expand All @@ -147,7 +147,7 @@ public function actionGetRouteRules($siteId = null, $includeGlobal = true)
*
* @return string
*/
public function actionGetUrlAssetUrls($url, array $assetTypes = ['image'], $siteId = null)
public function actionGetUrlAssetUrls($url, array $assetTypes = ['image'], $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId));
}
Expand All @@ -162,7 +162,7 @@ public function actionGetUrlAssetUrls($url, array $assetTypes = ['image'], $site
*
* @return string
*/
public function actionGetElementUrls($elementType, array $criteria = [], $siteId = null)
public function actionGetElementUrls($elementType, array $criteria = [], $siteId = null): string
{
return $this->asJson(RouteMap::$plugin->routes->getElementUrls($elementType, $criteria, $siteId));
}
Expand Down
7 changes: 5 additions & 2 deletions src/helpers/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class Field extends Component
*
* @return array
*/
public static function fieldsOfType(ElementInterface $element, string $fieldType)
public static function fieldsOfType(ElementInterface $element, string $fieldType): array
{
$foundFields = [];

$layout = $element->getFieldLayout();
if ($layout === null) {
return [];
}
$fields = $layout->getFields();
/** @var $field BaseField */
foreach ($fields as $field) {
Expand All @@ -58,7 +61,7 @@ public static function fieldsOfType(ElementInterface $element, string $fieldType
*
* @return array
*/
public static function matrixFieldsOfType(MatrixBlock $matrixBlock, string $fieldType)
public static function matrixFieldsOfType(MatrixBlock $matrixBlock, string $fieldType): array
{
$foundFields = [];

Expand Down
Loading

0 comments on commit 8e0b930

Please sign in to comment.