本文整理匯總了PHP中FOS\RestBundle\View\View::getTemplateVar方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::getTemplateVar方法的具體用法?PHP View::getTemplateVar怎麽用?PHP View::getTemplateVar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FOS\RestBundle\View\View
的用法示例。
在下文中一共展示了View::getTemplateVar方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepareTemplateParameters
/**
* Prepares view data for use by templating engine.
*
* @param View $view
*
* @return array
*/
public function prepareTemplateParameters(View $view)
{
$data = $view->getData();
if ($data instanceof FormInterface) {
return array($view->getTemplateVar() => $data->getData(), 'form' => $data->createView());
}
if (empty($data) || !is_array($data) || is_numeric(key($data))) {
return array($view->getTemplateVar() => $data);
}
if (isset($data['form']) && $data['form'] instanceof FormInterface) {
$data['form'] = $data['form']->createView();
}
return $data;
}
示例2: prepareTemplateParameters
/**
* Prepares view data for use by templating engine.
*
* @param View $view
*
* @return array
*/
public function prepareTemplateParameters(View $view)
{
$data = $view->getData();
if ($data instanceof FormInterface) {
$data = [$view->getTemplateVar() => $data->getData(), 'form' => $data];
} elseif (empty($data) || !is_array($data) || is_numeric(key($data))) {
$data = [$view->getTemplateVar() => $data];
}
if (isset($data['form']) && $data['form'] instanceof FormInterface) {
$data['form'] = $data['form']->createView();
}
$templateData = $view->getTemplateData();
if (is_callable($templateData)) {
$templateData = call_user_func($templateData, $this, $view);
}
return array_merge($data, $templateData);
}
示例3: prepareTemplateParameters
/**
* Prepare view data for use by templating engine.
*
* @param View $view
*
* @return array
*/
public function prepareTemplateParameters(View $view)
{
$data = $view->getData();
if (empty($data)) {
return array($view->getTemplateVar() => $data);
}
if (!is_array($data)) {
$data = array($view->getTemplateVar() => $data);
}
foreach (array_keys($data) as $key) {
if ($data[$key] instanceof FormInterface) {
$data[$key] = $data[$key]->createView();
}
}
if (is_numeric($key)) {
$data = array($view->getTemplateVar() => $data);
}
return $data;
}