/**
  * Warms up the cache.
  *
  * @param string $cacheDir The cache directory
  * @throws \RuntimeException
  */
 public function warmUp($cacheDir)
 {
     $baseDir = $this->annotationDir . DIRECTORY_SEPARATOR . 'Sidus' . DIRECTORY_SEPARATOR . 'EAV' . DIRECTORY_SEPARATOR;
     if (!@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
         throw new \RuntimeException("Unable to create annotations directory: {$baseDir}");
     }
     foreach ($this->familyConfigurationHandler->getFamilies() as $family) {
         $content = $this->getFileHeader($family);
         foreach ($family->getAttributes() as $attribute) {
             $content .= $this->getAttributeMethods($family, $attribute);
         }
         $content .= "}\n";
         $this->writeFile($baseDir . $family->getCode() . '.php', $content);
     }
 }
 /**
  * @param OptionsResolver $resolver
  *
  * @throws \Exception
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['families' => null]);
     $resolver->setNormalizer('families', function (Options $options, $values) {
         if (null === $values) {
             $values = $this->familyConfigurationHandler->getFamilies();
         }
         $families = [];
         foreach ($values as $value) {
             if (!$value instanceof FamilyInterface) {
                 $value = $this->familyConfigurationHandler->getFamily($value);
             }
             if ($value->isInstantiable()) {
                 $families[$value->getCode()] = $value;
             }
         }
         return $families;
     });
 }
 /**
  * @param OptionsResolver $resolver
  * @throws \Exception
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['choices_as_values' => true, 'choices' => null, 'families' => null]);
     $resolver->setNormalizer('families', function (Options $options, $values) {
         if (null === $values) {
             $values = $this->familyConfigurationHandler->getFamilies();
         }
         $families = [];
         foreach ($values as $value) {
             if (!$value instanceof FamilyInterface) {
                 $value = $this->familyConfigurationHandler->getFamily($value);
             }
             if ($value->isInstantiable()) {
                 $families[$value->getCode()] = $value;
             }
         }
         return $families;
     });
     $resolver->setNormalizer('choices_as_values', function (Options $options, $value) {
         if ($value !== true) {
             throw new \UnexpectedValueException("'choices_as_values' must be true (and is by default)");
         }
         return true;
     });
     $resolver->setNormalizer('choices', function (Options $options, $value) {
         if (null !== $value) {
             throw new \UnexpectedValueException("'choices' options is not supported for family selector, please use 'families' option");
         }
         $choices = [];
         /** @var FamilyInterface[] $families */
         $families = $options['families'];
         foreach ($families as $family) {
             if ($family->isInstantiable()) {
                 $choices[ucfirst($family)] = $family->getCode();
             }
         }
         return $choices;
     });
 }