Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 591 Bytes

11_entity_factory.md

File metadata and controls

25 lines (19 loc) · 591 Bytes

Entity factory

Description

Creates entity from result hit.

Example

namespace SpameriTests\Elastic\Factory;


class VideoFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface
{
	
	public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit)
	{
		return new \SpameriTests\Elastic\Data\Entity\Video(
			new \Spameri\Elastic\Entity\Property\ElasticId($hit->getValue('id')),
			new \SpameriTests\Elastic\Data\Entity\Video\Identification(
				new \SpameriTests\Elastic\Data\Entity\Property\ImdbId($hit->getValue('identification.imdb'))
			)
		);
	}
	
}