-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from esmero/ISSUE-308
ISSUE-308: This adds {1992..1996,...} to Solr indexing + Session ISSUE-310 + ISSUE-313
- Loading branch information
Showing
8 changed files
with
202 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Drupal\strawberryfield; | ||
|
||
use Drupal\Core\Security\TrustedCallbackInterface; | ||
use Drupal\views\Exception\ViewRenderElementException; | ||
use Drupal\views\Views; | ||
|
||
/** | ||
* Defines a class for render callbacks. | ||
* | ||
* @internal | ||
*/ | ||
final class StrawberryfieldRenderCallbacks implements TrustedCallbackInterface | ||
{ | ||
|
||
/** | ||
* #pre_render callback to alter views session starting crazyness during an index operation. | ||
*/ | ||
public static function preRender($build) { | ||
if (\Drupal::service('strawberryfield.search_api_state_helper')->isIndexing()) { | ||
// Initialize the exposed filters so Views won't start the session. | ||
// @see \Drupal\views\ViewExecutable::getExposedInput() | ||
/** @var \Drupal\views\ViewExecutable|null $view */ | ||
|
||
if (!isset($build['#view'])) { | ||
$view = Views::getView($build['#name']); | ||
if (!$view) { | ||
throw new ViewRenderElementException("Invalid View name ({$build['#name']}) given."); | ||
} | ||
$build['#view'] = $view; | ||
} | ||
$view = $build['#view'] ?? NULL; | ||
if ($view) { | ||
$view->initDisplay(); | ||
$view->setExposedInput(['' => '']); | ||
// Disable render caching. | ||
// $build['#cache']['max-age'] = 0; | ||
} | ||
} | ||
return $build; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function trustedCallbacks() { | ||
return ['preRender']; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Drupal\strawberryfield; | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\Core\File\FileSystemInterface; | ||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Entity\EntityTypeManagerInterface; | ||
use Drupal\Core\Entity\EntityFieldManagerInterface; | ||
use Drupal\Core\Extension\ModuleHandlerInterface; | ||
use Drupal\Core\StreamWrapper\StreamWrapperInterface; | ||
use Drupal\Core\StringTranslation\StringTranslationTrait; | ||
use Drupal\Core\Entity\ContentEntityInterface; | ||
use Drupal\search_api\Entity\Index; | ||
use Drupal\search_api\ParseMode\ParseModePluginManager; | ||
use Drupal\search_api\Query\QueryInterface; | ||
use Drupal\strawberryfield\Plugin\search_api\datasource\StrawberryfieldFlavorDatasource; | ||
|
||
/** | ||
* Provides the most basic Container we can keep a memory state of past Search API events. | ||
*/ | ||
class StrawberryfieldSearchAPIUtilityService implements StrawberryfieldSearchAPIUtilityServiceInterface { | ||
|
||
protected $isIndexing = FALSE; | ||
|
||
public function isIndexing(): bool | ||
{ | ||
return $this->isIndexing; | ||
} | ||
|
||
public function setIsIndexing(bool $isIndexing): void | ||
{ | ||
$this->isIndexing = $isIndexing; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Drupal\strawberryfield; | ||
|
||
interface StrawberryfieldSearchAPIUtilityServiceInterface | ||
{ | ||
|
||
public function isIndexing(): bool; | ||
|
||
|
||
public function setIsIndexing(bool $isIndexing): void; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters