Displays Syrup components with their recent version

@return JsonResponse
501327
public function indexAction()
    {
        $rootPath = str_replace('web/../', '', ROOT_PATH);

        $filepath = $rootPath . '/../../composer/installed.json';

        if (!file_exists($filepath)) {
            $filepath = $rootPath . '/vendor/composer/installed.json';
        }

        $installedJson = file_get_contents($filepath);

        $jsonDecoder = new JsonDecode(true);
        $installedArr = $jsonDecoder->decode($installedJson, JsonEncoder::FORMAT);

        $syrupComponents = array();
        foreach ($installedArr as $package) {
            $nameArr = explode("/", $package['name']);

            if ($nameArr[0] == 'syrup' || $nameArr[0] == 'keboola') {
                $syrupComponents[$package['name']] = $package['version'];
            }
        }

        return new JsonResponse(array(
            "host"          => gethostname(),
            "components"    => $syrupComponents,
            "documentation" => "http://documentation.keboola.com/syrup"
        ));
    }
35079
public function toJson()
    {
        $json = array();
        $json['id'] = $this->id;
        $json['from'] = $this->from;
        $json['color'] = $this->color;
        $json['message'] = $this->message;
        $json['notify'] = $this->notify;
        $json['message_format'] = $this->messageFormat;
        $json['date'] = $this->date;

        return $json;

    }
638243
public function jsonSerialize()
    {
        $feedbacks = [];

        foreach ($this->feedbacks as $feedback) {
            $feedbacks[] = $feedback->serialize($this->controllerContext);
        }

        return [
            'timestamp' => new \DateTime(),
            'feedbacks' => $feedbacks
        ];
    }
24947
public function actionUpdate()
    {
        $result = ['error' => Yii::t('podium/view', 'Error')];

        if (Yii::$app->request->isPost) {
            $result = (new Update())->nextStep();
        }
        return Json::encode($result);
    }
179146
public function index()
    {
        $this->requireAdmin();

        $json = $this->getComposerJson();
        $this->view->installedPackages = $json['require'];

        $pluginInfo = new PluginInformationCollection();
        $pluginInfo->add(FilesPluginInformation::newFromDir(
            PHPCI_DIR . "PHPCI/Plugin/"
        ));
        $pluginInfo->add(ComposerPluginInformation::buildFromYaml(
            PHPCI_DIR . "vendor/composer/installed.json"
        ));

        $this->view->plugins = $pluginInfo->getInstalledPlugins();

        $this->layout->title = Lang::get('plugins');

        return $this->view->render();
    }
778561
public function index($version = null)
    {
        try {
            $request = new ServiceRequest();
            if (!empty($version)) {
                $request->setApiVersion($version);
            }

            Log::info('[REQUEST]', [
                'API Version' => $request->getApiVersion(),
                'Method'      => $request->getMethod(),
                'Service'     => null,
                'Resource'    => null
            ]);

            Log::debug('[REQUEST]', [
                'Parameters' => json_encode($request->getParameters(), JSON_UNESCAPED_SLASHES),
                'API Key'    => $request->getHeader('X_DREAMFACTORY_API_KEY'),
                'JWT'        => $request->getHeader('X_DREAMFACTORY_SESSION_TOKEN')
            ]);

            $limitedFields = ['id', 'name', 'label', 'description', 'type'];
            $fields = \Request::query(ApiOptions::FIELDS);
            if (!empty($fields) && !is_array($fields)) {
                $fields = array_map('trim', explode(',', trim($fields, ',')));
            } elseif (empty($fields)) {
                $fields = $limitedFields;
            }
            $fields = array_intersect($fields, $limitedFields);

            $group = \Request::query('group');
            $type = \Request::query('type');
            if (!empty($group)) {
                $results = ServiceManager::getServiceListByGroup($group, $fields, true);
            } elseif (!empty($type)) {
                $results = ServiceManager::getServiceListByType($type, $fields, true);
            } else {
                $results = ServiceManager::getServiceList($fields, true);
            }
            $services = [];
            foreach ($results as $info) {
                // only allowed services by role here
                if (Session::allowsServiceAccess(array_get($info, 'name'))) {
                    $services[] = $info;
                }
            }

            if (!empty($group)) {
                $results = ServiceManager::getServiceTypes($group);
            } elseif (!empty($type)) {
                $results = [ServiceManager::getServiceType($type)];
            } else {
                $results = ServiceManager::getServiceTypes();
            }
            $types = [];
            foreach ($results as $type) {
                $types[] = [
                    'name'        => $type->getName(),
                    'label'       => $type->getLabel(),
                    'group'       => $type->getGroup(),
                    'description' => $type->getDescription()
                ];
            }
            $response = ResponseFactory::create(['services' => $services, 'service_types' => $types]);
            Log::info('[RESPONSE]', ['Status Code' => $response->getStatusCode(), 'Content-Type' => $response->getContentType()]);

            return ResponseFactory::sendResponse($response, $request);
        } catch (\Exception $e) {
            return ResponseFactory::sendException($e, (isset($request) ? $request : null));
        }
    }
1226602
private function getLastJsonResponse(): stdClass
    {
        if (null === ($decoded = json_decode($this->restContext->getMink()->getSession()->getDriver()->getContent()))) {
            throw new \RuntimeException('JSON response seems to be invalid');
        }

        return $decoded;
    }
703043
public function showComponents()
    {
        $components = Component::with('group')->orderBy('order')->orderBy('created_at')->get();

        $this->subMenu['components']['active'] = true;

        return View::make('dashboard.components.index')
            ->withPageTitle(trans_choice('dashboard.components.components', 2).' - '.trans('dashboard.dashboard'))
            ->withComponents($components)
            ->withSubMenu($this->subMenu);
    }
1167419
private Response assertOutdatedStatus(boolean outdated) throws JSONException {
        Response response = httpGet("keys/" + keyName);
        JSONObject actual = new JSONObject(response.asString());
        Assertions.assertThat(actual.getBoolean("outdated")).isEqualTo(outdated);
        return response;
    }
778134
public function debug()
    {
        // call TransformationMixin functions
        $json_response = $this->sendDebug($this->transform_url,
            $this->api_key, $this->security);

        return $json_response;
    }
873146
public function readCampaigns()
    {
        $response = new HTTPResponse();
        $response->addHeader('Content-Type', 'application/json');
        $hal = $this->getListResource();
        $response->setBody(json_encode($hal));
        return $response;
    }
344415
public function updateDatabase()
    {
        $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');
        $json = $storageRepository->load();
        $sqlStatements = $this->getSqlByConfiguration($json);
        if (count($sqlStatements) > 0) {
            $response = $this->performDbUpdates($sqlStatements);
        }
        return $response;
    }
1128103
public function indexAction()
    {
        $response = $this->response;

        $mainPage = new \stdClass();
        $mainPage->services = $this->determineServices(
            $this->restUtils->getOptionRoutes()
        );

        $mainPage->thirdparty = $this->registerThirdPartyServices();

        $response->setContent(json_encode($mainPage));
        $response->setStatusCode(Response::HTTP_OK);
        $response->headers->set('Link', $this->prepareLinkHeader());

        // todo: make sure, that the correct content type is set.
        // todo: this should be covered by a kernel.response event listener?
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
973060
public function allAction()
    {
        $repository = $this->container->get('request')->get('repository');
        $response = new JsonResponse();

        if (!$this->isValidRepositoryName($repository)) {
            $response->setData(array('msg' => 'Package not found. Please check the package name. eg. (symfony/symfony)'));
            $response->setStatusCode(404);

            return $response;
        }

        try {
            $badges = $this->container->get('snippet_generator')->generateAllSnippets($repository);
            $response->setData($badges);
        } catch (ClientErrorResponseException $e) {
            $response->setData(array('msg' => 'Package not found. Please check the package name. eg. (symfony/symfony)'));
            $response->setStatusCode(404);
        } catch (\Exception $e) {
            $response->setData(array('msg' => 'Server Error'));
            $response->setStatusCode(500);
        }

        return $response;
    }
1075611
private function getJsonVersioner()
    {
        if (!$this->jsonVersioner) {
            $this->jsonVersioner = new ChainVersioner(array(
                // check the schema of the "$schema" field by default
                new SchemaUriVersioner(),
                // fall back to the "version" field for 1.0
                new VersionFieldVersioner(),
            ));
        }

        return $this->jsonVersioner;
    }
348116
public function getStaticVersions(): array
	{
		$result = false;
		try
		{
			// Fetch StaticData from JSON files
			$result = DataDragonAPI::getStaticVersions();
			if (!$result) throw new ServerException("StaticData failed to be loaded.");

			$this->result_data = $result;
		}
		catch (DataDragonExceptions\ArgumentException $ex)
		{
			throw new RequestException($ex->getMessage(), $ex->getCode());
		}
		finally
		{
			// Return data
			return $result;
		}
	}
1265575
public function index()
    {
        $options = $this->getParams('offset', 'limit', 'includes', 'order_by');

        $orders = Subbly::api('subbly.order')->all($options);

        return $this->jsonCollectionResponse('orders', $orders);
    }