Doctrine\Search\UnitOfWork::load PHP Метод

load() публичный Метод

Load and hydrate a document model
public load ( ClassMetadata $class, mixed $value, array $options = [] )
$class Doctrine\Search\Mapping\ClassMetadata
$value mixed
$options array
    public function load(ClassMetadata $class, $value, $options = array())
    {
        $client = $this->sm->getClient();
        if (isset($options['field'])) {
            $document = $client->findOneBy($class, $options['field'], $value);
        } else {
            $document = $client->find($class, $value, $options);
        }
        return $this->hydrateEntity($class, $document);
    }

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function find($entityName, $id)
 {
     $options = array();
     if (is_array($id)) {
         if (!isset($id['id'])) {
             throw new \InvalidArgumentException('An "id" field is required');
         }
         $options = $id;
         $id = $options['id'];
         unset($options['id']);
     }
     $class = $this->getClassMetadata($entityName);
     return $this->unitOfWork->load($class, $id, $options);
 }