Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Welch <[email protected]>
khalwat committed Apr 20, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3ab4ef0 commit 197e494
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/services/Similar.php
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ class Similar extends Component
public $limit;

public $targetElements;

// Public Methods
// =========================================================================

@@ -105,7 +106,7 @@ public function find($data)
$elements = Craft::$app->getElements();
$models = [];
foreach ($results as $config) {
if($config['id'] && $config['siteId']) {
if ($config['id'] && $config['siteId']) {
$model = $elements->getElementById($config['id'], $elementClass, $config['siteId']);
if ($model) {
// The `count` property is added dynamically by our CountBehavior behavior
@@ -139,7 +140,7 @@ protected function eventAfterPrepareHandler(CancelableEvent $event)
$query->query->limit($this->limit); // or whatever limit is set

$query->subQuery->groupBy('elements.id');
if($query->elementType == 'craft\elements\Entry') {
if ($query->elementType === 'craft\elements\Entry') {
$query->subQuery->addGroupBy(['structureelements.structureId', 'structureelements.lft']);
}
$event->isValid = true;

0 comments on commit 197e494

Please sign in to comment.