public function validateSeedProducerCode(ErrorElement $errorElement, $object)
    {
        $code = $object->getSeedProducerCode();
        $container = $this->getConfigurationPool()->getContainer();
        $is_new = empty($object->getId());

        if (empty($code)) {
            // Check if organism is a seed producer (belongs to the seed_producers app circle)
            $app_circles = $container->get('librinfo_crm.app_circles');
            if ($app_circles->isInCircle($object, 'seed_producers') && !$is_new) {
                $errorElement
                    ->with('seedProducerCode')
                        ->addViolation('A seed producer code is required for seed producers')
                    ->end()
                ;
            }
        } else {
            $registry = $container->get('blast_core.code_generators');
            $codeGenerator = $registry->getCodeGenerator(Organism::class, 'seedProducerCode');
            if (!$codeGenerator->validate($code)) {
                $errorElement
                    ->with('seedProducerCode')
                        ->addViolation('Wrong format for seed producer code. It shoud be: ' . $codeGenerator::getHelp())
                    ->end()
                ;
            }
        }
    }
public function validateSeedProducerCode(ErrorElement $errorElement, $object)
    {
        $code = $object->getSeedProducerCode();
        $container = $this->getConfigurationPool()->getContainer();
        $is_new = empty($object->getId());

        if (empty($code)) {
            // Check if organism is a seed producer (belongs to the seed_producers app circle)
            $app_circles = $container->get('librinfo_crm.app_circles');
            if ($app_circles->isInCircle($object, 'seed_producers') && !$is_new) {
                $errorElement
                    ->with('seedProducerCode')
                        ->addViolation('A seed producer code is required for seed producers')
                    ->end()
                ;
            }
        } else {
            $registry = $container->get('blast_core.code_generators');
            $codeGenerator = $registry->getCodeGenerator(Organism::class, 'seedProducerCode');
            if (!$codeGenerator->validate($code)) {
                $errorElement
                    ->with('seedProducerCode')
                        ->addViolation('Wrong format for seed producer code. It shoud be: ' . $codeGenerator::getHelp())
                    ->end()
                ;
            }
        }
    }
public function validateSeedProducerCode ( ErrorElement $ errorElement , $ object ) { $ code = $ object -> getSeedProducerCode ( ) ; $ container = $ this -> getConfigurationPool ( ) -> getContainer ( ) ; $ is_new = empty ( $ object -> getId ( ) ) ; if ( empty ( $ code ) ) { // Check if organism is a seed producer (belongs to the seed_producers app circle) $ app_circles = $ container -> get ( 'librinfo_crm.app_circles' ) ; if ( $ app_circles -> isInCircle ( $ object , 'seed_producers' ) && ! $ is_new ) { $ errorElement -> with ( 'seedProducerCode' ) -> addViolation ( 'A seed producer code is required for seed producers' ) -> end ( ) ; } } else { $ registry = $ container -> get ( 'blast_core.code_generators' ) ; $ codeGenerator = $ registry -> getCodeGenerator ( Organism :: class , 'seedProducerCode' ) ; if ( ! $ codeGenerator -> validate ( $ code ) ) { $ errorElement -> with ( 'seedProducerCode' ) -> addViolation ( 'Wrong format for seed producer code. It shoud be: ' . $ codeGenerator :: getHelp ( ) ) -> end ( ) ; } } }
Seed producer code validator.

@param ErrorElement $errorElement
@param Organism     $object
Seed producer code validator .