PHP code example of onedrop / solr-extbase
1. Go to this page and download the library: Download onedrop/solr-extbase library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
onedrop / solr-extbase example snippets
namespace Vendor\Extension\Domain\Model;
class Foobar extends AbstractEntity implements \Onedrop\SolrExtbase\Domain\Model\IndexableEntity {
/**
* relatedEntities
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extension\Domain\Model\RelatedEntity>
*/
protected $relatedEntities = NULL;
public function __construct() {
$this->relatedEntities = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
public function isIndexable() {
// Just returning true will cause the model to be indexed according to its enableFields
// and all other indexQueue constraints (additionalWhere etc.)
return true;
}
public function addEntityFieldsToDocument(\Apache_Solr_Document $document) {
foreach ($this->relatedEntites as $relatedEntity) {
$document->addField('relatedUid_intM', $relatedEntity->getUid());
}
return $document;
}