Prepares params for rendering, executing callable functions.

@return array
960431
public function getParams()
    {
        $res = [];
        if ($this->_params instanceof Closure) {
            $res = call_user_func($this->_params, $this);
        } else {
            foreach ($this->_params as $k => $v) {
                $res[$k] = $v instanceof Closure ? call_user_func($v, $this, $this->getModel()) : $v;
            }
        }

        return array_merge($res, $this->prepareData($res));
    }
883108
public function render()
    {
        $this->runHook('document:render', [ $this ]);

        $fsettings = $this->project->config('filters_settings');
        $filters   = Extensions::getFilters($this->getProject()->config('filters'));

        if (count($filters) > 0) {
            foreach ($filters as $name => $filter) {
                if ($filter instanceof \Closure) {
                    call_user_func_array($filter, [ $this, isset($fsettings[ $name ]) ? $fsettings[ $name ] : [ ] ]);
                } else {
                    $instance = app()->make($filter);
                    call_user_func_array([ $instance, 'handle' ], [ $this, isset($fsettings[ $name ]) ? $fsettings[ $name ] : [ ] ]);
                }
            }
        }

        return $this->content;
    }
519687
public function getParamsAsCode(): array
    {
        $paramsAsCode = [];

        foreach ($this->getParamNames() as $paramName) {
            $paramsAsCode[$paramName] = RequestPropertyUtility::getStringValueAsCode($this->$paramName);
        }

        return $paramsAsCode;
    }
264482
public function compileParameters(): array
    {
        $return = [
            'query' => [],
            'resource_id' => $this->resourceId,
        ];

        if ($this->filterBy) {
            $return['query']['filter_by'] = $this->filterBy;
        }

        if ($this->sortBy) {
            $return['query']['sort_by'] = $this->sortBy;
        }

        if ($this->fieldList) {
            $return['query']['field_list'] = $this->fieldList;
        }

        if ($this->parameters) {
            foreach ($this->parameters as $name => $value) {
                $return['query'][$name] = $value;
            }
        }

        return $return;
    }
992561
public function generateActionParamComments()
    {
        /** @var ActiveRecord $class */
        $class = $this->modelClass;
        $pks = $class::primaryKey();
        if (($table = $this->getTableSchema()) === false) {
            $params = [];
            foreach ($pks as $pk) {
                $params[] = '@param ' . (substr(strtolower($pk), -2) == 'id' ? 'integer' : 'string') . ' $' . $pk;
            }

            return $params;
        }
        if (count($pks) === 1) {
            return ['@param ' . $table->columns[$pks[0]]->phpType . ' $id'];
        } else {
            $params = [];
            foreach ($pks as $pk) {
                $params[] = '@param ' . $table->columns[$pk]->phpType . ' $' . $pk;
            }

            return $params;
        }
    }
331326
public function prepareParam(array $param = null)
    {
        if (!$param) {
            return [];
        }
        $ret = [];

        foreach ($param as $key => $value) {
            if (is_array($value)) {
                $keyString = md5($key);
                foreach ($value as $subKey => $subValue) {
                    $ret[] =[':' . $keyString.$subKey , $subValue];
                }
            } else {
                $ret[] = [':' . md5($key), $value];
            }

        }

        return $ret;
    }
490016
protected function _render($params) {
		foreach ($params as $name => $param) {
			if ($name === 'run' || empty($param['name'])) {
				continue;
			}
			$usage = (!empty($param['usage'])) ? trim($param['usage'], ' []') : $param['name'];
			$this->out($this->_pad($usage), 'option');

			if ($param['description']) {
				$this->out($this->_pad($param['description'], 2));
			}
			$this->nl();
		}
	}
1308545
private function assembleRouteParams() : array
    {
        $params = [
            'version' => $this->version,
            'resource' => $this->resource,
        ];

        if ($this->id !== null) {
            $params['id'] = $this->id;
        }

        if ($this->relationship !== null) {
            $params['relationship'] = $this->relationship;
        }

        if ($this->relatedId !== null) {
            $params['parameter'] = $this->relatedId;
        }

        return $params;
    }
763977
public function prepare()
    {
        $return = [];

        $this->getDatabaseConfigs($return);

        if ($this->command->confirm('Do you want to provide an other user to connect to DB?', false))
        {
            $this->getOtherConnectionUser($return);
        }

        $this->generateSqlCommands($return);

        return $return;
    }
621810
protected function prepareDataProvider($params = []) {
        if (!isset($params['attr']))
            throw new Exception('Require parameter "attr"!');

        $prefix = is_null($this->controller->module) ? $this->controller->module->uniqueId : $this->controller->module->id;
        $prefix.= DIRECTORY_SEPARATOR . $params['attr'];
        $uploadPath = $this->uploadPath . DIRECTORY_SEPARATOR . $prefix;
        $uploadUrl = str_replace('\\', '/', $this->uploadUrl . '/' . $prefix);

        $data = [];
        if (@file_exists($uploadPath)) {
            $whiteExts = array_map(function($value) {
                return "*.{$value}";
            }, $this->whiteExts);
            $files = FileHelper::findFiles($uploadPath, ['only' => $whiteExts]);

            foreach ($files as $file) {
                $fileName = basename($file);
                $data[] = [
                    'title' => $fileName,
                    'thumb' => Url::to($uploadUrl . '/' . $fileName),
                    'image' => Url::to($uploadUrl . '/' . $fileName),
                ];
            }
        }
        return $data;
    }
658504
protected function prepareParams(array $params)
    {
        foreach ($params as $key => $param) {
            if (gettype($param) === 'boolean') {
                $params[$key] = (string)(($param) ? 'true' : 'false');
            }
        }
        return $params;
    }
342588
public function render()
    {
        // Prepare details
        $path       = $this->config['settings']['path'];
        $name       = $this->config['settings']['name'] . '/';
        $template   = 'index.tpl.php';
        $functions  = 'functions.php';

        // Include theme specific functions file
        $file = $path . $name . $functions;
        if (is_readable($file)) {
            include $file;
        }

        // Create views for regions, from config-file
        if (isset($this->config['views'])) {
            foreach ($this->config['views'] as $view) {
                $this->di->views->add($view['template'], $view['data'], $view['region'], $view['sort']);
            }
        }

        // Sen response headers, if any.
        $this->di->response->sendHeaders();

        // Create a view to execute the default template file
        $tpl  = $path . $name . $template;
        $data = array_merge($this->config['data'], $this->data);
        $view = $this->di->get('view');
        $view->set($tpl, $data);
        $view->setDI($this->di);
        $view->render();
    }
63116
public function prepare_render() {

        global $DB, $CFG, $PAGE;

        $this->renderable = new StdClass();

        $this->renderable->user = $DB->get_record('user', array('id' => $this->userid));

        // Entry comments.
        if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
            require_once($CFG->dirroot . '/comment/lib.php');

            $cmt = new stdClass();
            $cmt->context = context_user::instance($this->userid);
            $cmt->courseid = $PAGE->course->id;
            $cmt->area = 'format_blog';
            $cmt->itemid = $this->id;
            $cmt->showcount = $CFG->blogshowcommentscount;
            $cmt->component = 'blog';
            $this->renderable->comment = new comment($cmt);
        }

        $this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);

        // External blog link.
        if ($this->uniquehash && $this->content) {
            if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
                $urlparts = parse_url($externalblog->url);
                $this->renderable->externalblogtext = get_string('retrievedfrom', 'blog') . get_string('labelsep', 'langconfig');
                $this->renderable->externalblogtext .= html_writer::link($urlparts['scheme'] . '://' . $urlparts['host'],
                                                                         $externalblog->name);
            }
        }

        // Retrieve associations.
        $this->renderable->unassociatedentry = false;
        if (!empty($CFG->useblogassociations)) {

            // Adding the entry associations data.
            if ($associations = $associations = $DB->get_records('blog_association', array('blogid' => $this->id))) {

                // Check to see if the entry is unassociated with group/course level access.
                if ($this->publishstate == 'group' || $this->publishstate == 'course') {
                    $this->renderable->unassociatedentry = true;
                }

                foreach ($associations as $key => $assocrec) {

                    if (!$context = context::instance_by_id($assocrec->contextid, IGNORE_MISSING)) {
                        unset($associations[$key]);
                        continue;
                    }

                    // The renderer will need the contextlevel of the association.
                    $associations[$key]->contextlevel = $context->contextlevel;

                    // Course associations.
                    if ($context->contextlevel == CONTEXT_COURSE) {
                        // TODO: performance!!!!
                        $instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid));

                        $associations[$key]->url = $assocurl = new moodle_url('/course/view.php',
                                                                              array('id' => $context->instanceid));
                        $associations[$key]->text = $instancename;
                        $associations[$key]->icon = new pix_icon('i/course', $associations[$key]->text);
                    }

                    // Mod associations.
                    if ($context->contextlevel == CONTEXT_MODULE) {

                        // Getting the activity type and the activity instance id.
                        $sql = 'SELECT cm.instance, m.name FROM {course_modules} cm
                                  JOIN {modules} m ON m.id = cm.module
                                 WHERE cm.id = :cmid';
                        $modinfo = $DB->get_record_sql($sql, array('cmid' => $context->instanceid));
                        // TODO: performance!!!!
                        $instancename = $DB->get_field($modinfo->name, 'name', array('id' => $modinfo->instance));

                        $associations[$key]->type = get_string('modulename', $modinfo->name);
                        $associations[$key]->url = new moodle_url('/mod/' . $modinfo->name . '/view.php',
                                                                  array('id' => $context->instanceid));
                        $associations[$key]->text = $instancename;
                        $associations[$key]->icon = new pix_icon('icon', $associations[$key]->text, $modinfo->name);
                    }
                }
            }
            $this->renderable->blogassociations = $associations;
        }

        // Entry attachments.
        $this->renderable->attachments = $this->get_attachments();

        $this->renderable->usercanedit = blog_user_can_edit_entry($this);
    }
1025066
protected function compileParameterNames()
    {
        preg_match_all('/\{(.*?)\}/', $this->domain() .$this->uri, $matches);

        return array_map(function ($match)
        {
            return trim($match, '?');

        }, $matches[1]);
    }
1288055
public function render()
    {
        $renderFunction = function (&$element, $key) {
            $element = $element->render();
        };
        array_walk($this->elements, $renderFunction);

        $structuredElements = StructureManager::buildStructure($this->elements, $this->structure);

        return $structuredElements;
    }
751276
private function prepare($args)
    {
        $bindings = array();

        // Two parameters (key, value).
        if (count($args) == 2) {
            $bindings[$args[0]] = $args[1];
        }
        // Array of parameters.
        elseif (is_array($args[0])) {
            $bindings = $args[0];
        }

        return $bindings;
    }
420593
protected function getParams()
    {
        $reserved = [
            $this->config('prefix', '').'sort',
            $this->config('prefix', '').'fields',
            $this->config('prefix', '').'limit',
            $this->config('prefix', '').'with',
            $this->config('prefix', '').'page',
        ];

        return $this->params ?: $this->request->except($reserved);
    }