Return a stack.

@param string $stackName    Stack name
@param string $organization Optional organization name

@throws GuzzleException
@throws \RuntimeException

@return Stack
198345
public function getStack($stackName, $organization = '')
    {
        $contents = $this
            ->call('GET', implode('/', [self::STACK_RESOURCE, $this->getOrganizationName($organization), $stackName]))
            ->getBody()
            ->getContents();

        return Stack::createFromJsonResponse($contents);
    }
578500
static private function _stackMiddleware(Callable $callback) {
        if (self::$_busy) {
            // Make sure it's not busy before adding something.
            throw new \Lollipop\Exception\HTTP\Router('Cannot add new middleware while dequeue in progress');
        }
        
        if (is_null(self::$_kernel)) {
            $active = self::$_active_route;
            $top = function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) use ($active) {
                return Route::resolve($active['callback'], $req, $res, $active['arguments']);
            };
            self::$_kernel = $top;
        }

        $next = self::$_kernel;

        // The update the top function
        self::$_kernel = function(\Lollipop\HTTP\Request $req, \Lollipop\HTTP\Response $res) use ($callback, $next) {
            // Pass the last function
            $new_response = call_user_func($callback, $req, $res, $next);
            
            if ($new_response instanceof \Lollipop\HTTP\Response) {
                $res = $new_response;
            } else {
                $res->set($new_response);
            }
            
            // Return the new result
            return $res;
        };
    }
1076227
public static function findingName($organization, $source, $finding)
    {
        return self::getFindingNameTemplate()->render([
            'organization' => $organization,
            'source' => $source,
            'finding' => $finding,
        ]);
    }
381621
public DbOrganization getOrganization(final String organizationId) {
        final DbOrganization dbOrganization = repositoryHandler.getOrganization(organizationId);

        if(dbOrganization == null){
            throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
                    .entity("Organization " + organizationId + " does not exist.").build());
        }

        return dbOrganization;
    }
1063954
public function getOrganizationMembership(string $org, string $username): array
    {
        $this->getApi()->setAccept('application/vnd.github.moondragon+json');

        return $this->getApi()->request($this->getApi()->sprintf('/orgs/:org/memberships/:username', $org, $username));
    }
212753
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
    {
        /** @var DocumentManager $manager */
        $manager = $this->managerRegistry->getManagerForClass($resourceClass);

        $repository = $manager->getRepository($resourceClass);
        if (!$repository instanceof DocumentRepository) {
            throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $resourceClass, DocumentRepository::class));
        }

        $aggregationBuilder = $repository->createAggregationBuilder();
        foreach ($this->collectionExtensions as $extension) {
            $extension->applyToCollection($aggregationBuilder, $resourceClass, $operationName, $context);

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

        return $aggregationBuilder->hydrate($resourceClass)->execute();
    }
1168472
public function getOrganization($organization = '')
    {
        $contents = $this
            ->call('GET', self::ORGANIZATION_RESOURCE.'/'.$this->getOrganizationName($organization))
            ->getBody()
            ->getContents()
        ;

        return Organization::createFromJsonResponse($contents);
    }
1298442
public function createFork(string $organization = ''): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/forks',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo()), Request::METHOD_POST,
            ['organization' => $organization]);
    }
135755
public function setOrganization(\WobbleCode\UserBundle\Model\OrganizationInterface $organization)
    {
        $this->organization = $organization;
        return $this;
    }
503097
public static function run(array $stack, ServerRequestInterface $request = null): ResponseInterface
    {
        if ($request === null) {
            $request = Factory::createServerRequest('GET', '/');
        }

        return (new static($stack))->dispatch($request);
    }
634447
public function createOrganizationAdminInvite($organizationUuid, $email)
    {
        $options = [
            'form_params' => [
                'email' => $email,
            ],
        ];

        return new OperationResponse(
            $this->connector->request('post', "/teams/${organizationUuid}/invites", $this->query, $options)
        );
    }
1119679
public function getOrganizationProjects(string $organization): ResponseInterface
    {
        // This API endpoint uses the newer `api.transifex.com` subdomain, only change if the default www was given
        $currentBaseUri = $this->getOption('base_uri');

        if (!$currentBaseUri || $currentBaseUri === 'https://www.transifex.com') {
            $this->setOption('base_uri', 'https://api.transifex.com');
        }

        try {
            return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/organizations/$organization/projects/")));
        } finally {
            $this->setOption('base_uri', $currentBaseUri);
        }
    }
729234
public function retrieveConfig(string $stackName) : array {


		$stackId = $this->getStackIdByName($stackName);

		$url = implode('/', [
			$this->account->getUrl(),
			'environments',
			$stackId,
			'?action=exportconfig'
		]);

		$headers = [];
		$this->addAuthHeader($headers);

		$jsonContent = json_encode([
			'serviceIds' => []
		]);
		$data = $this->apiService->post($url, $jsonContent, $headers, [200]);

		$decodedData = json_decode($data, true);
		$dockerCompose = $decodedData['dockerComposeConfig'];
		$rancherCompose = $decodedData['rancherComposeConfig'];

		// Empty files are not sent empty so we force them to be
		if(substr($dockerCompose, 0, 2) === '{}')
			$dockerCompose = '';
		if(substr($rancherCompose, 0, 2) === '{}')
			$rancherCompose = '';

		return [$dockerCompose, $rancherCompose];
	}
173500
public static function getByName($stackName, $cvID = 'RECENT', TreeInterface $site = null, $multilingualContentSource = self::MULTILINGUAL_CONTENT_SOURCE_CURRENT)
    {
        $c = Page::getCurrentPage();
        if (is_object($c) && (!$c->isError())) {
            $identifier = sprintf('/stack/name/%s/%s/%s/%s', $stackName, $c->getCollectionID(), $cvID, $multilingualContentSource);
            $cache = Core::make('cache/request');
            $item = $cache->getItem($identifier);
            if (!$item->isMiss()) {
                $cID = $item->get();
            } else {
                $item->lock();
                $db = Database::connection();
                $ms = false;
                $detector = Core::make('multilingual/detector');
                if ($detector->isEnabled()) {
                    $ms = self::getMultilingualSectionFromType($multilingualContentSource);
                }
                $sql = 'select cID from Stacks where stName = ?';
                $q = [$stackName];
                if ($ms) {
                    $sql .= ' and (stMultilingualSection = ? or stMultilingualSection = 0)';
                    $q[] = $ms->getCollectionID();
                } else {
                    $sql .= ' and stMultilingualSection = 0';
                }
                //$sql .= ' and siteTreeID = ?';
                if ($ms) {
                    $sql .= ' order by stMultilingualSection desc';
                }
                $sql .= ' limit 1';
                /*if (!is_object($site)) {
                    $site = \Core::make('site')->getSite();
                }
                if ($site instanceof Site) {
                    $q[] = $site->getDefaultLocale()->getSiteTree()->getSiteTreeID();
                } else {
                    $q[] = $site->getSiteTreeID();
                }*/
                $cID = $db->fetchColumn($sql, $q);
                $cache->save($item->set($cID));
            }
        } else {
            $db = Database::connection();
            $cID = $db->fetchColumn(
                'select cID from Stacks where stName = ? and stMultilingualSection = 0',
                [$stackName]
            );
        }

        return $cID ? static::getByID($cID, $cvID) : null;
    }
821058
public static function stack(string $stack): string
    {
        $content = implode('', self::$stacks[$stack] ?? []);

        self::$stacks[$stack] = [];

        return $content;
    }
950869
public static Stack getStack() {
        Stack stack = interceptionContexts.get();
        if (stack == null) {
            stack = new Stack(interceptionContexts);
            interceptionContexts.set(stack);
        }
        return stack;
    }
1172881
protected static function getConsoleDir(Event $event, $actionName)
    {
        $options = static::getOptions($event);

        if (static::useNewDirectoryStructure($options)) {
            if (!static::hasDirectory($event, 'symfony-bin-dir', $options['symfony-bin-dir'], $actionName)) {
                return;
            }

            return $options['symfony-bin-dir'];
        }

        if (!static::hasDirectory($event, 'symfony-app-dir', $options['symfony-app-dir'], 'execute command')) {
            return;
        }

        return $options['symfony-app-dir'];
    }