/**
  * Finds entities by a set of criteria.
  *
  * @param Criteria $criteria
  * @return array The objects.
  *
  */
 public function findBy(Criteria $criteria)
 {
     $hydrator = $this->_hydrator;
     $classname = $this->_class->getName();
     $result = $this->_em->getConnexionDriver()->findBy($criteria, $this->_class);
     return array_map(function ($item) use($hydrator, $classname) {
         return $hydrator->hydrate($item, new $classname());
     }, $result);
 }
 /**
  * @param array $values
  * @param ClassMetadata $classMetadata
  * @return array
  */
 protected function getKeyValues(array $values, ClassMetadata $classMetadata)
 {
     return array_map(function ($item) use($values, $classMetadata) {
         if (!isset($values[$item['name']])) {
             throw new MissingIdentifierException('The field `' . $item['name'] . '` is mandatory');
         }
         return [$this->mapTypeField($item['type']) => $values[$item['name']]];
     }, $classMetadata->getIdentifier());
 }