get() public static method

public static get ( )
Beispiel #1
0
<?php

use Doctrine\Tests\Models\Comments\User;
use Doctrine\Tests\Models\Comments\Email;
use Doctrine\Tests\Models\Comments\Comment;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/ElasticSearch.php';
$sm = ElasticSearch::get();
$client = $sm->getClient();
$metadatas = $sm->getMetadataFactory()->getAllMetadata();
// Delete indexes
foreach ($metadatas as $metadata) {
    if ($client->getIndex($metadata->index)->exists()) {
        $client->deleteIndex($metadata->index);
    }
}
// Recreate indexes and types
foreach ($metadatas as $metadata) {
    if (!$client->getIndex($metadata->index)->exists()) {
        $client->createIndex($metadata->index);
    }
    $client->createType($metadata);
}
//Install fixtures here... can use Doctrine/data-fixtures package with
//special SearchManager adapter if required.
$user1 = new User();
$user1->setName('Hash');
$user1->setUsername('mrhash');
$user1->addEmail(new Email('*****@*****.**'));
$user2 = new User();
$user2->setName('Timothy Leary');