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
b51aa4ed
Commit
b51aa4ed
authored
Jun 07, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
1599a2cf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
214 deletions
+2
-214
Controller.php
framework/base/Controller.php
+2
-35
RenderEvent.php
framework/base/RenderEvent.php
+0
-43
DirectoryDependency.php
framework/caching/DirectoryDependency.php
+0
-136
No files found.
framework/base/Controller.php
View file @
b51aa4ed
...
...
@@ -16,9 +16,7 @@ namespace yii\base;
*
* 1. [[authorize]]
* 2. [[beforeAction]]
* 3. [[beforeRender]]
* 4. [[afterRender]]
* 5. [[afterAction]]
* 3. [[afterAction]]
*
* @property array $actionParams the request parameters (name-value pairs) to be used for action parameter binding
* @property string $route the route (module ID, controller ID and action ID) of the current request.
...
...
@@ -283,40 +281,9 @@ class Controller extends Component implements Initable
$this
->
trigger
(
__METHOD__
,
new
ActionEvent
(
$action
));
}
/**
* This method is invoked right before an action renders its result using [[render()]].
* @param string $view the view to be rendered
* @return boolean whether the action should continue to render.
*/
public
function
beforeRender
(
$view
)
{
$event
=
new
RenderEvent
(
$view
);
$this
->
trigger
(
__METHOD__
,
$event
);
return
$event
->
isValid
;
}
/**
* This method is invoked right after an action renders its result using [[render()]].
* @param string $view the view just rendered
* @param string $content the content to be displayed
* @return string the content to be displayed. This may be the same as the input content or the one
* modified by event handlers.
*/
public
function
afterRender
(
$view
,
$content
)
{
$event
=
new
RenderEvent
(
$view
,
$content
);
$this
->
trigger
(
__METHOD__
,
$event
);
return
$event
->
content
;
}
public
function
render
(
$view
,
$params
=
array
())
{
if
(
$this
->
beforeRender
(
$view
))
{
$content
=
$this
->
createView
()
->
render
(
$view
,
$params
);
$content
=
$this
->
afterRender
(
$view
,
$content
);
return
$content
;
}
return
''
;
return
$this
->
createView
()
->
render
(
$view
,
$params
);
}
public
function
renderText
(
$text
)
...
...
framework/base/RenderEvent.php
deleted
100644 → 0
View file @
1599a2cf
<?php
/**
* RenderEvent class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\base
;
/**
* RenderEvent represents the event parameter used for when calling [[Controller::render()]].
*
* By setting the [[isValid]] property, one may control whether to continue the rendering.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
RenderEvent
extends
Event
{
/**
* @var string the view currently being rendered
*/
public
$view
;
/**
* @var string the content to be displayed
*/
public
$content
;
/**
* @var boolean whether the action is in valid state and its life cycle should proceed.
*/
public
$isValid
=
true
;
/**
* Constructor.
* @param string $view the view currently being rendered
*/
public
function
__construct
(
$view
)
{
$this
->
view
=
$view
;
}
}
framework/caching/DirectoryDependency.php
deleted
100644 → 0
View file @
1599a2cf
<?php
/**
* DirectoryDependency class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\caching
;
/**
* DirectoryDependency represents a dependency based on change of a directory.
*
* DirectoryDependency performs dependency checking based on the
* modification time of the files contained in the specified directory.
* The directory being checked is specified via {@link directory}.
*
* By default, all files under the specified directory and subdirectories
* will be checked. If the last modification time of any of them is changed
* or if different number of files are contained in a directory, the dependency
* is reported as changed. By specifying {@link recursiveLevel},
* one can limit the checking to a certain depth of the directory.
*
* Note, dependency checking for a directory is expensive because it involves
* accessing modification time of multiple files under the directory.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
DirectoryDependency
extends
Dependency
{
/**
* @var string the directory whose change is used to determine if the dependency has been changed.
* If any of the files under the directory is changed, the dependency is considered as changed.
*/
public
$directory
;
/**
* @var integer the depth of the subdirectories to be recursively checked.
* If the value is less than 0, it means unlimited depth.
* If the value is 0, it means checking the files directly under the specified directory.
*/
public
$recursiveLevel
=
-
1
;
/**
* @var string the regular expression matching valid file/directory names.
* Only the matching files or directories will be checked for changes.
* Defaults to null, meaning all files/directories will qualify.
*/
public
$namePattern
;
/**
* Constructor.
* @param string $directory the directory to be checked
*/
public
function
__construct
(
$directory
=
null
)
{
$this
->
directory
=
$directory
;
}
/**
* Generates the data needed to determine if dependency has been changed.
* This method returns the modification timestamps for files under the directory.
* @return mixed the data needed to determine if dependency has been changed.
*/
protected
function
generateDependencyData
()
{
if
(
$this
->
directory
!==
null
)
{
return
$this
->
generateTimestamps
(
$this
->
directory
);
}
else
{
throw
new
CException
(
Yii
::
t
(
'yii'
,
'DirectoryDependency.directory cannot be empty.'
));
}
}
/**
* Determines the last modification time for files under the directory.
* This method may go recursively into subdirectories if {@link recursiveLevel} is not 0.
* @param string $directory the directory name
* @param integer $level level of the recursion
* @return array list of file modification time indexed by the file path
*/
protected
function
generateTimestamps
(
$directory
,
$level
=
0
)
{
if
((
$dir
=
@
opendir
(
$directory
))
===
false
)
{
throw
new
CException
(
Yii
::
t
(
'yii'
,
'"{path}" is not a valid directory.'
,
array
(
'{path}'
=>
$directory
)));
}
$timestamps
=
array
();
while
((
$file
=
readdir
(
$dir
))
!==
false
)
{
$path
=
$directory
.
DIRECTORY_SEPARATOR
.
$file
;
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;
}
if
(
$this
->
namePattern
!==
null
&&
!
preg_match
(
$this
->
namePattern
,
$file
))
{
continue
;
}
if
(
is_file
(
$path
))
{
if
(
$this
->
validateFile
(
$path
))
{
$timestamps
[
$path
]
=
filemtime
(
$path
);
}
}
else
{
if
((
$this
->
recursiveLevel
<
0
||
$level
<
$this
->
recursiveLevel
)
&&
$this
->
validateDirectory
(
$path
))
{
$timestamps
=
array_merge
(
$timestamps
,
$this
->
generateTimestamps
(
$path
,
$level
+
1
));
}
}
}
closedir
(
$dir
);
return
$timestamps
;
}
/**
* Checks to see if the file should be checked for dependency.
* This method is invoked when dependency of the whole directory is being checked.
* By default, it always returns true, meaning the file should be checked.
* You may override this method to check only certain files.
* @param string $fileName the name of the file that may be checked for dependency.
* @return boolean whether this file should be checked.
*/
protected
function
validateFile
(
$fileName
)
{
return
true
;
}
/**
* Checks to see if the specified subdirectory should be checked for dependency.
* This method is invoked when dependency of the whole directory is being checked.
* By default, it always returns true, meaning the subdirectory should be checked.
* You may override this method to check only certain subdirectories.
* @param string $directory the name of the subdirectory that may be checked for dependency.
* @return boolean whether this subdirectory should be checked.
*/
protected
function
validateDirectory
(
$directory
)
{
return
true
;
}
}
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