1. Go to this page and download the library: Download becklyn/search-bundle 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/ */
becklyn / search-bundle example snippets
use Becklyn\SearchBundle\Entity\SearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;
/**
* @Search\Item()
*/
class SomeEntity implements SearchableEntityInterface
{
}
use Becklyn\Interfaces\LanguageInterface;
use Becklyn\SearchBundle\Entity\LocalizedSearchableEntityInterface;
use Becklyn\SearchBundle\Mapping as Search;
/**
* @Search\Item(
* index="custom-index-name",
* loader="some.service:method",
* )
*/
class LocalizedSomeEntity implements LocalizedSearchableEntityInterface
{
/**
* @return LanguageInterface
*/
public function getLanguage ()
{
}
}
use Becklyn\SearchBundle\Mapping as Search;
class SomeEntity
{
/**
* @Search\Field()
*/
private $headline;
/**
* @Search\Field()
*/
public function getSomeData ()
{
}
}
use Becklyn\SearchBundle\Event\IndexEntityEvent;
public function myEventListener (IndexEntityEvent $event)
{
$data = $event->getData();
$entity = $event->getEntity();
if (42 === $entity->getId())
{
$data["property-headline"] = "The answer to everything.";
$event->setData($data);
}
}
use Becklyn\SearchBundle\Mapping as Search;
/**
* @Search\Item(loader="custom.service:method")
*/
class Example
{
}
/**
* @Search\Item(loader="custom.service:method")
*/
// --> will load the entities using
$container->get("custom.service")->method(int[] $ids = null);
use Becklyn\SearchBundle\Mapping as Search;
class SomeClass
{
/**
* @Search\Filter("filter")
*/
public $property;
/**
* @Search\Filter("another-filter")
*/
public function method ()
{
// ...
}
}