/** * Constructor * * @param ManagerRegistry $registry Registry * @param array $registeredTypes Array of registered ENUM types */ public function __construct(ManagerRegistry $registry, array $registeredTypes) { parent::__construct($registry); foreach ($registeredTypes as $type => $details) { $this->registeredEnumTypes[$type] = $details['class']; } }
/** * @param string $class * @return ClassMetadataInfo */ protected function getSingleMetadata($class) { $metadata = parent::getMetadata($class); if (!empty($metadata)) { return $metadata[0]; } }
/** * Get class metadata * * @param string $class Class name * * @return ClassMetadataInfo */ protected function getClassMetadata($class) { $metadata = parent::getMetadata($class); if (0 === count($metadata)) { return null; } return $metadata[0]; }
/** * Returns a field guess for a property name of a class. * * @param string $class The fully qualified class name. * @param string $property The name of the property to guess for. * * @return Guess\TypeGuess|null A guess for the field's type and options. */ public function guessType($class, $property) { if (!($ret = $this->getMetadata($class))) { return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); } list($metadata, $name) = $ret; if ('simple_array' == $metadata->getTypeOfField($property)) { return new TypeGuess('simple_array', array(), Guess::MEDIUM_CONFIDENCE); } return parent::guessType($class, $property); }
/** * Returns a field guess for a property name of a class. * * @param string $class The fully qualified class name. * @param string $property The name of the property to guess for. * * @return TypeGuess|null A guess for the field's type and options. */ public function guessType($class, $property) { if (!($ret = $this->getMetadata($class))) { $type = method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix') ? 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType' : 'text'; return new TypeGuess($type, [], Guess::LOW_CONFIDENCE); } $metadata = $ret[0]; if ('simple_array' == $metadata->getTypeOfField($property)) { $type = method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix') ? 'EmanueleMinotto\\SimpleArrayBundle\\Form\\Type\\SimpleArrayType' : 'simple_array'; return new TypeGuess($type, [], Guess::MEDIUM_CONFIDENCE); } return parent::guessType($class, $property); }
/** * @param ManagerRegistry $registry * @param Reader $reader */ public function __construct(ManagerRegistry $registry, Reader $reader) { parent::__construct($registry); $this->reader = $reader; }