diff --git a/src/Entity/Index.php b/src/Entity/Index.php index 2d82215..89c6f74 100644 --- a/src/Entity/Index.php +++ b/src/Entity/Index.php @@ -636,7 +636,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $fields = $this->getCache(__FUNCTION__, FALSE); if (!$fields) { $fields = array(); - foreach ($this->getFieldSettings() as $key => $field_info) { + foreach ($this->field_settings as $key => $field_info) { $fields[$key] = Utility::createField($this, $key, $field_info); } } @@ -677,7 +677,7 @@ class Index extends ConfigEntityBase implements IndexInterface { $fulltext_fields = $this->getCache(__FUNCTION__); if (!$fulltext_fields) { $fulltext_fields = array(); - foreach ($this->getFieldSettings() as $key => $field_info) { + foreach ($this->field_settings as $key => $field_info) { if (Utility::isTextType($field_info['type'])) { $fulltext_fields[] = $key; } @@ -690,21 +690,6 @@ class Index extends ConfigEntityBase implements IndexInterface { /** * {@inheritdoc} */ - public function getFieldSettings() { - return $this->field_settings; - } - - /** - * {@inheritdoc} - */ - public function setFieldSettings(array $fields = array()) { - $this->field_settings = $fields; - return $this; - } - - /** - * {@inheritdoc} - */ public function getPropertyDefinitions($datasource_id, $alter = TRUE) { $alter = $alter ? 1 : 0; $properties = $this->getCache(__FUNCTION__); diff --git a/src/IndexInterface.php b/src/IndexInterface.php index deac9e8..9f3b26a 100644 --- a/src/IndexInterface.php +++ b/src/IndexInterface.php @@ -420,24 +420,6 @@ interface IndexInterface extends ConfigEntityInterface { public function getFulltextFields(); /** - * Retrieves this index's field settings. - * - * @return array - * An array of field settings. - */ - public function getFieldSettings(); - - /** - * Sets this index's field settings. - * - * @param array $fields - * An array of field settings. - * - * @return $this - */ - public function setFieldSettings(array $fields); - - /** * Retrieves the properties of one of this index's datasources. * * @param string|null $datasource_id diff --git a/src/Tests/Processor/ProcessorTestBase.php b/src/Tests/Processor/ProcessorTestBase.php index 8d7b6b5..a4813c6 100644 --- a/src/Tests/Processor/ProcessorTestBase.php +++ b/src/Tests/Processor/ProcessorTestBase.php @@ -9,6 +9,7 @@ namespace Drupal\search_api\Tests\Processor; use Drupal\search_api\Entity\Index; use Drupal\search_api\Entity\Server; +use Drupal\search_api\Item\Field; use Drupal\search_api\Utility; use Drupal\system\Tests\Entity\EntityUnitTestBase; @@ -101,20 +102,22 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { 'tracker' => 'default', )); $this->index->setServer($this->server); - $this->index->setFieldSettings(array( - 'subject' => array( - 'label' => 'Subject', - 'type' => 'text', - 'datasource_id' => 'entity:comment', - 'property_path' => 'subject', - ), - 'title' => array( - 'label' => 'Title', - 'type' => 'text', - 'datasource_id' => 'entity:node', - 'property_path' => 'title', - ), - )); + + $field_subject = new Field($this->index, 'subject'); + $field_subject->setType('text'); + $field_subject->setPropertyPath('subject'); + $field_subject->setDatasourceId('entity:comment'); + $field_subject->setLabel('Subject'); + + $field_title = new Field($this->index, 'title'); + $field_title->setType('text'); + $field_title->setPropertyPath('title'); + $field_title->setDatasourceId('entity:node'); + $field_title->setLabel('Title'); + + $this->index->addField($field_subject); + $this->index->addField($field_title); + if ($processor) { $this->index->setProcessorSettings(array( $processor => array(