本文整理汇总了PHP中static::render方法的典型用法代码示例。如果您正苦于以下问题:PHP static::render方法的具体用法?PHP static::render怎么用?PHP static::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forge
/**
* Create a view and get its content
*
* @param string Name of view
* @param array Data to pass to the view
* @return \Kofradia\Viev
*/
public static function forge($name, $data = array())
{
$path = PATH_APP . "/views/{$name}.php";
$view = new static($path);
$view->setData($data);
return $view->render();
}
示例2: create
/**
* Create a thumbnail
*/
static function create($source, $options = array())
{
// Create thumb
$thumb = new static();
// Load
$thumb->load($source);
// Set properties
$properties = array('type', 'quality', 'alignX', 'alignY', 'background');
// Loop
foreach ($properties as $property) {
// If set
if (isset($options[$property])) {
// Set it
$thumb->{$property} = $options[$property];
}
}
// If there's width
if (isset($options['width']) && ($width = $options['width'])) {
// Set width
$thumb->width = $width;
}
// If there's height
if (isset($options['height']) && ($height = $options['height'])) {
// Set height
$thumb->height = $height;
}
// Resize
$thumb->resize();
// Render and return
return $thumb->render();
}
示例3: renderTemplate
/**
* @param string $templatePath
* @param array $data
*
* @return string
*/
public static function renderTemplate(string $templatePath, array $data = []) : string
{
if (substr($templatePath, 0, 1) != '/') {
$templatePath = AbstractApp::getAppRoot() . '/' . $templatePath;
}
$phtml = new static($templatePath);
$phtml->addDatas($data);
return $phtml->render();
}
示例4: factory
public static function factory(RendererInterface $renderer, DataObject $object, $urlType, array $attributes = array())
{
$element = new static();
$element->setView($renderer);
$element->setObject($object);
$element->setAttributes($attributes);
$element->setUrlType($urlType);
return $element->render();
}
示例5: render
/**
* Render a HAL document in JSON format
*
* @param array $options Rendering options. You can currently only set json_options (json_encode options)
*
* @return string The JSON representation of the HAL document
*/
public function render($options = array())
{
if (isset($options['data_key'])) {
$this->_dataKey = $options['data_key'];
}
if (isset($options['json_options'])) {
$jsonOptions = $options['json_options'];
} else {
$jsonOptions = 0;
}
$serialiseThis = new \stdClass();
// Add links
$collection = $this->_document->getLinks();
$serialiseThis->_links = new \stdClass();
foreach ($collection as $rel => $links) {
if (!is_array($links)) {
$serialiseThis->_links->{$rel} = $this->_getLink($links);
} else {
$serialiseThis->_links->{$rel} = array();
foreach ($links as $link) {
array_push($serialiseThis->_links->{$rel}, $this->_getLink($link));
}
}
}
// Add embedded documents
$collection = $this->_document->getEmbedded();
if (!empty($collection)) {
$serialiseThis->_embedded = new \stdClass();
foreach ($collection as $rel => $embeddeddocs) {
$serialiseThis->_embedded->{$rel} = array();
if (!is_array($embeddeddocs)) {
$embeddeddocs = array($embeddeddocs);
}
foreach ($embeddeddocs as $embedded) {
$renderer = new static($embedded);
array_push($serialiseThis->_embedded->{$rel}, $renderer->render($options));
}
}
}
// Add data
$data = $this->_document->getData();
if (is_object($data)) {
if ($data instanceof DataModel) {
$data = $data->toArray();
} else {
$data = (array) $data;
}
if (!empty($data)) {
foreach ($data as $k => $v) {
$serialiseThis->{$k} = $v;
}
}
} elseif (is_array($data)) {
$serialiseThis->{$this->_dataKey} = $data;
}
return json_encode($serialiseThis, $jsonOptions);
}
示例6: helpers
public static function helpers()
{
static::$app = app();
$link_to = new \Twig_SimpleFunction('link_to', function ($text, $route_alias, $data = [], $attributes = []) {
$url = urlHelper($route_alias, $data);
if (isset($attributes)) {
$cnt = '';
foreach ($attributes as $key => $value) {
$cnt .= $value[0] . '="' . $value[1] . '" ';
}
}
echo '<a href="' . $url . '" ' . $cnt . '>' . $text . '</a>';
});
$link_to_remote = new \Twig_SimpleFunction('link_to_remote', function ($text, $url, $attributes) {
if (isset($attributes)) {
$cnt = '';
foreach ($attributes as $key => $value) {
$cnt .= $value[0] . '="' . $value[1] . '" ';
}
}
echo '<a href="' . $url . '" ' . $cnt . '>' . $text . '</a>';
});
$debugBarHead = new \Twig_SimpleFunction('debugBarHead', function () {
$app = app();
if (!$app->isProd()) {
static::$debugbarRender = $app->debugbar;
$test = static::$debugbarRender;
static::$render = $test->getJsRender();
echo static::$render->renderHead();
} else {
echo '';
}
});
$debugBarBody = new \Twig_SimpleFunction('debugBarBody', function () {
$app = app();
if (!$app->isProd()) {
echo static::$debugbarRender->render();
} else {
echo '';
}
});
$flash = new \Twig_SimpleFunction('flash', function () {
echo flash()->display(null, false);
});
$dd = new \Twig_SimpleFunction('dd', function ($data) {
dd($data);
});
return ['flash' => $flash, 'debugBarHead' => $debugBarHead, 'debugBarBody' => $debugBarBody, 'link_to' => $link_to, 'link_to_remote' => $link_to_remote, 'dd' => $dd];
}
示例7: execute
/**
* Execute the command.
*
* @param Application $app The application instance
*
* @return mixed
*/
public static function execute(Application $app)
{
static::$base = dirname(__DIR__) . '/templates/help/';
$help = new static($app->command ?: 'help');
$help->render();
}
示例8: load
/**
* load
*
* @param string $file
* @param array $data
*
* @return string
*/
public function load($file, $data = null)
{
$data = $this->data->bind(new Data($data));
$renderer = new static($this->paths, $this->config);
return $renderer->render($file, $data);
}
示例9: prepare
/**
* Prepare a response from the given value.
*
* If the value is not a response, it will be converted into a response
* instance and the content will be cast to a string.
*
* @param mixed $response
* @return Response
*/
public static function prepare($response)
{
if (!$response instanceof Response) {
$response = new static($response);
}
// We'll need to force the response to be a string before closing the session,
// since the developer may be using the session within a view, and we can't
// age the flash data until the view is rendered.
//
// Since this method is used by both the Route and Controller classes, it is
// a convenient spot to cast the application response to a string before it
// is returned to the main request handler.
$response->render();
return $response;
}
示例10: renderFieldset
/**
* Adds a fieldset object to the table.
*
* @param Fieldset $fieldset
*
* @since 2.0
*/
public function renderFieldset(Fieldset $fieldset)
{
// Create a new renderer and render the content
$fieldsetRenderer = new static($this->csrfProvider);
// Generate all the content
foreach ($fieldset as $item) {
$fieldsetRenderer->render($item);
}
$content = $fieldsetRenderer->getRenderedForm();
// Create the fieldset tag and add the content
$tag = Html::tag('fieldset', $fieldset->getAttributes(), $content);
// Make sure everything is added to the parent table
$cell = new Table\Cell($tag);
$cell->setAttributes(['colspan' => 2]);
$this->table->addCell($cell);
$this->table->addRow();
return '';
}
示例11: export
/**
* Export
*
* @param Di $di
* @param array $runtimeClasses
* @return void
*/
public static function export(Di $di, array $runtimeClasses = array())
{
$console = new static($di);
$console->addRuntimeClasses($runtimeClasses);
$console->render($di);
}
示例12: setRender
public static function setRender($render)
{
static::$render = $render;
}
示例13: import
public function import($in, $data = null)
{
$new = new static($in, $this->getOutputStream(), $this->getRouter(), $data);
$new->render();
return;
}
示例14: create
/**
* Initializes a helper with access to the template, and if needed, some
* parameters and content,
* validates its properties and returns its HTML representation
* @static
* @param Cognosys\Template $template
* @param array $params
* @param mixed $content Tipically, a string, an array or a Closure
* @return string
*/
public static function create($template, array $params = array(), $content = null)
{
$helper = new static($template, $params, $content);
$helper->validate();
return $helper->render($content);
}
示例15: page
public static function page($template, $data = array())
{
$tpl = new static();
$tpl->assign('data', $data);
echo $tpl->render($template);
}