-
Notifications
You must be signed in to change notification settings - Fork 24
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 #175 from pantheon-systems/BUGS-7551-Hook-Deprecation
BUGS-7551: Updates ConfigFilesAlter to use a listener instead of hook.
- Loading branch information
Showing
3 changed files
with
55 additions
and
20 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
51 changes: 51 additions & 0 deletions
51
src/EventSubscriber/SearchApiPantheonSolrConfigFilesAlter.php
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,51 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Drupal\search_api_pantheon\EventSubscriber; | ||
|
||
use Drupal\search_api_solr\Event\PostConfigFilesGenerationEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
use Symfony\Component\HttpKernel\Event\ResponseEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
/** | ||
* @issue BUGS-4278 | ||
* | ||
* Implements hook_search_api_solr_config_files_alter(). | ||
* | ||
* Remember to post schema after any changes to the XML files here. | ||
*/ | ||
final class SearchApiPantheonSolrConfigFilesAlter implements EventSubscriberInterface { | ||
|
||
/** | ||
* PostConfigFilesGenerationEvent event handler. | ||
* | ||
* @param PostConfigFilesGenerationEvent $event | ||
*/ | ||
public function onPostConfigFilesGenerationEvent(PostConfigFilesGenerationEvent $event): void { | ||
$files = $event->getConfigFiles(); | ||
// Append at the end of the file. | ||
$solrcore_properties = explode(PHP_EOL, $files['solrcore.properties']); | ||
// Remove the solr.install.dir if it exists | ||
foreach ($solrcore_properties as $key => $property) { | ||
if (substr($property, 0, 16) == 'solr.install.dir') { | ||
unset($solrcore_properties[$key]); | ||
} | ||
} | ||
// Remove the solrcore.properties file from the upload | ||
// This file is causing undue issues with core restarts | ||
unset($files['solrcore.properties']); | ||
|
||
$event->setConfigFiles($files); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents(): array { | ||
return [ | ||
'Drupal\search_api_solr\Event\PostConfigFilesGenerationEvent' => ['onPostConfigFilesGenerationEvent'], | ||
]; | ||
} | ||
|
||
} |