Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.3' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Mar 2, 2018
2 parents d2caefd + 4ca3b76 commit 6178b4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## 1.0.3 - 2018.03.02
### Changed
* Fixed deprecation errors from Craft CMS 3 RC13

## 1.0.2 - 2017.02.01
### Changed
* Renamed the composer package name to `craft-eagerbeaver`
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-eagerbeaver",
"description": "Allows you to eager load elements from auto-injected Entry elements on demand from your templates.",
"type": "craft-plugin",
"version": "1.0.2",
"version": "1.0.3",
"keywords": [
"craft",
"cms",
Expand Down
18 changes: 11 additions & 7 deletions src/services/EagerBeaverService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/**
* Eager Beaver plugin for Craft CMS 3.x
*
* Allows you to eager load elements from auto-injected Entry elements on demand from your templates.
* Allows you to eager load elements from auto-injected Entry elements on
* demand from your templates.
*
* @link https://nystudio107.com
* @copyright Copyright (c) 2017 nystudio107
Expand Down Expand Up @@ -30,26 +31,29 @@ class EagerBeaverService extends Component
/**
* Eager-loads additional elements onto a given set of elements.
*
* @param ElementInterface[] $elements The root element models that should be updated with the eager-loaded elements
* @param string|array $with Dot-delimited paths of the elements that should be eager-loaded into the root elements
* @param ElementInterface[] $elements The root element models that should
* be updated with the eager-loaded
* elements
* @param string|array $with Dot-delimited paths of the elements
* that should be eager-loaded into the
* root elements
*
* @return void
*/
public function eagerLoadElements($elements, $with)
{
// Bail if there aren't even any elements
if (!$elements || empty($elements))
{
if (!$elements || empty($elements)) {
return;
}

if (!is_array($elements)) {
$elements = array($elements);
$elements = [$elements];
}
// We are assuming all of these elements are of the same type
/** @var Element $element */
$element = $elements[0];
$elementType = $element::className();
$elementType = get_class($element);
Craft::$app->elements->eagerLoadElements($elementType, $elements, $with);
}
}

0 comments on commit 6178b4f

Please sign in to comment.