@Route("/snippet/all/",
name="pugx_snippet_all"
)
@Method({"GET"})
@Cache(smaxage="3600", maxage="3600", public=true)

@return JsonResponse
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;
    }
1330794
public function wantsJson()
    {
        $acceptable = $this->getAcceptableContentTypes();
        return (isset($acceptable[0]) && (strpos($acceptable[0], '/json') !== false || strpos($acceptable[0], '+json') !== false));
    }
667461
def all(self):
        

        response = self._get_json(HTTPMethods.GET, self.saved_query_url, self._get_master_key())

        return response
551394
public function postDispatch() {
        parent::postDispatch();
        if (!empty($this->_postModifyMethods)) {
            $response = Zend_Json::decode($this->view->response, Zend_Json::TYPE_ARRAY);
            $modifiedResponse = array();
            /**
             * Check if this was a batch request. In that case the array is a plain array of
             * arrays. If not, there will be a 'jsonrpc' key in the root of the array.
             */
            $batch = !array_key_exists('jsonrpc', $response);
            if (!$batch) {
                $response = array($response);
            }
            /**
             * Post modify methods are recorded from $this:preDispatch()
             */
            foreach ($this->_postModifyMethods as $i => $postMethod) {
                if (!empty($response[$i]) && !empty($this->_originalRequests[$i])) {
                    $modifyMethod = '_modifyAfter' . ucfirst($postMethod);
                    $response[$i] = $this->{$modifyMethod}(
                        $response[$i],
                        $this->_originalRequests[$i]
                    );
                }
            }
            if ($batch) {
                $this->view->response = Zend_Json::encode($response);
            } else {
                $this->view->response = Zend_Json::encode($response[0]);
            }
        }
        $this->_toggleCache(true);
    }
406884
public function jsonConfig()
    {
        $request = $this->request;

        // Remove null values and normalise leading dot
        $allExts = $request->getVar('allowedExtensions') ?
            explode(',', $request->getVar('allowedExtensions')) :
            File::config()->allowed_extensions;

        $exts = array_map(function ($item) {
            return $item[0] == '.' ? $item : '.' . $item;
        }, array_filter(
            $allExts,
            'strlen'
        ));

        $currentLinkParts = parse_url(Controller::join_links(Director::baseURL(), $this->Link()));
        $types = explode(',', $request->getVar('allowedTypes'));

        return Convert::array2json(array(
            'baseRoute' => $currentLinkParts['path'],
            'maxFilesize' => FileAttachmentField::get_filesize_from_ini(),
            'allowedExtensions' => implode(',', $exts),
            'thumbnailsDir' => DROPZONE_DIR . '/images/file-icons',
            'langNewFolder' => _t('AssetAdmin.NEWFOLDER', 'NewFolder'),
            'iconSize' => self::ICON_SIZE,
            'thumbnailWidth' => self::IMAGE_WIDTH,
            'thumbnailHeight' => self::IMAGE_HEIGHT,
            'defaultSort' => $this->config()->default_sort,
            'defaultView' => $this->config()->default_view,
            'maxCacheSize' => $this->config()->max_cache_size,
            'folderExtension' => self::FOLDER_EXTENSION,

            'allowSelection' => (boolean)$request->getVar('allowSelection'),
            'maxSelection' => (int)$request->getVar('maxSelection'),
            'canUpload' => (boolean)$request->getVar('canUpload'),
            'canDelete' => (boolean)$request->getVar('canDelete'),
            'canEdit' => (boolean)$request->getVar('canEdit'),
            'canCreateFolder' => (boolean)$request->getVar('canCreateFolder'),
            'allowedTypes' => !empty($types) ? $types : null
        ));
    }
1209814
protected function getJson()
    {
        if ($this->json) {
            return $this->json;
        }
        $composer = Util::joinPaths($this->getPath(), 'composer.json');
        $file = new JsonFile($composer);
        $this->json = $file->read();
        return $this->json;
    }
1167663
public function ldJson()
    {
        $attributes = [
            '@context' => 'http://schema.org',
            '@type' => 'WebSite',
            'url' => $this->Url->build('/', true),
            'potentialAction' => [
                '@type' => 'SearchAction',
                'query-input' => 'required name=search_term_string',
                'target' => $this->Url->build([
                    'plugin' => 'Wasabi/Cms',
                    'controller' => 'Frontend/Search',
                    'action' => 'search',
                    'language_id' => Wasabi::contentLanguage()->id
                ], true) . '?q={search_term_string}'
            ]
        ];

        if (!empty(WasabiCms::$instanceName)) {
            $attributes['name'] = WasabiCms::$instanceName;
        }

        $sameAsKeys = [
            'Settings.Cms.SEO.Social.facebook_url',
            'Settings.Cms.SEO.Social.instagram_url',
            'Settings.Cms.SEO.Social.linkedin_url',
            'Settings.Cms.SEO.Social.myspace_url',
            'Settings.Cms.SEO.Social.pinterest_url',
            'Settings.Cms.SEO.Social.youtube_url',
            'Settings.Cms.SEO.Social.googleplus_url'
        ];
        $sameAs = [];

        foreach ($sameAsKeys as $key) {
            $setting = Configure::read($key);
            if (!empty($setting)) {
                $sameAs[] = $setting;
            }
        }

        $twitterName = Configure::read('Settings.Cms.SEO.Social.twitter_username');
        if (!empty($twitterName)) {
            $sameAs[] = 'https://twitter.com/' . $twitterName;
        }

        if (!empty($sameAs)) {
            $attributes['sameAs'] = $sameAs;
        }

        return '<script type="application/ld+json">' . json_encode($attributes) . '</script>';
    }
56615
public function getJson()
    {
        if (empty($this->json_loaded)) {
            if ($this->getBody() && $this->isJson()) {
                $this->json = json_decode($this->getBody(), true);

                if (json_last_error()) {
                    throw new RuntimeException('Failed to parse JSON. Reason: ' . json_last_error_msg());
                }
            }

            $this->json_loaded = true;
        }

        return $this->json;
    }
721941
public function cgetAction()
    {
        /** @var WebspaceManagerInterface $webspaceManager */
        $webspaceManager = $this->get('sulu_core.webspace.webspace_manager');

        $localizations = [];
        $locales = [];

        /** @var Webspace $webspace */
        foreach ($webspaceManager->getWebspaceCollection() as $webspace) {
            $i = 0;
            foreach ($webspace->getAllLocalizations() as $localization) {
                if (!in_array($localization->getLocale(), $locales)) {
                    $locales[] = $localization->getLocale();
                    $localizations[] = [
                        'localization' => $localization->getLocale(),
                        'name' => $localization->getLocale(Localization::DASH),
                        'id' => $i++,
                    ];
                }
            }
        }

        $data = [
            '_embedded' => $localizations,
            'total' => count($localizations),
        ];

        return new JsonResponse($data);
    }
951830
public function getFullExperimentsAction()
    {
        $experimentsArray = [];
        /** @var SettingsManager $manager */
        $manager = $this->get('ongr_settings.settings_manager');
        $experiments = $manager->getAllExperiments();
        $activeExperiments = $manager->getActiveExperiments();

        /** @var Setting $experiment */
        foreach ($experiments as $experiment) {
            $experiment = $experiment->getSerializableData();
            $experiment['active'] = in_array($experiment['name'], $activeExperiments);
            $experimentsArray[] = $experiment;
        }

        return new JsonResponse(
            ['count' => count($experiments), 'documents' => $experimentsArray]
        );
    }
638508
public function all(Request $request)
    {
        $app = $this->app;

        $store = $this->getStore();

        return $app->json(array(
            'success' => true,
            'results' => $store->findAll(
                [],
                $request->get('sort', $this->sort)
            )
        ));
    }
1242732
def all(self, start=0, amount=10):
        
        return self._get_json('user/all', start=start, amount=amount)
1019960
public function actionJson()
    {
        /** @var \yii\web\Response */
        $response = \Yii::$app->getResponse();
        
        if (!is_readable($this->module->swaggerPath)) {
            throw new NotFoundHttpException();
        }
        
        // Read source json file
        $json = file_get_contents($this->module->swaggerPath);
    
        // Do replacements
        if (is_array($this->module->swaggerReplace)) {
            foreach ($this->module->swaggerReplace as $find => $replace) {
                if (is_callable($replace)) {
                    $replaceText = call_user_func($replace);
                } else {
                    $replaceText = (string) $replace;
                }
                $json = mb_ereg_replace((string)$find, $replaceText, $json);
            }
        }
        
        // Override default response formatters
        // To avvoid json format modification
        $response->format = Response::FORMAT_RAW;
        $response->getHeaders()->set('Content-Type', 'application/json; charset=UTF-8');
        
        // Trigger events
        $event = new BeforeJsonEvent;
        $event->responseText = $json;
        $this->module->trigger(self::EVENT_BEFORE_JSON, $event);
        
        return $event->responseText;
    }
344783
private function getCache()
    {
        $cachePath = $this->getCachePath();

        if (!$this->files->exists($cachePath)) {
            $this->createCache();

            $this->optimize();
        }

        return collect(json_decode($this->files->get($cachePath), true));
    }
704468
def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
        
        # Only API.spaces and API.event should not provide
        # the `space argument
        if space is None and model not in (Space, Event):
            raise Exception(
                'In general, `API._get_json` should always '
                'be called with a `space` argument.'
            )

        if not extra_params:
            extra_params = {}

        # Handle pagination for requests carrying large amounts of data
        extra_params['page'] = extra_params.get('page', 1)

        # Generate the url to hit
        url = '{0}/{1}/{2}.json?{3}'.format(
            settings.API_ROOT_PATH,
            settings.API_VERSION,
            rel_path or model.rel_path,
            urllib.urlencode(extra_params),
        )

        # If the cache is being used and the url has been hit already
        if self.cache_responses and url in self.cache:
            response = self.cache[url]
        else:
            # Fetch the data
            headers = {
                'X-Api-Key': self.key,
                'X-Api-Secret': self.secret,
            }
            response = self.session.get(url=url, headers=headers)
            # If the cache is being used, update it
            if self.cache_responses:
                self.cache[url] = response

        if response.status_code == 200:  # OK
            results = []
            json_response = response.json()
            for obj in json_response:
                instance = model(data=obj)
                instance.api = self
                if space:
                    instance.space = space
                results.append(instance)
            # If it looks like there are more pages to fetch,
            # try and fetch the next one
            per_page = extra_params.get('per_page', None)
            if (
                get_all
                and per_page
                and len(json_response)
                and per_page == len(json_response)
            ):
                extra_params['page'] += 1
                results = results + self._get_json(model, space, rel_path, extra_params, get_all=get_all)
            return results
        elif response.status_code == 204:  # No Content
            return []
        else:  # Most likely a 404 Not Found
            raise Exception(
                'Code {0} returned from `{1}`. Response text: "{2}".'.format(
                    response.status_code,
                    url,
                    response.text
                )
            )
109871
private function generateSnippets()
    {
        if ($this->snippetsGenerated) {
            return null;
        }

        $snippetsSet = array();
        foreach ($this->undefinedSteps as $i => $undefinedStep) {
            $snippet = $this->generateSnippet($undefinedStep->getEnvironment(), $undefinedStep->getStep());

            if (!$snippet) {
                continue;
            }

            if (!isset($snippetsSet[$snippet->getHash()])) {
                $snippetsSet[$snippet->getHash()] = array();
            }

            $snippetsSet[$snippet->getHash()][] = $snippet;
            unset($this->undefinedSteps[$i]);
        }

        $this->snippets = array_values(
            array_map(
                function (array $snippets) {
                    return new AggregateSnippet($snippets);
                },
                $snippetsSet
            )
        );
        $this->undefinedSteps = array_values($this->undefinedSteps);
        $this->snippetsGenerated = true;
    }
615442
protected function getSchema()
    {
        if (file_exists(__DIR__.'/../all.json')) {
            return json_decode(file_get_contents(__DIR__.'/../all.json'), true);
        }

        echo "Getting schema\n";

        $schema = [
            'datatypes' => [],
            'properties' => [],
            'types' => [],
        ];

        $client = new Client(['base_uri' => 'https://schema.org']);
        $response = $client->get('/docs/full.html');
        $crawler = new Crawler($response->getBody()->__toString());

        $dataTypes = $crawler->filter('#datatype_tree a');
        foreach ($dataTypes as $index => $dataType) {
            echo '['.($index + 1).'/'.$dataTypes->count().'] ';
            if (strpos($dataType->getAttribute('class'), 'ext') !== false) {
                echo 'Skipping extension datatype: '.$dataType->textContent."\n";
                continue;
            }

            echo 'Getting datatype: '.$dataType->textContent."\n";
            $schema['datatypes'][$dataType->textContent] = $this->getDataType($client, $dataType->getAttribute('href'));
        }

        $types = $crawler->filter('#thing_tree a');
        foreach ($types as $index => $type) {
            if (!isset($schema['types'][$type->textContent]) && substr($type->getAttribute('href'), 0, 1) !== '#') {
                echo '['.($index + 1).'/'.$types->count().'] ';
                if (strpos($type->getAttribute('class'), 'ext') !== false) {
                    echo 'Skipping extension type: '.$type->textContent."\n";
                    continue;
                }

                echo 'Getting type: '.$type->textContent."\n";
                $schema['types'][$type->textContent] = $this->getType($client, $type->getAttribute('href'));
            }
        }

        $specificProperties = [];
        foreach ($schema['types'] as $type) {
            foreach ($type['specific_properties'] as $specificProperty) {
                if (!isset($schema['properties'][$specificProperty])) {
                    $specificProperties[$specificProperty] = $specificProperty;
                }
            }
        }

        $specificPropertiesCount = count($specificProperties);
        foreach (array_values($specificProperties) as $index => $specificProperty) {
            echo '['.($index + 1).'/'.$specificPropertiesCount.'] Getting property: '.$specificProperty."\n";
            try {
                $schema['properties'][$specificProperty] = $this->getProperty($client, '/'.$specificProperty);
            } catch (\InvalidArgumentException $exception) {
                echo '   Failed: '.$exception->getMessage()."\n";
                echo "   Skipping...\n";
            }
        }

        $enumerationMembers = [];
        foreach ($schema['types'] as $type) {
            foreach ($type['enumeration_members'] as $enumerationMember) {
                if (!isset($schema['types'][$enumerationMember])) {
                    $enumerationMembers[$enumerationMember] = $enumerationMember;
                }
            }
        }

        $enumerationMembersCount = count($enumerationMembers);
        foreach (array_values($enumerationMembers) as $index => $enumerationMember) {
            echo '['.($index + 1).'/'.$enumerationMembersCount.'] Getting extra enumeration member: '.$enumerationMember."\n";
            $schema['types'][$enumerationMember] = $this->getType($client, '/'.$enumerationMember);
        }

        echo "Getting schema done!\n\n";

        file_put_contents(__DIR__.'/../all.json', json_encode($schema));

        return $schema;
    }