Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4a787059
Commit
4a787059
authored
Apr 04, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better phpdoc for view renderers, composite view renderer
parent
6c00f6d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletion
+84
-1
CompositeViewRenderer.php
framework/renderers/CompositeViewRenderer.php
+57
-0
SmartyViewRenderer.php
framework/renderers/SmartyViewRenderer.php
+15
-0
TwigViewRenderer.php
framework/renderers/TwigViewRenderer.php
+12
-1
No files found.
framework/renderers/CompositeViewRenderer.php
0 → 100644
View file @
4a787059
<?php
/**
* Composite view renderer class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\renderers
;
use
Yii
;
use
yii\base\View
;
use
yii\base\ViewRenderer
;
/**
* CompositeViewRenderer allows you to use multiple view renderers in a single
* application.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class
CompositeViewRenderer
extends
ViewRenderer
{
/**
* @var array a config array with the view renderer objects or the configuration arrays for
* creating the view renderers indexed by file extensions.
*/
public
$renderers
=
array
();
/**
* Renders a view file.
*
* This method is invoked by [[View]] whenever it tries to render a view.
* Child classes must implement this method to render the given view file.
*
* @param View $view the view object used for rendering the file.
* @param string $file the view file.
* @param array $params the parameters to be passed to the view file.
*
* @return string the rendering result
*/
public
function
render
(
$view
,
$file
,
$params
)
{
$ext
=
pathinfo
(
$file
,
PATHINFO_EXTENSION
);
if
(
$ext
===
'php'
||
!
isset
(
$this
->
renderers
[
$ext
]))
{
return
$view
->
renderPhpFile
(
$file
,
$params
);
}
else
{
if
(
is_array
(
$this
->
renderers
[
$ext
]))
{
$this
->
renderers
[
$ext
]
=
Yii
::
createObject
(
$this
->
renderers
[
$ext
]);
}
return
$this
->
renderers
[
$ext
]
->
render
(
$view
,
$file
,
$params
);
}
}
}
\ No newline at end of file
framework/renderers/SmartyViewRenderer.php
View file @
4a787059
...
@@ -20,9 +20,24 @@ use \yii\base\ViewRenderer;
...
@@ -20,9 +20,24 @@ use \yii\base\ViewRenderer;
*/
*/
class
SmartyViewRenderer
extends
ViewRenderer
class
SmartyViewRenderer
extends
ViewRenderer
{
{
/**
* @var string alias pointing to where Smarty code is located.
*/
public
$smartyDir
=
'@app/vendors/Smarty'
;
public
$smartyDir
=
'@app/vendors/Smarty'
;
/**
* @var string alias pointing to where Smarty cache will be stored.
*/
public
$cacheDir
=
'@app/runtime/Smarty/cache'
;
public
$cacheDir
=
'@app/runtime/Smarty/cache'
;
/**
* @var string alias pointing to where Smarty compiled teamplates will be stored.
*/
public
$compileDir
=
'@app/runtime/Smarty/compile'
;
public
$compileDir
=
'@app/runtime/Smarty/compile'
;
/**
* @var string file extension to use for template files
*/
public
$fileExtension
=
'tpl'
;
public
$fileExtension
=
'tpl'
;
/** @var \Smarty */
/** @var \Smarty */
...
...
framework/renderers/TwigViewRenderer.php
View file @
4a787059
...
@@ -20,12 +20,23 @@ use \yii\base\ViewRenderer;
...
@@ -20,12 +20,23 @@ use \yii\base\ViewRenderer;
*/
*/
class
TwigViewRenderer
extends
ViewRenderer
class
TwigViewRenderer
extends
ViewRenderer
{
{
/**
* @var string alias pointing to where Twig code is located.
*/
public
$twigDir
=
'@app/vendors/Twig'
;
public
$twigDir
=
'@app/vendors/Twig'
;
/**
* @var string alias pointing to where Twig cache will be stored.
*/
public
$cacheDir
=
'@app/runtime/Twig/cache'
;
public
$cacheDir
=
'@app/runtime/Twig/cache'
;
/**
* @var string file extension to use for template files.
*/
public
$fileExtension
=
'twig'
;
public
$fileExtension
=
'twig'
;
/**
/**
* @var array options
* @var array
Twig
options
* @see http://twig.sensiolabs.org/doc/api.html#environment-options
* @see http://twig.sensiolabs.org/doc/api.html#environment-options
*/
*/
public
$options
=
array
();
public
$options
=
array
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment