Resolves a Donee for the incoming donor

@param DonorInterface $donor The donor to fetch a donee for

@return DoneeInterface
335265
public function resolve(DonorInterface $donor)
    {
        $mutualIncrement = 0;

        do {
            $donee = $this->doneeRepository->findOneNonMutualFor($donor);

            $mutualIncrement++;

            if ($mutualIncrement >= self::MAX_MUTUAL_LOOP) {
                $donee = null;
                break;
            }
            if (!$this->pairRepository->isPairMutually($donor, $donee)) {
                break;
            }
        } while (true);

        if (!is_null($donee)) {
            return $donee;
        }

        return  $this->nextResolver->resolve($donor);
    }
1258445
public function process(EventInterface $event)
    {
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }

        $options = $optionsProvider->getOptions($pane);
        if ($options->getType() == 'search') {
            $this->error(self::ReorderSearch);
            return $this->redirect($event);
        }
        if ($options->getRoot() == 'trash') {
            $this->error(self::ReorderTrash);
            return $this->redirect($event);
        }
        if ($options->getOrderBy() != 'natural') {
            $this->error(self::UnmanagedOrder);
            return $this->redirect($event);
        }

        $posNew = $event->getParam('position');
        $posOld = $event->getParam('old_position');
        if (empty($posNew) || empty($posOld)) {
            return;
        }
        $positions = array_diff_assoc($posNew, $posOld);
            foreach ($positions as $id => $position) {
                try {
                    $mapper->beginTransaction();
                    $tid = $mapper->getTransactionIdentifier();
                    $this->mapper->reorder($id, $position, $tid);
                    $mapper->commit();
                } catch (UnavailableSourceException $e) {
                    $mapper->rollBack();
                    $this->setValue($id)->error(self::SourceNotFound);
                } catch (UnavailableDestinationException $e) {
                    $mapper->rollBack();
                    $this->error(self::DestinationNotFound);

                    // the destination is not available for all elements
                    break;
                } catch (Exception $e) {
                    $mapper->rollBack();
                    if (DEBUG_MODE) {
                        throw new DebugException(
                            $translator->translate('Error: ') . $e->getMessage(),
                            $e->getCode(),
                            $e
                        );
                    }
                    $meta = $mapper->findMetaById($id);
                    $name = isset($meta['title']) ? $meta['title'] : $id;
                    $this->setValue($name)->error(self::UnexpectedError);
                    break;
                }
            }

        return $this->redirect($event);
    }
1209033
public function documentExists(TransferInterface $transfer, $containerName)
    {
        $this->checkTransferMethods($transfer);

        $fileName = $transfer->getFileName();
        $relativePath = $transfer->getRelativePath();

        return $this->fileUploadFacade->fileExists($containerName, $fileName, $relativePath);
    }
790919
protected function resolveCommand($command, array $parameters): CommandInterface
	{
		if($command instanceof CommandInterface)
		{
			return $command;
		}

		return $this->container->get($command, $parameters);
	}
240235
protected function prepareTransfer(TransferInterface $transferObject) {
        $uri    = $this->getUri();
        $body   = $transferObject->getBody();

        if( array_key_exists('chargeId', $body) ) {
            $uri = str_replace('{chargeId}', $body['chargeId'], $uri);

            unset($body['chargeId']);
        }

        $this->fullUri  = $transferObject->getUri() . $uri;
        $this->body     = $body;
    }
1183668
public function resolveFromInput(InputInterface $input): void
    {
        $this->isDryRun = (bool) $input->getOption(Option::OPTION_DRY_RUN);
        $this->source = (array) $input->getArgument(Option::SOURCE);
        $this->hideAutoloadErrors = (bool) $input->getOption(Option::HIDE_AUTOLOAD_ERRORS);
        $this->withStyle = (bool) $input->getOption(Option::OPTION_WITH_STYLE);
    }
214347
public function toTransactionResponseTransfer(StreamInterface $response): TransferInterface
    {
        $decryptedResponse = $this->decryptResponse($response);

        return $this->getResponseTransfer($decryptedResponse);
    }
839861
private function getPassword(InputInterface $input, OutputInterface $output)
    {
        if ($pass = $input->getOption('pass')) {
            return $pass;
        }
        if ($pass = $this->getTransifexConfigValue('/pass')) {
            $this->writelnVerbose($output, 'Using transifex password specified in config.');

            return $pass;
        }
        if ($pass = getenv('transifexpass')) {
            $this->writelnVerbose($output, 'Using transifex password specified in environment.');

            return $pass;
        }
        if ($input->isInteractive()) {
            /** @var \Symfony\Component\Console\Helper\QuestionHelper $dialog */
            $dialog = $this->getHelperSet()->get('question');
            if ($pass = $dialog->ask($input, $output, (new Question('Transifex password:'))->setHidden(true))) {
                return $pass;
            }
        }

        throw new \RuntimeException('Error: you must either specify a password on the commandline or run interactive.');
    }
777573
protected function _resolveDefinition(
        DefinitionInterface $definition, array $parameters = [])
    {
        $entryName = $definition->getName();
        $definitionResolver = $this->_getDefinitionResolver($definition);

        try {
            $value = $definitionResolver->resolve($definition, $parameters);
        } catch (\Exception $exception) {
            throw new DependencyException(
                "An error occurred while resolving " .
                "entry '{$entryName}': " . $exception->getMessage(),
                0,
                $exception
            );
        }

        return $value;
    }
1009172
public function resolve($input)
    {
        if (!\is_array($input)) {
            $input = [$input];
        }

        if (!isset($input[0]) || !isset($input[1])) {
            $optionResolver = new OptionsResolver();
            $optionResolver->setDefaults([null, []]);
            $input = $optionResolver->resolve($input);
        }

        $alias = $input[0];
        $funcArgs = $input[1];

        $solution = $this->getSolution($alias);

        if (null === $solution) {
            throw new UnresolvableException($this->unresolvableMessage($alias));
        }

        $options = $this->getSolutionOptions($alias);
        $func = [$solution, $options['method']];

        return \call_user_func_array($func, $funcArgs);
    }
602882
public function transferCredit(Transfer $transfer)
    {
        $transfer->setRequiredFields(array(
            'amount',
            'linkedAccount',
            'merchantRefNum',
        ));
        $transfer->setOptionalFields(array(
            'detail',
            'dupCheck',
        ));

        $request = new Request(array(
               'method' => Request::POST,
               'uri' => $this->prepareURI($this->creditPath),
               'body' => $transfer
           ));

        $response = $this->client->processRequest($request);

        return new Transfer($response);
    }
1229326
public function transform(FormInterface $form)
    {
        return new ConfirmationQuestion($this->questionFrom($form), $this->defaultValueFrom($form));
    }
1101867
public function createDocument(TransferInterface $transfer, $containerName)
    {
        $this->checkTransferMethods($transfer);

        if ($transfer->getFileName() === null) {
            throw new NoFileNameSetException(
                'No filename defined for Transfer.'
            );
        }

        $fileName = $transfer->getFileName();
        $relativePath = $transfer->getRelativePath();

        if (!$this->documentExists($transfer, $containerName)) {

            $fullFilePath = $this->createFullFilePath($fileName);
            $this->renderFile($transfer, $containerName, $fullFilePath);

            $fileInfo = new \SplFileInfo($fullFilePath);

            $this->fileUploadFacade->saveFile($containerName, $fileInfo, $relativePath);
        }

        return $transfer;
    }
182258
public function readDocument(TransferInterface $transfer, $containerName)
    {
        $this->checkTransferMethods($transfer);

        $fileName = $transfer->getFileName();
        $relativePath = $transfer->getRelativePath();

        if (!$this->documentExists($transfer, $containerName)) {
            throw new NoDocumentFoundException(
                sprintf(
                    'No File "%s" found for type %s',
                    $fileName,
                    $containerName
                )
            );
        }

        return $this->fileUploadFacade->readFileStream($containerName, $fileName, $relativePath);
    }
114919
public function resolve($event)
    {
        if ($event instanceof FilterUserResponseEvent) {
            return $this->getEventDetailsArray($event->getUser()->getUsername());
        }

        return null;
    }
206916
protected function resolveCallable($callable)
    {
        if (!$this->container instanceof ContainerInterface) {
            return $callable;
        }

        /** @var CallableResolverInterface $resolver */
        $resolver = $this->container->get('callableResolver');

        return $resolver->resolve($callable);
    }
685102
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $orgSource = $input->getOption('source-organization');
        if (!$orgSource = $this->resolveOrganizationName($orgSource, $output)) {
            return -1;
        }

        $orgDest = $input->getArgument('dest-organization');
        if (!$orgDest = $this->resolveOrganizationName($orgDest, $output)) {
            return -1;
        }

        if ($orgSource === $orgDest) {
            $output->writeln($this->formatterHelper->formatBlock([
                'Error!',
                'The organizations to copy images between must not be the same: "'.$orgSource.'"!',
            ], 'error', true));

            return -1;
        }

        $stopOnError = false;
        $clonedImages = 0;

        $client = $this->clientProvider->getImageClient($orgSource);

        $limit = 100;
        $images = $client->searchSourceImages([], [], $limit);
        $output->writeln('Reading images to be cloned from <info>'.$orgSource.'</info> to <info>'.$orgDest.'</info>');

        while ($images->count() > 0) {
            /** @var SourceImage $image */
            $hashes = [];
            foreach ($images->getSourceImages() as $image) {
                $hashes[] = $image->hash;
            }

            try {
                $output->writeln('Copying '.\count($hashes).' images from <comment>'.$image->organization.'</comment> to <comment>'.$orgDest.'</comment>');

                $hashes = $this->copyImages($orgDest, $orgSource, $hashes, $client);
                $total = \count($hashes['existing']) + \count($hashes['created']);
                $output->writeln($total.' images copied from <comment>'.$image->organization.'</comment> to <comment>'.$orgDest.'</comment> ('.
                    \count($hashes['existing']).' existing, '.\count($hashes['created']).' newly created).'
                );

                $clonedImages += $total;
            } catch (\Exception $e) {
                $output->writeln('');
                $output->writeln($this->formatterHelper->formatBlock([
                    'Error: Exception',
                    $e->getMessage(),
                ], 'error', true));
                if ($stopOnError) {
                    return -1;
                }
            }
            $images = $client->searchSourceImages([], [], $limit, $images->getCursor());
        }

        // Avoid further processing if no images have been loaded.
        if (0 == $clonedImages) {
            $output->write('No Image found in <info>'.$orgSource.'</info> organization.');

            return 0;
        }

        $output->writeln('');
        $output->writeln('Cloned images: <info>'.$clonedImages.'</info>');

        return 0;
    }