SolrFieldDefinition.php in Search API Solr 8.2
File
src/TypedData/SolrFieldDefinition.php
View source
<?php
namespace Drupal\search_api_solr\TypedData;
use Drupal\Core\TypedData\DataDefinition;
class SolrFieldDefinition extends DataDefinition implements SolrFieldDefinitionInterface {
protected static $schemaLabels = [
'I' => 'Indexed',
'T' => 'Tokenized',
'S' => 'Stored',
'M' => 'Multivalued',
'V' => 'TermVector Stored',
'o' => 'Store Offset With TermVector',
'p' => 'Store Position With TermVector',
'O' => 'Omit Norms',
'L' => 'Lazy',
'B' => 'Binary',
'C' => 'Compressed',
'f' => 'Sort Missing First',
'l' => 'Sort Missing Last',
];
protected $schema;
public function isList() {
return $this
->isMultivalued();
}
public function isReadOnly() {
return TRUE;
}
public function isComputed() {
return FALSE;
}
public function isRequired() {
return FALSE;
}
public function getSchema() {
if (!isset($this->schema)) {
foreach (str_split(str_replace('-', '', $this->definition['schema'])) as $key) {
$this->schema[$key] = isset(self::$schemaLabels[$key]) ? self::$schemaLabels[$key] : $key;
}
}
return $this->schema;
}
public function getDynamicBase() {
return isset($this->field['dynamicBase']) ? $this->field['dynamicBase'] : NULL;
}
public function isIndexed() {
$this
->getSchema();
return isset($this->schema['I']);
}
public function isTokenized() {
$this
->getSchema();
return isset($this->schema['T']);
}
public function isStored() {
$this
->getSchema();
return isset($this->schema['S']);
}
public function isMultivalued() {
$this
->getSchema();
return isset($this->schema['M']);
}
public function isTermVectorStored() {
$this
->getSchema();
return isset($this->schema['V']);
}
public function isStoreOffsetWithTermVector() {
$this
->getSchema();
return isset($this->schema['o']);
}
public function isStorePositionWithTermVector() {
$this
->getSchema();
return isset($this->schema['p']);
}
public function isOmitNorms() {
$this
->getSchema();
return isset($this->schema['O']);
}
public function isLazy() {
$this
->getSchema();
return isset($this->schema['L']);
}
public function isBinary() {
$this
->getSchema();
return isset($this->schema['B']);
}
public function isCompressed() {
$this
->getSchema();
return isset($this->schema['C']);
}
public function isSortMissingFirst() {
$this
->getSchema();
return isset($this->schema['f']);
}
public function isSortMissingLast() {
$this
->getSchema();
return isset($this->schema['l']);
}
public function isPossibleKey() {
return !$this
->getDynamicBase() && $this
->isStored() && !$this
->isMultivalued();
}
public function isSortable() {
return $this
->isIndexed() && !$this
->isMultivalued();
}
public function isFulltextSearchable() {
return $this
->isIndexed() && $this
->isTokenized();
}
public function isFilterable() {
return $this
->isIndexed() && !$this
->isTokenized();
}
}