/**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     if (null === $data || '' === $data) {
         return null;
     }
     $attribute = $context['attribute'];
     $code = $this->prepareOptionCode($attribute, $data);
     return $this->repository->findOneByIdentifier($code);
 }
 /**
  * Find an attribute option or throw a 404
  *
  * @param int $id The id of the attribute option
  *
  * @throws NotFoundHttpException
  *
  * @return AttributeOptionInterface
  */
 protected function findAttributeOptionOr404($id)
 {
     try {
         $result = $this->optionRepository->find($id);
     } catch (EntityNotFoundException $e) {
         throw new NotFoundHttpException($e->getMessage());
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 protected function getResults()
 {
     return new \ArrayIterator($this->repository->findBy([], ['attribute' => 'ASC', 'sortOrder' => 'ASC']));
 }
 /**
  * Find Option entity from identifier
  *
  * @param string $identifier
  *
  * @return AttributeOptionInterface
  */
 protected function findEntity($identifier)
 {
     return $this->repository->findOneByIdentifier($identifier);
 }