Finishes creating a rule using the parent builder.

@param \Caridea\Validate\Registry $registry
@return \Caridea\Validate\Rule The fully created rule
165966
public function finish(\Caridea\Validate\Registry $registry): \Caridea\Validate\Rule
    {
        if ($this->validator instanceof \Caridea\Validate\Validator) {
            return $this;
        } else {
            $rule = clone $this;
            $builder = $registry->builder();
            switch ($this->operator) {
                case "nested_object":
                case "list_objects":
                    $rule->validator = $builder->build($this->validator);
                    return $rule;
                case "list":
                    $rule->validator = $builder->build((object)['entry' => $this->validator]);
                    return $rule;
                case "list_different_objects":
                case "variable_object":
                    $validators = [];
                    foreach ($this->validator as $value => $ruleset) {
                        $validators[$value] = $builder->build($ruleset);
                    }
                    $rule->validator = new \Caridea\Validate\SwitchValidator($this->field, $validators);
                    return $rule;
            }
        }
    }
1315861
public function handle(ManagerRegistry $registry)
    {
        $emName = $this->option('em');
        $em     = $registry->getManager($emName);

        $destPath = base_path($this->argument('dest-path') ? $this->argument('dest-path') : 'app/Mappings');

        $simplified = false;
        $type       = $this->argument('mapping-type');

        if (Str::startsWith($type, 'simplified')) {
            $simplified = true;

            if (Str::contains($type, 'xml')) {
                $type       = 'xml';
            } elseif (Str::contains($type, 'yaml')) {
                $type       = 'yaml';
            }
        }

        $cme      = new ClassMetadataExporter();
        $exporter = $cme->getExporter($type);

        $exporter->setOverwriteExistingFiles($this->option('force'));

        if ('annotation' === $type) {
            $entityGenerator = $this->getEntityGenerator();
            $exporter->setEntityGenerator($entityGenerator);
        }

        $databaseDriver = new DatabaseDriver($em->getConnection()->getSchemaManager());

        // set namespace that will be used to generate metadata files
        $namespace = $this->option('namespace');
        if ($namespace) {
            $databaseDriver->setNamespace($namespace);
        }

        $em->getConfiguration()->setMetadataDriverImpl($databaseDriver);

        $cmf = new DisconnectedClassMetadataFactory();
        $cmf->setEntityManager($em);

        $metadata = $cmf->getAllMetadata();
        $metadata = MetadataFilter::filter($metadata, $this->option('filter'));

        if ($metadata) {
            $this->info(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));

            foreach ($metadata as $class) {
                $className = $class->name;
                if ('annotation' === $type) {
                    $path = $destPath . '/' . str_replace('\\', '.', $className) . '.php';
                } elseif ($simplified) {
                    $element = explode('\\', $className);
                    $path    = $destPath . '/' . end($element) . '.orm.' . $type;
                } else {
                    $path = $destPath . '/' . str_replace('\\', '.', $className) . '.dcm.' . $type;
                }
                $this->info(sprintf('  > writing <comment>%s</comment>', $path));
                $code = $exporter->exportClassMetadata($class);
                if (!is_dir($dir = dirname($path))) {
                    mkdir($dir, 0775, true);
                }
                file_put_contents($path, $code);
                chmod($path, 0664);
            }

            return 0;
        } else {
            $this->error('Database does not have any mapping information.');
            $this->error('');

            return 1;
        }
    }
30835
public function buildRules(RulesChecker $rules)
    {
        $rules->add($rules->isUnique(['name']));

        // don't allow deletion of non-deletable menu
        $rules->addDelete(function ($entity, $options) {
            return !$entity->deny_delete;
        }, 'systemCheck');

        return $rules;
    }
727748
public function build(): GetCertificateRequest
	{
		$instance = new GetCertificateRequest();
		if ($this->origin === null) {
			throw new BuilderException('Property [origin] is required.');
		}
		$instance->origin = $this->origin;
		return $instance;
	}
867930
public function afterRegistry()
    {
        parent::afterRegistry();

        $this->orgTranslations = $this->db->fetchPairs('
            SELECT gor_provider_id, gor_id_organization
                FROM gems__organizations
                WHERE gor_provider_id IS NOT NULL
                ORDER BY gor_provider_id');

        $this->orgTranslations = $this->orgTranslations + $this->db->fetchPairs('
            SELECT gor_code, gor_id_organization
                FROM gems__organizations
                WHERE gor_code IS NOT NULL
                ORDER BY gor_id_organization');
    }
1354238
public function afterRegistry()
    {
        parent::afterRegistry();

        $this->addColumn(new \Zend_Db_Expr(sprintf(
                "CASE WHEN gla_by IS NULL THEN '%s'
                    ELSE CONCAT(
                        COALESCE(gsf_last_name, '-'),
                        ', ',
                        COALESCE(CONCAT(gsf_first_name, ' '), ''),
                        COALESCE(gsf_surname_prefix, '')
                        )
                    END",
                $this->_('(no user)')
                )), 'staff_name');
        $this->addColumn(new \Zend_Db_Expr(sprintf(
                "CASE WHEN grs_id_user IS NULL THEN '%s'
                    ELSE CONCAT(
                        COALESCE(grs_last_name, '-'),
                        ', ',
                        COALESCE(CONCAT(grs_first_name, ' '), ''),
                        COALESCE(grs_surname_prefix, '')
                        )
                    END",
                $this->_('(no respondent)')
                )), 'respondent_name');
    }
521385
public function getMetaDataDriver($connection = null, ManagerRegistry $registry)
    {
        $registry = $registry ?: $this->container->make('registry');
        $manager  = $registry->getManager($connection);

        return $manager->getConfiguration()->getMetadataDriverImpl();
    }
238921
public function afterRegistry()
    {
        parent::afterRegistry();

        $this->browse  = true;
        $this->caption = $this->_('Rounds with this condition');
        $this->onEmpty = $this->_('No rounds using this condition found');
    }
991972
public function handle(
        ConfigurationProvider $provider,
        ManagerRegistry $registry,
        SqlBuilder $builder,
        MigrationFileGenerator $generator
    ) {
        $configuration = $provider->getForConnection($this->option('connection'));
        $em            = $registry->getManager($this->option('connection'));
        $connection    = $configuration->getConnection();

        // Overrule the filter
        if ($filterExpr = $this->option('filter-expression')) {
            $connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpr);
        }

        $fromSchema = $connection->getSchemaManager()->createSchema();
        $toSchema   = $this->getSchemaProvider($em)->createSchema();

        // Drop tables which don't suffice to the filter regex
        if ($filterExpr = $connection->getConfiguration()->getFilterSchemaAssetsExpression()) {
            foreach ($toSchema->getTables() as $table) {
                $tableName = $table->getName();
                if (!preg_match($filterExpr, $this->resolveTableName($tableName))) {
                    $toSchema->dropTable($tableName);
                }
            }
        }

        $up   = $builder->up($configuration, $fromSchema, $toSchema);
        $down = $builder->down($configuration, $fromSchema, $toSchema);

        if (!$up && !$down) {
            return $this->error('No changes detected in your mapping information.');
        }

        $path = $generator->generate(
            $configuration,
            false,
            false,
            $up,
            $down
        );

        $this->line(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));
    }
508713
public function build(): SetOverrideCertificateErrorsRequest
	{
		$instance = new SetOverrideCertificateErrorsRequest();
		if ($this->override === null) {
			throw new BuilderException('Property [override] is required.');
		}
		$instance->override = $this->override;
		return $instance;
	}
1097153
private function createLazyDefinition($registry, Definition $definition)
    {
        $lazy = new Definition(LazyRegistry::class, [
            new Reference('service_container'),
            new Reference($registry),
        ]);

        foreach ($definition->getMethodCalls() as $methodCall) {
            if ($methodCall[0] === 'offsetSet') {
                $methodCall[1][1] = (string) $methodCall[1][1];
                $lazy->addMethodCall('setLazy', $methodCall[1]);
            }
        }

        return $lazy;
    }
568326
public function afterRegistry()
    {
        parent::afterRegistry();

        $allowedGroups = $this->loader->getCurrentUser()->getAllowedStaffGroups();
        if ($allowedGroups) {
            $expr = new \Zend_Db_Expr(sprintf(
                    "CASE WHEN gsf_id_primary_group IN (%s) THEN 1 ELSE 0 END",
                    implode(", ", array_keys($allowedGroups))
                    ));
        } else {
            $expr = new \Zend_Db_Expr('0');
        }
        $this->addColumn($expr, 'accessible_role');
        $this->set('accessible_role', 'default', 1);
    }
319135
public function handle(ManagerRegistry $registry)
    {
        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();

        foreach ($names as $name) {
            $em = $registry->getManager($name);

            $this->comment('');
            $this->message('Generating getter and setter for <info>' . $name . '</info> entity manager...', 'blue');

            $cmf = new DisconnectedClassMetadataFactory();
            $cmf->setEntityManager($em);
            $metadatas = $cmf->getAllMetadata();
            $metadatas = MetadataFilter::filter($metadatas, $this->option('filter'));

            $destPath = base_path($this->argument('dest-path') ?:'app/Entities');

            if (!is_dir($destPath)) {
                mkdir($destPath, 0777, true);
            }

            $destPath = realpath($destPath);

            if (!file_exists($destPath)) {
                throw new \InvalidArgumentException(
                    sprintf("Proxies destination directory ' < info>%s </info > ' does not exist.",
                        $em->getConfiguration()->getProxyDir())
                );
            }

            if (count($metadatas)) {

                // Create EntityGenerator
                $entityGenerator = new EntityGenerator();

                $entityGenerator->setGenerateAnnotations($this->option('generate-annotations'));
                $entityGenerator->setGenerateStubMethods($this->option('generate-methods'));
                $entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities'));
                $entityGenerator->setUpdateEntityIfExists($this->option('update-entities'));
                $entityGenerator->setNumSpaces($this->option('num-spaces'));
                $entityGenerator->setBackupExisting(!$this->option('no-backup'));

                if (($extend = $this->option('extend')) !== null) {
                    $entityGenerator->setClassToExtend($extend);
                }

                foreach ($metadatas as $metadata) {
                    $this->comment(
                        sprintf('Processing entity "<info>%s</info>"', $metadata->name)
                    );
                }

                // Generating Entities
                $entityGenerator->generate($metadatas, $destPath);

                // Outputting information message
                $this->comment(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
            }
        }
    }
16507
public function actionGenerate()
	{
		Question::confirm(null, 1);
		$count = \App::$domain->rbac->const->generateAll();
		if($count) {
			Output::block("Generated {$count} constants");
		} else {
			Output::block("All rules exists!");
		}
	}
1239046
public function handle(ManagerRegistry $registry)
    {
        $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
        $exit  = 0;

        foreach ($names as $name) {
            $em        = $registry->getManager($name);
            $validator = new SchemaValidator($em);

            $this->comment('');
            $this->message('Validating for <info>' . $name . '</info> entity manager...');

            if ($this->option('skip-mapping')) {
                $this->comment('Mapping]  Skipped mapping check.');
            } elseif ($errors = $validator->validateMapping()) {
                foreach ($errors as $className => $errorMessages) {
                    $this->error("[Mapping]  FAIL - The entity-class '" . $className . "' mapping is invalid:");
                    $this->comment('');

                    foreach ($errorMessages as $errorMessage) {
                        $this->message('* ' . $errorMessage, 'red');
                    }
                }

                $exit += 1;
            } else {
                $this->info('[Mapping]  OK - The mapping files are correct.');
            }

            if ($this->option('skip-sync')) {
                $this->comment('Database] SKIPPED - The database was not checked for synchronicity.');
            } elseif (!$validator->schemaInSyncWithMetadata()) {
                $this->error('[Database] FAIL - The database schema is not in sync with the current mapping file.');

                $exit += 2;
            } else {
                $this->info('[Database] OK - The database schema is in sync with the mapping files.');
            }
        }

        return $exit;
    }
212463
private function buildStdClass()
    {
        foreach ($this->registries as $registry) {
            $this->entity->{$registry->getKey()} = $registry->getValue();
        }
    }
372015
public static function registerAllExtensions(\Protobuf\Extension\ExtensionRegistry $registry)
    {
        $registry->add(self::package());
        $registry->add(self::genericServices());
    }