{@inheritdoc}

@throws RuntimeException
320644
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
    {
        /** @var ObjectManager $manager */
        $manager = $this->managerRegistry->getManagerForClass($resourceClass);

        $repository = $manager->getRepository($resourceClass);
        if (!method_exists($repository, 'createQueryBuilder')) {
            throw new RuntimeException('The repository class must have a "createQueryBuilder" method.');
        }

        $queryBuilder = $repository->createQueryBuilder('o');
        $queryNameGenerator = new QueryNameGenerator();
        foreach ($this->collectionExtensions as $extension) {
            $extension->applyToCollection($queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context);

            if ($extension instanceof QueryResultCollectionExtensionInterface && $extension->supportsResult($resourceClass, $operationName, $context)) {
                return $extension->getResult($queryBuilder, $resourceClass, $operationName, $context);
            }
        }

        return $queryBuilder->getQuery()->getResult();
    }
1011534
public function initialize(array $config)
    {
        $encryptionKey = $this->getConfig('encryptionKey');
        if (!empty($config['encryptionKey'])) {
            $encryptionKey = $config['encryptionKey'];
        }
        if (empty($encryptionKey)) {
            throw new RuntimeException('Encryption key is required.');
        }

        $enabled = $this->getConfig('enabled');
        if (!empty($config['enabled'])) {
            $enabled = $config['enabled'];
        }
        if (!is_callable($enabled) && !is_bool($enabled)) {
            throw new RuntimeException('Enabled flag must be a boolean or a callable which returns a boolean.');
        }
        $this->setConfig($config);
    }
54066
public function initialize()
    {
        if ($this->isActive()) {
            throw new RuntimeException('Process is already active');
        }

        $handle = $this->getFileResource();

        if (! @flock($handle, (LOCK_EX | LOCK_NB))) {
            throw new RuntimeException('Could not lock pidfile');
        }

        if (-1 === @fseek($handle, 0)) {
            throw new RuntimeException('Could not seek pidfile cursor');
        }

        if (! @ftruncate($handle, 0)) {
            throw new RuntimeException('Could not truncate pidfile');
        }

        if (! @fwrite($handle, $this->control->info()->getId().PHP_EOL)) {
            throw new RuntimeException('Could not write on pidfile');
        }
    }
1299078
public function write($message)
    {
        if ($this->output instanceof OutputInterface) {
            $this->output->write($message);
        } elseif (@fwrite($this->output, $message) === false) {
            throw new \RuntimeException('Unable to write output.');
        }
    }
833115
@Override
    public void run() {
        try {
            handle();
        } catch (Exception e) {
            Throwables.throwIfUnchecked(e);
            throw new RuntimeException(e);
        }
    }
264847
public function run(): void
    {
        if (!$this->config->isLoadedFromFile()) {
            throw new \RuntimeException('No configuration to edit');
        }

        $this->checkHook();
        $this->checkChange();

        $change = $this->createChange();
        $change->applyTo($this->config);
        Config\Util::writeToDisk($this->config);

        $this->io->write('Configuration successfully updated');
    }
382870
public function serialize()
    {
        if ($this->getIsModified() || $this->getIsNew()) {
            throw new RuntimeException($this->translate(
                'Cannot serialize modified or new object.'
            ));
        }

        if ($this->collection && $this->type) {
            $this->fullyLoad(true);
        }
        $data = [
            $this->initialValues,
            $this->getCollectionName(),
            $this->getTypeName()
        ];

        return serialize($data);
    }
909926
public function validateIdentifier($id)
    {
        $printed = print_r($id, true);
        if (count($this->keys) > 1 && !is_array($id)) {
            throw new \RuntimeException("Entity $this->name has a composed key, finding by id requires an array, given: $printed");
        }
        if (count($this->keys) !== count($id)) {
            $keys = print_r($this->keys, true);
            throw new \RuntimeException("Entity $this->name requires the following keys: $keys, given: $printed");
        }
    }
426441
public function read()
    {
        $read = $this->getStreams();
        $write = null;
        $except = null;
        $modified = stream_select($read, $write, $except, 0, 200000);

        if ($modified === false) {
            throw new \RuntimeException("stream_select() returned an error");
        }

        foreach ($read as $resource) {
            foreach ($this->messages as $message) {
                $this->readResource($message, $resource);
            }
        }
    }
621514
public function release()
    {
        try {
            $this->lock->release();
        } catch (\Exception $ex) {
            throw new \RuntimeException(
                sprintf(
                    'Releasing the lock failed with the following message: %s',
                    $ex->getMessage()
                ),
                0,
                $ex
            );
        }
    }
778478
public function setProperties(array $properties = [])
    {
        foreach ($properties as $property => $value) {
            $method = 'set'.ucfirst($property);
            if (!method_exists($this, $method)) {
                throw new \RuntimeException("Undefined method $method.");
            }

            if (!in_array($property, $this->validProperties)) {
                throw new \Exception('You are trying to set invalid properties. Please check valid properties.');
            }

            $this->{$method}($value);
        }
    }
84557
protected function read()
    {
        $contents = $this->filesystem()->get($this->path);
        $data     = json_decode($contents, true);

        if (is_null($data)) {
            throw new RuntimeException("Invalid JSON file in [{$this->path}]");
        }

        return (array) $data;
    }
651366
public function remove()
    {
        if ($this->removed) {
            return;
        }

        if (!\unlink($this->file)) {
            throw new RuntimeException(sprintf('Impossible to remove file "%s"', $this->file));
        }

        $this->removed = true;
    }
1098269
public function handle()
    {
        $users = $this->getUsers();

        $count = count($users);

        if ($count === 0) {
            throw new RuntimeException("There were no users found to import.");
        } else if ($count === 1) {
            $this->info("Found user '{$users[0]->getCommonName()}'.");
        } else {
            $this->info("Found {$count} user(s).");
        }

        if (
            $this->input->isInteractive() &&
            $this->confirm('Would you like to display the user(s) to be imported / synchronized?', $default = false)
        ) {
            $this->display($users);
        }

        if (
            ! $this->input->isInteractive() ||
            $this->confirm('Would you like these users to be imported / synchronized?', $default = true)
        ) {
            $imported = $this->import($users);

            $this->info("Successfully imported / synchronized {$imported} user(s).");
        } else {
            $this->info("Okay, no users were imported / synchronized.");
        }
    }
686082
public function execute(array $runtimeArgs)
    {
        if (null === $this->commandName)
        {
            throw new CommandNameNotSetException(self::class, __METHOD__);
        }

        return parent::execute($runtimeArgs);
    }
800720
public function beforeCompile(): void
	{
		// Breaks at other mode then CLI
		if (PHP_SAPI !== 'cli') return;

		$builder = $this->getContainerBuilder();

		// Verify that we have http.request
		if (!$builder->hasDefinition('http.request')) {
			throw new RuntimeException('Service http.request is needed');
		}

		$config = $this->validateConfig($this->defaults);
		$builder->getDefinition('http.request')
			->setFactory(Request::class, [
				new Statement(UrlScript::class, [$config['url']]),
				$config['query'],
				$config['post'],
				$config['files'],
				$config['cookies'],
				$config['headers'],
				$config['method'],
				$config['remoteAddress'],
				$config['remoteHost'],
				$config['rawBodyCallback'],
			]);
	}
293640
protected function loadValueOptions()
    {
        if (!($om = $this->objectManager)) {
            throw new RuntimeException('No object manager was set');
        }

        if (!($targetClass = $this->targetClass)) {
            throw new RuntimeException('No target class was set');
        }

        $metadata   = $om->getClassMetadata($targetClass);
        $identifier = $metadata->getIdentifierFieldNames();
        $objects    = $this->getObjects();
        $options    = array();

        if ($this->displayEmptyItem || empty($objects)) {
            $options[] = $this->getEmptyItemLabel();
        }

        if (!empty($objects)) {
            foreach ($objects as $key => $object) {
                if (null !== ($generatedLabel = $this->generateLabel($object))) {
                    $label = $generatedLabel;
                } elseif ($property = $this->property) {
                    $label = $this->getPropertyValue($property, $object, $metadata);
                } else {
                    if (!is_callable(array($object, '__toString'))) {
                        throw new RuntimeException(
                            sprintf(
                                '%s must have a "__toString()" method defined if you have not set a property'
                                . ' or method to use.',
                                $targetClass
                            )
                        );
                    }

                    $label = (string) $object;
                }

                if (count($identifier) > 1) {
                    $value = $key;
                } else {
                    $value = current($metadata->getIdentifierValues($object));
                }
                $groupProperties = $this->getGroupProperty();
                if(empty($groupProperties)) {
                    $options[$value] = $label;
                }else{
//                    $groupLabel = array();
//                    foreach($groupProperties as $prop){
//                        $groupLabel[] = $this->getPropertyValue($prop, $object, $metadata);
//                    }
//                    $groupLabel = implode($this->getPropertyPartsConcatBy(), $groupLabel);
                    $groupLabel =  $this->getPropertyValue($groupProperties, $object, $metadata);
                    $options[$groupLabel]['label'] = $groupLabel;
                    $options[$groupLabel]['options'][$value] = $label;
                }
            }
        }

        $this->valueOptions = $options;
    }