Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Welch <andrew@nystudio107.com>
  • Loading branch information
khalwat committed Jul 30, 2018
1 parent df324c5 commit b0c4e6b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/EagerBeaver.php
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 @@ -73,8 +74,4 @@ function (Event $event) {
__METHOD__
);
}

// Protected Methods
// =========================================================================

}
6 changes: 3 additions & 3 deletions src/services/EagerBeaverService.php
Expand Up @@ -43,17 +43,17 @@ class EagerBeaverService extends Component
public function eagerLoadElements($elements, $with)
{
// Bail if there aren't even any elements
if (!$elements || empty($elements)) {
if (empty($elements)) {
return;
}

if (!is_array($elements)) {
if (!\is_array($elements)) {
$elements = [$elements];
}
// We are assuming all of these elements are of the same type
/** @var Element $element */
$element = $elements[0];
$elementType = get_class($element);
$elementType = \get_class($element);
Craft::$app->elements->eagerLoadElements($elementType, $elements, $with);
}
}
12 changes: 8 additions & 4 deletions src/twigextensions/EagerBeaverTwigExtension.php
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 All @@ -12,7 +13,6 @@

use nystudio107\eagerbeaver\EagerBeaver;

use Craft;
use craft\base\ElementInterface;

/**
Expand Down Expand Up @@ -48,8 +48,12 @@ public function getFunctions()
/**
* 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
*/
Expand Down
12 changes: 8 additions & 4 deletions src/variables/EagerBeaverVariable.php
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 All @@ -12,7 +13,6 @@

use nystudio107\eagerbeaver\EagerBeaver;

use Craft;
use craft\base\ElementInterface;

/**
Expand All @@ -32,8 +32,12 @@ class EagerBeaverVariable
/**
* 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
*/
Expand Down

0 comments on commit b0c4e6b

Please sign in to comment.