Skip to content

Switch to protected methods #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Plugin/GraphQL/Derivers/SearchAPIDocumentTypeDeriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class SearchAPIDocumentTypeDeriver extends DeriverBase implements ContainerDeriverInterface {

/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
Expand Down
6 changes: 4 additions & 2 deletions src/Plugin/GraphQL/Derivers/SearchAPIFieldDeriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
class SearchAPIFieldDeriver extends DeriverBase implements ContainerDeriverInterface {

/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
Expand Down Expand Up @@ -76,13 +78,13 @@ public function getDerivativeDefinitions($base_plugin_definition) {
* @field_id
* The id of the field to map.
*/
private function setFieldType($field, $field_id) {
protected function setFieldType($field, $field_id) {

// Get field type.
$type = $field->getType();

// We can only check if a field is multivalue if it has a Datasource.
// @Todo This seems inefficient, check when it's being cached
// @todo This seems inefficient, check when it's being cached
$multivalue = SearchAPIHelper::checkMultivalue($field);

// Map the Search API types to GraphQL.
Expand Down
34 changes: 24 additions & 10 deletions src/Plugin/GraphQL/Fields/SearchAPISearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\graphql\GraphQL\Cache\CacheableValue;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use GraphQL\Type\Definition\ResolveInfo;
Expand Down Expand Up @@ -39,16 +38,31 @@
class SearchAPISearch extends FieldPluginBase implements ContainerFactoryPluginInterface {

/**
* Entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;

/**
* Logger channel factory.
*
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected $logger;

/**
* Search API query.
*
* @var \Drupal\search_api\Query\QueryInterface
*/
private $query;

/**
* Search API index.
*
* @var \Drupal\search_api\IndexInterface
*/
private $index;

/**
Expand Down Expand Up @@ -124,7 +138,7 @@ protected function getCacheDependencies(array $result, $value, array $args, Reso
* @conditions
* The conditions to be added.
*/
private function addConditions($conditions) {
protected function addConditions($conditions) {

// Loop through conditions to add them into the query.
foreach ($conditions as $condition) {
Expand All @@ -145,14 +159,14 @@ private function addConditions($conditions) {
* @condition_group
* The conditions to be added.
*/
private function addConditionGroup($condition_group_arg) {
protected function addConditionGroup($condition_group_arg) {

// Loop through the groups in the args.
foreach ($condition_group_arg['groups'] as $group) {

// Set default conjunction and tags.
$group_conjunction = 'AND';
$group_tags = array();
$group_tags = [];

// Set conjunction from args.
if (isset($group['conjunction'])) {
Expand Down Expand Up @@ -183,7 +197,7 @@ private function addConditionGroup($condition_group_arg) {
* @params
* The conditions to be added.
*/
private function addSolrParams($params) {
protected function addSolrParams($params) {

// Loop through conditions to add them into the query.
foreach ($params as $param) {
Expand All @@ -199,7 +213,7 @@ private function addSolrParams($params) {
* Parameters containing fulltext keywords to be used as well as optional
* fields.
*/
private function setFulltextFields($full_text_params) {
protected function setFulltextFields($full_text_params) {

// Check if keys is an array and if so set a conjunction.
if (is_array($full_text_params['keys'])) {
Expand Down Expand Up @@ -227,7 +241,7 @@ private function setFulltextFields($full_text_params) {
* @facets
* The facets to be added to the query.
*/
private function setFacets($facets) {
protected function setFacets($facets) {

// Retrieve this index server details.
$server = $this->index->getServerInstance();
Expand Down Expand Up @@ -259,7 +273,7 @@ private function setFacets($facets) {
* @facets
* The MLT params to be added to the query.
*/
private function setMLT($mlt_params) {
protected function setMLT($mlt_params) {

// Retrieve this index server details.
$server = $this->index->getServerInstance();
Expand All @@ -280,7 +294,7 @@ private function setMLT($mlt_params) {
* @args
* The arguments containing all the parameters to be loaded to the query.
*/
private function prepareSearchQuery($args) {
protected function prepareSearchQuery($args) {

// Prepare a query for the respective Search API index.
$this->query = $this->index->query();
Expand Down Expand Up @@ -331,7 +345,7 @@ private function prepareSearchQuery($args) {
* @results
* The Search API results to be parsed.
*/
private function getSearchResponse($results) {
protected function getSearchResponse($results) {

// Obtain result items.
$result_items = $results->getResultItems();
Expand Down