Get form structure as json object

@param string $key
@param string|null $type
@return JsonResponse
@throws \Illuminate\Contracts\Container\BindingResolutionException
@throws \ReflectionException
15839
public function getStructure(string $key, string $type = null): JsonResponse
    {
        try {
            $form = $this->formManager->getForm($key, $type);
        } catch (HCException $exception) {
            return $this->response->error($exception->getMessage());
        }

        return $this->response->success('OK', $form);
    }
1182092
public function getElementsWhichUseField($key, $type = "tt_content")
    {
        $storage = $this->storageRepository->load();

        $elementsInUse = array();
        if ($storage[$type]["elements"]) {
            foreach ($storage[$type]["elements"] as $element) {
                if ($element["columns"]) {
                    foreach ($element["columns"] as $column) {
                        if ($column == $key) {
                            $elementsInUse[] = $element;
                        }
                    }
                }
            }
        }
        return $elementsInUse;
    }
8245
public function request($key, $type = 'string', $default = null)
    {
        $request = array_merge($this->get, $this->post, $this->cookie, $this->routeParams);
        $value = $default;
        if (isset($request[$key])) {
            $value = $request[$key];
        }
        settype($value, $type);
        return $value;
    }
318300
public function schema($key = null)
    {
        if (func_num_args() === 0) {
            return $this->collection->schema();
        } else {
            return $this->collection->schema($key);
        }
    }
1319669
public static function read($key = null, $type = null)
    {
        if (!self::_tableExists()) {
            return;
        }

        self::autoLoad();

        if (!$key) {
            return self::$_data;
        }

        if (key_exists($key, self::$_data)) {
            if ($type) {
                $value = self::$_data[$key];
                settype($value, $type);
                return $value;
            }
            return self::$_data[$key];
        }

        $model = self::model();

        $data = $model->findByName($key)->select('value');

        if ($data->count() > 0) {
            $data = $data->first()->toArray();
        } else {
            return null;
        }

        self::_store($key, $data['value']);

        $value = $data['value'];

        if ($type) {
            settype($value, $type);
        }

        return $value;
    }
1371999
public static function get($key, $type = 'ses')
    {
        $sessionData = $GLOBALS['TSFE']->fe_user->getKey(self::isType($type), $key);

        return unserialize($sessionData);
    }
408940
protected function getParameter($key, $type = Validate::TYPE_STRING, array $filter = array(), $title = null, $required = true)
    {
        $parameter = $this->request->getUri()->getParameter($key);

        if (isset($parameter)) {
            return $this->validate->apply($parameter, $type, $filter, $title, $required);
        } else {
            return null;
        }
    }
525446
public function getFromJson($key, array $replace = [], $locale = null)
    {
        $locale = $locale ?: $this->locale;

        // For JSON translations, there is only one file per locale, so we will simply load
        // that file and then we will be ready to check the array for the key. These are
        // only one level deep so we do not need to do any fancy searching through it.
        $this->load('*', '*', $locale);

        $line = $this->loaded['*']['*'][$locale][$key] ?? null;

        // If we can't find a translation for the JSON key, we will attempt to translate it
        // using the typical translation file. This way developers can always just use a
        // helper such as __ instead of having to pick between trans or __ with views.
        if (! isset($line)) {
            $fallback = $this->get($key, $replace, $locale);

            if ($fallback !== $key) {
                return $fallback;
            }
        }

        return $this->makeReplacements($line ?: $key, $replace);
    }
1249462
protected function getFieldFromBody($key)
    {
        $rpc = JsonRpc\json_decode((string) $this->getBody(), true);

        return isset($rpc[$key]) ? $rpc[$key] : null;
    }
1031095
private function getForm(string $key)
    {
        if (!Cache::has('hc-forms'))
            Artisan::call('hc:forms');

        $list = Cache::get('hc-forms');

        $new = substr($key, 0, -4);
        $edit = substr($key, 0, -5);

        if (isset($list[$new])) {
            $form = new $list[$new]();
            return $form->createForm();
        }

        if (isset($list[$edit])) {
            $form = new $list[$edit]();
            return $form->createForm(true);
        }

        return HCLog::error('CORE-0010', 'Form not found: ' . $key);
    }
1044171
public function get($key, $type)
	{
		if(is_array($key))
		{
			return $this->getItem($this->storageKey($key), $type);
		}

		if(is_string($key))
		{
			return $this->getItem($key, $type);
		}

		if(is_int($key))
		{
			return $this->getItem($this->storageKey([$key]), $type);
		}

		return null;
	}
796032
public function getMetadata($key = null)
    {
        if (is_null($this->metadataCache))
        {
            $this->metadataCache = json_decode($this->metadata, true);
        }

        if (is_null($key))
        {
            return $this->metadataCache;
        }

        if (isset($this->metadataCache[$key]))
        {
            return $this->metadataCache[$key];
        }

        return null;
    }
677371
public function getField($key)
    {
        if (!in_array($key, array_keys($this->formFields))) {
            throw FormFieldException::noSuchFieldName($key);
        }
        return $this->formFields[$key];
    }
308065
public function getResponseHeader($key = null) {
        if (null != $key) {
            if (array_key_exists($key, $this->response_headers)) {
                return $this->response_headers[$key];
            }
        } else {
            return $this->response_headers;
        }
    }
778374
public static function getStatic(string $type = '', string $module = '', $key = null) {
		return \Factory::model('\\' . get_called_class())->get($type, $module, $key);
	}
410381
public static function data($key=null,$default=null){
    if (null===static::$body){
      $json = (false !== stripos(empty($_SERVER['HTTP_CONTENT_TYPE'])?'':$_SERVER['HTTP_CONTENT_TYPE'],'json'))
           || (false !== stripos(empty($_SERVER['CONTENT_TYPE'])?'':$_SERVER['CONTENT_TYPE'],'json'));
      if ($json) {
        static::$body = json_decode(file_get_contents("php://input"));
      } else {
       if (empty($_POST)) {
          static::$body = file_get_contents("php://input");
        } else {
          static::$body = (object)$_POST;
        }
      }
    }
    return $key ? (isset(static::$body->$key) ? static::$body->$key : (is_callable($default)?call_user_func($default):$default))  : static::$body;
  }
846350
public function format($key, $type)
    {
        if (is_file($key)) {
            $key = file_get_contents($key);
        }

        if (is_string($key) && strpos($key, '-----') === false) {
            $key = $this->convertKey($key, $type);
        }

        return $key;
    }