You are here

class SolrDocumentFactory in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/SolrDocumentFactory.php \Drupal\search_api_solr\SolrDocumentFactory
  2. 8.2 src/SolrDocumentFactory.php \Drupal\search_api_solr\SolrDocumentFactory

Defines a class for a Solr Document factory.

Hierarchy

Expanded class hierarchy of SolrDocumentFactory

1 string reference to 'SolrDocumentFactory'
search_api_solr.services.yml in ./search_api_solr.services.yml
search_api_solr.services.yml
1 service uses SolrDocumentFactory
solr_document.factory in ./search_api_solr.services.yml
Drupal\search_api_solr\SolrDocumentFactory

File

src/SolrDocumentFactory.php, line 11

Namespace

Drupal\search_api_solr
View source
class SolrDocumentFactory implements SolrDocumentFactoryInterface {

  /**
   * Document name.
   *
   * @var string
   */
  protected static $solrDocument = 'solr_document';

  /**
   * A typed data manager.
   *
   * @var \Drupal\Core\TypedData\TypedDataManagerInterface
   */
  protected $typedDataManager;

  /**
   * Constructs a SolrDocumentFactory object.
   *
   * @param \Drupal\Core\TypedData\TypedDataManagerInterface $typedDataManager
   *   A typed data manager.
   */
  public function __construct(TypedDataManagerInterface $typedDataManager) {
    $this->typedDataManager = $typedDataManager;
  }

  /**
   * {@inheritdoc}
   *
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function create(ItemInterface $item) {
    $plugin = $this->typedDataManager
      ->getDefinition(static::$solrDocument)['class'];
    return $plugin::createFromItem($item);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SolrDocumentFactory::$solrDocument protected static property Document name. 1
SolrDocumentFactory::$typedDataManager protected property A typed data manager.
SolrDocumentFactory::create public function Overrides SolrDocumentFactoryInterface::create
SolrDocumentFactory::__construct public function Constructs a SolrDocumentFactory object.