Load grid model from the database.

@param int $gridId THe grid id.

@return void

@throws RuntimeException When Grid does not exist.
760543
protected function loadModel(int $gridId): void
    {
        $model = GridModel::findByPk($gridId);
        if (!$model) {
            throw new RuntimeException(sprintf('Grid ID "%s" not found', $gridId));
        }

        $this->model = $model;
    }
606052
public function getColumn($id)
    {
        $column = $this->getComponent($id);
        if (!$column) {
            throw new RuntimeException("Column '$id' is not defined.");
        }
        if (!$column instanceof Column) {
            throw new RuntimeException("'$id' is not a column.");
        }
        return $column;
    }
358556
public function initialize(Grid $grid)
    {
        $this->grid = $grid;
        if (method_exists($this, 'initializeComponents')) {
            $this->initializeComponents($grid);
        }
    }
291746
public function loadSectionData($id)
    {
        try {
            return $this->innerGateway->loadSectionData($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
426437
public function load(array $data)
    {
        foreach ($data as $index => $value) {
            $this->set($index, $value);
        }
    }
587623
public function loadUrlWildcardData($parentId)
    {
        try {
            return $this->innerGateway->loadUrlWildcardData($parentId);
        } catch (DBALException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        }
    }
993850
public function loadTagInfo($tagId)
    {
        $row = $this->gateway->getBasicTagData($tagId);

        return $this->mapper->createTagInfoFromRow($row);
    }
809869
public function setSessionId(string $sessionId): void
    {
        if (empty($sessionId)) {
            throw new RuntimeException('CSRF middleware failed. SessionId not found!');
        }

        $this->sessionId = $sessionId;
    }
1306724
public function initialize()
    {
        if (null !== $this->collection) {
            return;
        }

        if (empty($this->dbOptions['database'])) {
            throw new \RuntimeException('The option "database" must be set');
        }
        if (empty($this->dbOptions['collection'])) {
            throw new \RuntimeException('The option "collection" must be set');
        }

        $this->collection = $this
            ->mongo
            ->selectDB($this->dbOptions['database'])
            ->selectCollection($this->dbOptions['collection']);
    }
175284
public function load(int $id)
    {
        $sql = "SELECT * FROM `".$this->tableName."` "
            . "WHERE `".$this->primaryKey."` = '".$id."'"
            . "LIMIT 0,1;";
        $stmt = $this->db->query($sql);
        
        try {
            $row = $stmt->fetch(PDO::FETCH_ASSOC);
        } catch (Exception $ex) {
            $this->log->crit('Could not find requested entry in mySQL: '.$sql."\n".$ex->getMessage());
        }
        
        if (!is_array($row)) {
            return;
        }
        
        $this->loadWithData($row);
    }
747847
public function loadState(array $params)
	{
		parent::loadState($params);

		if ($this->getParent() instanceof DataGrid) {
			$this->getPaginator()->page = $this->getParent()->page;
		}
	}
1222324
public function loadRoleAssignment($roleAssignmentId)
    {
        try {
            return $this->innerGateway->loadRoleAssignment($roleAssignmentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
275172
public function prepareViewModel(Datagrid $grid)
    {
        $viewModel = $this->getViewModel();

        $viewModel->setVariable('gridId', $grid->getId());
        $viewModel->setVariable('title', $this->getTitle());
        $viewModel->setVariable('parameters', $grid->getParameters());
        $viewModel->setVariable('overwriteUrl', $grid->getUrl());

        $viewModel->setVariable('templateToolbar', $this->getToolbarTemplate());
        foreach ($this->getToolbarTemplateVariables() as $key => $value) {
            $viewModel->setVariable($key, $value);
        }
        $viewModel->setVariable('rendererName', $this->getName());

        $options = $this->getOptions();
        $generalParameterNames = $options['generalParameterNames'];
        $viewModel->setVariable('generalParameterNames', $generalParameterNames);

        $viewModel->setVariable('columns', $this->getColumns());

        $viewModel->setVariable('rowStyles', $grid->getRowStyles());

        $viewModel->setVariable('paginator', $this->getPaginator());
        $viewModel->setVariable('data', $this->getData());
        $viewModel->setVariable('filters', $this->getFilters());

        $viewModel->setVariable('rowClickAction', $grid->getRowClickAction());
        $viewModel->setVariable('massActions', $grid->getMassActions());

        $viewModel->setVariable('isUserFilterEnabled', $grid->isUserFilterEnabled());

        /*
         * renderer specific parameter names
         */
        $optionsRenderer = $this->getOptionsRenderer();
        $viewModel->setVariable('optionsRenderer', $optionsRenderer);
        if ($this->isExport() === false) {
            $parameterNames = $optionsRenderer['parameterNames'];
            $viewModel->setVariable('parameterNames', $parameterNames);

            $activeParameters = [];
            $activeParameters[$parameterNames['currentPage']] = $this->getCurrentPageNumber();
            {
                $sortColumns = [];
                $sortDirections = [];
            foreach ($this->getSortConditions() as $sortCondition) {
                $sortColumns[] = $sortCondition['column']->getUniqueId();
                $sortDirections[] = $sortCondition['sortDirection'];
            }

                $activeParameters[$parameterNames['sortColumns']] = implode(',', $sortColumns);
                $activeParameters[$parameterNames['sortDirections']] = implode(',', $sortDirections);
            }
            $viewModel->setVariable('activeParameters', $activeParameters);
        }

        $viewModel->setVariable('exportRenderers', $grid->getExportRenderers());
    }
285538
public function setGrid(Grid $grid)
    {
        $this->grid = $grid;

        $this->setModel($grid->model()->eloquent());
    }
363312
public function load(...$sources)
    {
        if (!$sources) {
            throw new \RuntimeException('Sources must not be empty');
        }

        $this->clear();
        foreach ($sources as $source) {
            switch ($source) {
                case 'query':
                case 'post':
                case 'files':
                case 'cookie':
                    $this->data = array_merge($this->data, $this->request->$source());
                    break;
                default:
                    throw new \RuntimeException('Unknown source: ' . $source);
            }
        }

        if ($session = $this->session->get('input')) {
            $this->session->unset('input');
            if (!$this->data) {
                $this->data   = $session['data'] ?? [];
                $this->errors = $session['errors'] ?? [];
            }
        }
    }
402184
public function loadDatabase(string $file): void
	{
		$this->check();
		$this->driver->loadDatabase($file);
	}
1013229
public function loadPoliciesByUserId($userId)
    {
        try {
            return $this->innerGateway->loadPoliciesByUserId($userId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }