Admin panel page config

@return JsonResponse
511441
public function index(): JsonResponse
    {
        $config = $this->makeView('language-view', trans('HCCore::languages.title.list'))
            ->addFormSource('add-new', 'language')
            ->addDataTable($this->getDataTable())
            ->setPermissions(['search'])
            ->toArray();

        return $this->response->success('OK', $config);
    }
1263129
public function jsonRows()
    {
        $arrWhat = array_values($this->getHeaderColumns());
        $arrWhere = [];
        $arrOrder = ['`id` DESC'];
        $start = 0;
        $pageSize = 15;
        if (isset($_POST['page']) && isset($_POST['pageSize'])) {
            $page = (int) $_POST['page'];
            $pageSize = (int) $_POST['pageSize'];
            $start = $page * $pageSize;
        }
        if (isset($_POST['sort']) && isset($_POST['sortDir'])) {
            $sort = (string) $_POST['sort'];
            $sortDir = (string) $_POST['sortDir'];
            if (!in_array($sortDir, ['ASC', 'DESC'])) {
                throw new Exception('Someone is doing something evil here :(');
            }
            if (!in_array($sort, $this->getAllowedPostColumns())) {
                throw new Exception('Someone is doing something evil here :(');
            }
            $arrOrder = ['`'.$sort.'` '.$sortDir];
        }
        foreach ($arrWhat as $filter) {
            if (in_array($filter, $arrWhat) && isset($_POST['filter_'.$filter])) {
                $arrWhere[$filter] = [
                    "operator" => "like",
                    "value" => '%'.$_POST['filter_'.$filter].'%'
                ];
            }
        }
        
        $arrLimit = [$start, $pageSize];
        $rows = $this->loadByPrepStmt($arrWhat, $arrWhere, $arrOrder, $arrLimit);
        if (count($rows) < 1) {
            return "[]";
        }
        foreach ($rows as $key => $columns) {
            foreach ($columns as $cKey => $column) {
                if ($cKey == "createDate") {
                    $rows[$key][$cKey] = strftime("%d.%m.%Y %H:%M:%S", strtotime($column));
                }
            }
            $rows[$key]['actions'] = $this->renderActionLinks();
        }
        $json = json_encode($rows, JSON_UNESCAPED_UNICODE);
        return $json;
    }
731424
protected function _controller() {
        if ($this->_setControllerFile($this->request->src, $this->request->controller) == true) {
            $className = "\\Src\\" . $this->request->src . "\\Controller\\" . ucfirst($this->request->controller);
            /** @var Controller $class */
            $class = new $className();

            if ($this->config->config['user']['security']['firewall'] == false || ($this->request->logged == '*' && $this->request->access == '*') || $class->setFirewall() == true) {
                if ($this->config->config['user']['security']['spam'] == false || $class->setSpam() == true) {
                    if ($this->request->cache > 0) {
                        $cache = new Cache('page_' . preg_replace('#\/#isU', '-slash-', $this->request->env('REQUEST_URI')), $this->request->cache);

                        if ($cache->isDie() == true) {
                            $output = $this->_action($class);
                            $this->response->page($output);

                            $cache->setContent(serialize($this->response));
                            $cache->setCache();
                        }
                        else {
                            $response = unserialize($cache->getCache());

                            $this->response->page($response->page());
                            $this->response->header($response->header());
                            $this->response->contentType($response->contentType());
                        }
                    }
                    else {
                        $output = $this->_action($class);
                        $this->response->page($output);
                    }
                }
                else {
                    $this->addError('The spam filter has detected an error', __FILE__, __LINE__, ERROR_ERROR);
                }
            }
            else {
                $this->addError('The firewall has detected an error', __FILE__, __LINE__, ERROR_ERROR);
            }
        }
        else {
            throw new Exception("Can't include controller from module " . $this->request->src);
        }
    }
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
        ));
    }
113277
public function getPage()
	{
		$pageData = $this->core->getSettings()->pagedata;
		$routeID = $this->route->id;

		$this->logger->info('Requested route: ' . $routeID);
		$this->logger->debug('Route info', array($this->route));

		if(isset($pageData->$routeID->active))
			$this->view->addActiveHtmlId($pageData->$routeID->active);

		$html = $this->view->render($routeID . '.html', array(
			'siteTitle' => isset($pageData->$routeID->title)?$pageData->$routeID->title:null,
			'runtime' => round(microtime(true) - REQUEST_TIME,3) ,
            'locale' => $this->core->getLocaleHandler()->getLocale(),
            'timezone' => date_default_timezone_get(),
			'base_path' => StringUtils::afterFirst(getcwd(), $_SERVER['DOCUMENT_ROOT'])
		));
		
		return new HttpResponse(200, $html, $this->headers);
	}
551147
public function get_admin_config() {
        if ($this->adminconfig) {
            return $this->adminconfig;
        }
        $this->adminconfig = get_config('assign');
        return $this->adminconfig;
    }
96651
public function listJsonAction()
    {
        $em = $this->getDoctrine()->getManager();
        $adminManager = $this->get('admin_manager');
        /** @var \AdminBundle\Services\DataTables\JsonList $jsonList */
        $jsonList = $this->get('json_list');
        $jsonList->setRepository($em->getRepository('EcommerceBundle:Product'));
        $user = $this->container->get('security.token_storage')->getToken()->getUser();
        if ($user->isGranted('ROLE_USER')) {
            $jsonList->setActor($user);
        }
        
        $response = $jsonList->get();

        return new JsonResponse($response);
    }
487041
public function getConfiguration(){
        $rest = $this->getService( self::API_CONNECTION_CONFIG);
        $rest->GET();

        return $rest->getResult( models\Connection\Config::class);
    }
488575
public function getJsonResponse()
    {
        $json = json_decode($this->httpResponse);
        if (is_null($json) && json_last_error() != JSON_ERROR_NONE) {
            return null; // decode error
        } else {
            return is_object($json) ? $json : null;
        }
    }
41924
public function buildCustomConfig() {
		$attributes = $this->readCustomAttributes();
		
		$pageConfig = new PageConfig();
		$pageConfig->setN2nLocaleUrlsActive($attributes->optBool(self::ATTR_LOCALES_ACTIVE_KEY, 
				self::ATTR_LOCALES_ACTIVE_DEFAULT));
		$pageConfig->setAutoN2nLocaleRedirectAllowed($attributes->optBool(self::ATTR_AUTO_LOCALE_REDIRECT_ACTIVE_KEY, 
				self::ATTR_AUTO_LOCALE_REDIRECT_ACTIVE_DEFAULT));
		$pageConfig->setSslDefault($attributes->optBool(self::ATTR_SSL_SELECTABLE_KEY, 
				self::ATTR_SSL_SELECTABLE_DEFAULT));
		$pageConfig->setSslDefault($attributes->optBool(self::ATTR_SSL_DEFAULT_KEY, 
				self::ATTR_SSL_DEFAULT_DEFAULT));
		
		$hooks = array();
		foreach ($attributes->getScalarArray(self::ATTR_HOOK_KEYS_KEY, false) as $key => $label) {
			if (is_numeric($key)) {
				$hooks[$label] = $label;
			} else {
				$hooks[$key] = $label;
			}
		}
		$pageConfig->setHooks($hooks);
		$pageConfig->setPageListenerLookupIds($attributes->getScalarArray(self::ATTR_PAGE_LISTENER_LOOKUP_IDS_KEY, 
				false));
		
		$pageControllerConfigs = array();
		foreach ($attributes->getArray(self::ATTR_PAGE_CONTROLLERS_KEY, false, array(), 
				TypeConstraint::createArrayLike('array')) as $pageControllerEiSpecId => $pageControllerAttrs) {
			$ciPanelConfigs = array();
			$pageControllerAttributes = new Attributes($pageControllerAttrs);
			foreach ($pageControllerAttributes->getArray(self::ATTR_PAGE_CONTROLLER_CI_PANELS_KEY, false, array(), 
					TypeConstraint::createArrayLike('array')) as $panelName => $ciPanelAttrs) {
				$ciPanelConfigs[] = CiConfigUtils::createPanelConfig($ciPanelAttrs, $panelName);
			}
				
			$pageConfig->addPageControllerConfig(new PageControllerConfig($pageControllerEiSpecId, $ciPanelConfigs));
		}
		
		return $pageConfig;
	}
1209502
public function toResponse($request)
	{
		return new JsonResponse([
			'data' => $this->transformData($request),
			'meta' => [
				'pagination' => [
					'total' => $this->paginator->total(),
					'per_page' => $this->paginator->perPage(),
					'current_page' => $this->paginator->currentPage(),
					'total_pages' => $this->paginator->lastPage()
				]
			]
		]);
	}
553871
public function getJson()
    {
        $response = [
            'status' => $this->status,
        ];

        switch ($this->status) {
            case self::STATUS_SUCCESS:
            case self::STATUS_FAIL:
                $response = array_merge(
                    $response,
                    [
                        'data' => $this->data,
                    ]
                );
                break;
            case self::STATUS_ERROR;
                $code     = $this->code ? ['code' => $this->code] : [];
                $data     = $this->data ? ['data' => $this->data] : [];
                $response = array_merge(
                    $response,
                    [
                        'message' => $this->message,
                    ],
                    $code,
                    $data
                );
                break;
            default:
                // because of the check in setStatus, this should never occur
                $response = [
                    'status'  => self::STATUS_ERROR,
                    'code'    => 500,
                    'message' => 'JSend response was built illegally',
                    'data'    => [
                        'original-data' => [
                            'status'  => $this->status,
                            'code'    => $this->code,
                            'message' => $this->message,
                            'data'    => $this->data,
                        ],
                    ],
                ];
                break;
        }

        return json_encode($response);
    }
1093774
public function getPages(){
        // Set method and action
        $method = 'settings';
        $action = 'getPages';

        // Set data
        $data = array(array(1)); // At least one parameter is required by API

        // Send request and retrieve response
        $result = Dispatcher::send($method, $action, $data);

        return $result;
    }
569889
public function query()
    {
        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }

        $authorUUID = $this
            ->userCredentialsProvider
            ->getUUID();

        $queryParameterBag = $this
            ->request
            ->query;

        $page = (int) $queryParameterBag->get('page', 1);
        $numPerPage = (int) $queryParameterBag->get('num_per_page', 10);
        $sortBy = json_decode($queryParameterBag->get(
            'sort_by',
            ['created_at' => 'desc']
        ), true);
        $indexedMetadataSortBy = [
            'indexed_metadata.' . key($sortBy) => $sortBy[key($sortBy)],
        ];

        $role = $this->userCredentialsProvider->isModerator()
            ? Author::ROLE_MODERATOR
            : Author::ROLE_USER;

        $result = $this
            ->commentRepository
            ->getCommentsBySource(
                $sourceUUID,
                $page,
                $numPerPage,
                $indexedMetadataSortBy,
                $role
            );

        if (!empty($authorUUID)) {
            foreach ($result->getComments() as $comment) {
                $this->setEditableInComment(
                    $comment,
                    $authorUUID
                );
            }
        }
        
        return new JsonResponse([
            'comments_result' => $result->toArray(),
            'user' => $this->userCredentialsProvider->toArray(),
        ], 200);
    }
440989
public function render()
    {
        $statusCode = $this->getExceptionStatusCode();
        if (is_array($this->exceptionMessage)) {
            return new JsonResponse(
                $this->exceptionMessage,
                $statusCode
            );
        } else {
            throw $this->exception;
        }
    }
813526
public function settingsAction(Request $request, View $view)
    {
        $pageSeo = $view->getSeo() ?: new PageSeo();
        $form = $this->createSettingsForm($pageSeo, $view);

        $form->handleRequest($request);

        $response = $this->getNotPersistedSettingsResponse(
            $form,
            $view,
            $request->query->get('novalidate', false)
        );

        return new JsonResponse($response);
    }
1072344
public function indexAction()
    {
        $configSectionManager = $this->container->get('admin.configuration.configsection_manager');
        $sections = $configSectionManager->getRepository()->findAllWithConfigGroups();
        $group = null;
        if ( count($sections) ) {
            $groups = $this->container->get('admin.configuration.configgroup_manager')->getRepository()->findByConfigGroupId($sections[0]->getId());
            if ( count($groups) ) {
                $group = $groups[0];
            }
        }

        return $this->renderTemplate($group);
    }