Resolve backend class.

@throws IllegalStateException

@return string
435706
private function resolveBackendClass()
    {
        $parser = new ArgvInput();
        $backend = $parser->getParameterOption('--backend', null);

        if (null === $backend) {
            // Do not use this feature for typical use case.
            // Overriding backend using env var provided only for
            // testing purposes and may be removed in the future.
            // You SHOULD NOT rely on this possibility.
            if (getenv('ZEPHIR_BACKEND')) {
                $backend = $backend = getenv('ZEPHIR_BACKEND');
            } elseif ($this->container->has('ZEPHIR_BACKEND')) {
                $backend = $this->container->get('ZEPHIR_BACKEND');
            }
        }

        if (null === $backend) {
            $backend = BaseBackend::getActiveBackend();
        }

        $className = "Zephir\\Backends\\{$backend}\\Backend";

        if (!class_exists($className)) {
            throw new IllegalStateException(sprintf('Backend class "%s" doesn\'t exist.', $backend));
        }

        return $className;
    }
395268
public function resolveAllAction()
    {
        $this->getEntityManager()->getRepository(Exception::class)->markAllAsResolved();

        $indexUrl = $this->getAdminListConfigurator()->getIndexUrl();

        return new RedirectResponse(
            $this->generateUrl(
                $indexUrl['path'],
                isset($indexUrl['params']) ? $indexUrl['params'] : array()
            )
        );
    }
6095
private function reslovePrototypesPath()
    {
        $prototypesPath = $this->prototypesPath;

        // fallback
        if (empty($prototypesPath)) {
            $prototypesPath = \dirname(__DIR__).'/prototypes';
        }

        if (!is_dir($prototypesPath) || !is_readable($prototypesPath)) {
            throw new IllegalStateException('Unable to resolve internal prototypes directory.');
        }

        return $prototypesPath;
    }
494571
static public function resolveConfiguration() {
		static::$init=true;
		$self = new static();
		static::$init=false;
		$conf = array (
			'table'=>$self->getTable(),
			'fieldConf'=>$self->getFieldConfiguration(),
			'db'=>$self->db,
			'fluid'=>$self->fluid,
			'primary'=>$self->primary,
			'charset'=>$self->charset,
		);
		unset($self);
		return $conf;
	}
1228106
public Class<?> getClassType() {
        try {
            return Class.forName(getType(), true, ClassLoaderHolder.getClassLoader());
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }
    }
331701
private TypeResolver getTypeResolver() {
        TypeResolver typeResolver = scannerContext.peek(TypeResolver.class);
        if (typeResolver == null) {
            throw new IllegalStateException("Cannot find Java type resolver.");
        }
        return typeResolver;
    }
507645
public function getTransactional() {
		if ($this->transactionalEm !== null && $this->transactionalEm->isOpen()) {
			return $this->transactionalEm;
		}
		
		$pdo = $this->pdoPool->getPdo($this->persistenceUnitName);
		if (!$pdo->inTransaction()) {
			throw new IllegalStateException('No tranaction open.');
		}
		
		$this->transactionalEm = new LazyEntityManager($this->persistenceUnitName, $this->pdoPool, true);
		$this->transactionalEm->bindPdo($pdo);
	
		return $this->transactionalEm;
	}
333211
protected function resolver()
    {
        $table = Arr::get($this->config, 'table', $this->name);

        return $this->repository->table($table);
    }
1082265
public function resolve()
    {
        // TODO: Make this dynamic.

        if (is_scalar($this->value)) {
            if (is_string($this->value)) {
                return ScalarTypes::SCALAR_STRING;
            } elseif (is_bool($this->value)) {
                return ScalarTypes::SCALAR_BOOLEAN;
            } elseif (is_integer($this->value)) {
                return ScalarTypes::SCALAR_INTEGER;
            } elseif (is_float($this->value)) {
                return ScalarTypes::SCALAR_FLOAT;
            }
        } elseif (is_array($this->value)) {
            return CompoundTypes::COMPOUND_ARRAY;
        } elseif (is_object($this->value)) {
            return CompoundTypes::COMPOUND_OBJECT;
        } elseif (is_resource($this->value)) {
            return SpecialTypes::SPECIAL_RESOURCE;
        } elseif ($this->value === null) {
            return SpecialTypes::SPECIAL_NULL;
        }

        throw new UnknownTypeException(gettype($this->value));
    }
196701
public static function parseBacktrace()
	{
		$file = '-';
		$line = 0;

		// Loop through the backtrace items
		foreach (self::getBacktrace() as $item)
		{
			// Looking for the last instance of one of the following classes...
			// this will be our indicator of the command that originated this query
			if (isset($item['class'])
			 && ($item['class'] == 'Hubzero\Database\Relational'
			 ||  $item['class'] == 'Hubzero\Database\Relationship\Relationship'
			 ||  $item['class'] == 'Hubzero\Database\Rows'))
			{

				$file = (isset($item['file'])) ? str_replace(PATH_CORE, '', $item['file']) : $file;
				$line = (isset($item['line'])) ? $item['line'] : $line;
			}
		}

		return array($file, $line);
	}
1032361
public function getResolver()
    {
        if (!$this->resolver) {
            $self = $this;

            $this->resolver = new EngineResolver();

            $this->resolver->register(
                'blade',
                function () use ($self) {
                    return $self->getCompiler();
                }
            );
        }

        return $this->resolver;
    }
239596
protected function _resolve()
    {
        if (!$this->_deferred) {
            return;
        }
        $data = $this->_deferred;

        $instance = $data['instance'];
        $this->_not = $data['not'];
        $boolean = $instance->resolve();
        $data['description'] = $instance->description();
        $data['backtrace'] = $instance->backtrace();
        $this->_log($boolean, $data);

        $this->_deferred = null;
    }
451855
public function resolve()
    {
        if (!($prev = $this->handler)) {
            throw new \LogicException('No handler has been specified');
        }

        if ($this->sorted === null) {
            $this->sortMiddleware();
        }

        foreach ($this->sorted as $fn) {
            $prev = $fn($prev);
        }

        return $prev;
    }
753166
public function resolve()
    {
        if ($this->sourceFile instanceof UploadedFile) {
            $extension = $this->sourceFile->guessExtension();
            $name = preg_filter('/^php(.+)/', '$1', $this->sourceFile->getBasename());
            $this->originalName = $this->sourceFile->getClientOriginalName();
        } else {
            $extension = $this->sourceFile->getExtension();
            $this->originalName = $name = $this->sourceFile->getBasename('.'.$extension);
        }

        $this->setPhysicalFile(
            $this->sourceFile->move(
                $this->storePath,
                sprintf('%s%s.%s',
                    strtolower($name),
                    base_convert(microtime(), 10, 36),
                    $extension
                )
            )
        );

        return parent::resolve();
    }
698640
public function getClass()
    {
        return $this->refl->isAbstract()
            ? null
            : new ParsedClass(
                (string) $this->refl->getDocComment(),
                $this->getCleanReflectionName(),
                $this->refl->getNamespaceName(),
                $this->getMethods()
            );
    }
324544
private static function resolveBaseService()
    {
        $cachedServices = Config::get('service-classes.cached_services.classes', null);

        $baseService = $cachedServices[static::class] ?? static::translateBaseService();

        return resolve($baseService);
    }
947250
private function getOptionsResolver()
    {
        // TODO Use/Merge ConfigurationBuilder options resolver.
        if (!$this->optionsResolver) {
            $resolver = new OptionsResolver();

            $resolver
                ->setRequired(['namespace', 'id', 'classes'])
                ->setDefaults([
                    'name'        => function (Options $options) {
                        return Inflector::camelize($options['id']);
                    },
                    'parent_id'   => null,
                    'event'       => null,
                    'templates'   => null,
                    'translation' => null,
                ])
                ->setAllowedTypes('namespace', 'string')
                ->setAllowedTypes('id', 'string')
                ->setAllowedTypes('name', 'string')
                ->setAllowedTypes('parent_id', ['null', 'string'])
                ->setAllowedTypes('classes', 'array')
                ->setAllowedTypes('event', ['null', 'string', 'array'])
                ->setAllowedTypes('templates', ['null', 'string', 'array'])
                ->setAllowedTypes('translation', ['null', 'array']);


            // Classes option
            $classesResolver = new OptionsResolver();
            $classesResolver
                ->setRequired(['entity'])
                ->setDefaults([
                    'form_type'  => null, // @TODO/WARNING no longer required (behavior refactoring)
                    'repository' => null,
                ])
                ->setAllowedTypes('entity', 'string')
                ->setAllowedTypes('repository', ['null', 'string'])
                ->setAllowedTypes('form_type', ['null', 'string']); // @TODO/WARNING no longer required (behavior refactoring)

            $resolver
                ->setNormalizer('classes', function (Options $options, $value) use ($classesResolver) {
                    foreach ($value as $class) {
                        if ($class && !class_exists($class)) {
                            throw new InvalidOptionsException(sprintf("Class '%s' does not exists.", $class));
                        }
                    }

                    $entity = $value['entity'];
                    if (null !== $options['translation'] && !is_subclass_of($entity, TranslatableInterface::class)) {
                        throw new InvalidOptionsException(sprintf(
                            "Class '%s' must implements '%s'.",
                            $entity,
                            TranslatableInterface::class));
                    }

                    $repository = array_key_exists('repository', $value) ? $value['repository'] : null;
                    if (null === $repository) {
                        $value['repository'] = null !== $options['translation']
                            ? TranslatableResourceRepository::class
                            : ResourceRepository::class;
                    } elseif (null !== $options['translation']) {
                        if (!is_subclass_of($repository, TranslatableResourceRepositoryInterface::class)) {
                            throw new InvalidOptionsException(sprintf(
                                "Class '%s' must implements '%s'.",
                                $repository,
                                TranslatableResourceRepositoryInterface::class
                            ));
                        }
                    } else {
                        if (!is_subclass_of($repository, ResourceRepositoryInterface::class)) {
                            throw new InvalidOptionsException(sprintf(
                                "Class '%s' must implements '%s'.",
                                $repository,
                                ResourceRepositoryInterface::class
                            ));
                        }
                    }

                    return $classesResolver->resolve($value);
                });


            // Translation option
            $translationResolver = new OptionsResolver();
            $translationResolver
                ->setRequired(['entity', 'fields'])
                ->setDefault('repository', null)
                ->setAllowedTypes('entity', 'string')
                ->setAllowedTypes('fields', 'array')
                ->setAllowedTypes('repository', ['null', 'string'])
                ->setAllowedValues('entity', function ($class) {
                    if (!class_exists($class)) {
                        throw new InvalidOptionsException(sprintf("Class '%s' does not exists.", $class));
                    }
                    if (!is_subclass_of($class, TranslationInterface::class)) {
                        throw new InvalidOptionsException(sprintf("Class '%s' must implements '%s'.", $class, TranslationInterface::class));
                    }

                    return true;
                })
                ->setAllowedValues('fields', function ($fields) {
                    if (empty($fields)) {
                        throw new InvalidOptionsException("Translatable fields cannot be empty.");
                    }

                    return true;
                })
                ->setAllowedValues('repository', function ($class) {
                    if (null !== $class && !class_exists($class)) {
                        throw new InvalidOptionsException(sprintf("Class '%s' does not exists.", $class));
                    }

                    return true;
                });

            /** @noinspection PhpUnusedParameterInspection */
            $resolver->setNormalizer('translation', function (Options $options, $value) use ($translationResolver) {
                if (is_array($value)) {
                    return $translationResolver->resolve($value);
                }

                return $value;
            });


            // Event option
            $eventResolver = new OptionsResolver();
            $eventResolver
                ->setRequired(['class'])
                ->setDefaults([
                    'class'    => $this->defaultEventClass,
                    'priority' => 0,
                ])
                ->setAllowedTypes('class', 'string')
                ->setAllowedTypes('priority', 'int');

            /** @noinspection PhpUnusedParameterInspection */
            $resolver->setNormalizer('event', function (Options $options, $value) use ($eventResolver) {
                if (is_string($value)) {
                    $value = ['class' => $value];
                }

                $value = $eventResolver->resolve((array)$value);

                if (!is_subclass_of($value['class'], ResourceEventInterface::class)) {
                    throw new InvalidOptionsException(sprintf(
                        "Class '%s' must implements '%s'.",
                        $value['class'],
                        ResourceEventInterface::class
                    ));
                }

                return $value;
            });


            // Templates option
            /** @noinspection PhpUnusedParameterInspection */
            $resolver->setNormalizer('templates', function (Options $options, $value) {
                return $this->buildTemplateList($value);
            });


            $this->optionsResolver = $resolver;
        }

        return $this->optionsResolver;
    }