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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
1fbf81be
Commit
1fbf81be
authored
Mar 28, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User WIP.
parent
5f0f721c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
96 additions
and
23 deletions
+96
-23
code_style.md
docs/code_style.md
+1
-1
Component.php
framework/base/Component.php
+4
-1
Event.php
framework/base/Event.php
+3
-16
Model.php
framework/base/Model.php
+1
-1
ActiveRecord.php
framework/db/ActiveRecord.php
+2
-2
Identity.php
framework/web/Identity.php
+46
-0
Response.php
framework/web/Response.php
+2
-1
Session.php
framework/web/Session.php
+1
-0
User.php
framework/web/User.php
+0
-0
UserEvent.php
framework/web/UserEvent.php
+35
-0
ComponentTest.php
tests/unit/framework/base/ComponentTest.php
+1
-1
No files found.
docs/code_style.md
View file @
1fbf81be
...
...
@@ -204,7 +204,7 @@ doIt('a', array(
~~~
if ($event === null) {
return new Event(
$this
);
return new Event();
} elseif ($event instanceof CoolEvent) {
return $event->instance();
} else {
...
...
framework/base/Component.php
View file @
1fbf81be
...
...
@@ -422,7 +422,10 @@ class Component extends \yii\base\Object
$this
->
ensureBehaviors
();
if
(
isset
(
$this
->
_e
[
$name
])
&&
$this
->
_e
[
$name
]
->
getCount
())
{
if
(
$event
===
null
)
{
$event
=
new
Event
(
$this
);
$event
=
new
Event
;
}
if
(
$event
->
sender
===
null
)
{
$event
->
sender
=
$this
;
}
$event
->
handled
=
false
;
$event
->
name
=
$name
;
...
...
framework/base/Event.php
View file @
1fbf81be
...
...
@@ -28,7 +28,8 @@ class Event extends \yii\base\Object
*/
public
$name
;
/**
* @var object the sender of this event
* @var object the sender of this event. If not set, this property will be
* set as the object whose "trigger()" method is called.
*/
public
$sender
;
/**
...
...
@@ -38,21 +39,7 @@ class Event extends \yii\base\Object
*/
public
$handled
=
false
;
/**
* @var mixed extra data associated with the event.
* @var mixed extra
custom
data associated with the event.
*/
public
$data
;
/**
* Constructor.
*
* @param mixed $sender sender of the event
* @param mixed $data extra data associated with the event
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public
function
__construct
(
$sender
=
null
,
$data
=
null
,
$config
=
array
())
{
$this
->
sender
=
$sender
;
$this
->
data
=
$data
;
parent
::
__construct
(
$config
);
}
}
framework/base/Model.php
View file @
1fbf81be
...
...
@@ -258,7 +258,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
*/
public
function
beforeValidate
()
{
$event
=
new
ModelEvent
(
$this
)
;
$event
=
new
ModelEvent
;
$this
->
trigger
(
self
::
EVENT_BEFORE_VALIDATE
,
$event
);
return
$event
->
isValid
;
}
...
...
framework/db/ActiveRecord.php
View file @
1fbf81be
...
...
@@ -847,7 +847,7 @@ class ActiveRecord extends Model
*/
public
function
beforeSave
(
$insert
)
{
$event
=
new
ModelEvent
(
$this
)
;
$event
=
new
ModelEvent
;
$this
->
trigger
(
$insert
?
self
::
EVENT_BEFORE_INSERT
:
self
::
EVENT_BEFORE_UPDATE
,
$event
);
return
$event
->
isValid
;
}
...
...
@@ -887,7 +887,7 @@ class ActiveRecord extends Model
*/
public
function
beforeDelete
()
{
$event
=
new
ModelEvent
(
$this
)
;
$event
=
new
ModelEvent
;
$this
->
trigger
(
self
::
EVENT_BEFORE_DELETE
,
$event
);
return
$event
->
isValid
;
}
...
...
framework/web/Identity.php
0 → 100644
View file @
1fbf81be
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\web
;
/**
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
interface
Identity
{
/**
* Returns an ID that can uniquely identify a user identity.
* The returned ID can be a string, an integer, or any serializable data.
* @return mixed an ID that uniquely identifies a user identity.
*/
public
function
getId
();
/**
* Returns a key that can be used to check the validity of a given identity ID.
* The space of such keys should be big and random enough to defeat potential identity attacks.
* The returned key can be a string, an integer, or any serializable data.
* @return mixed a key that is used to check the validity of a given identity ID.
* @see validateAuthKey()
*/
public
function
getAuthKey
();
/**
* Validates the given auth key.
* @param string $authKey the given auth key
* @return boolean whether the given auth key is valid.
* @see getAuthKey()
*/
public
function
validateAuthKey
(
$authKey
);
/**
* Finds an identity by the given ID.
* @param mixed $id the ID to be looked for
* @return Identity the identity object that matches the given ID.
* Null should be returned if such an identity cannot be found.
*/
public
static
function
findIdentity
(
$id
);
}
\ No newline at end of file
framework/web/Response.php
View file @
1fbf81be
...
...
@@ -7,6 +7,7 @@
namespace
yii\web
;
use
Yii
;
use
yii\helpers\FileHelper
;
/**
...
...
@@ -178,6 +179,6 @@ class Response extends \yii\base\Response
*/
public
function
getCookies
()
{
return
\
Yii
::
$app
->
getRequest
()
->
getCookies
();
return
Yii
::
$app
->
getRequest
()
->
getCookies
();
}
}
framework/web/Session.php
View file @
1fbf81be
...
...
@@ -619,6 +619,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
}
/**
* Returns a value indicating whether there is a flash message associated with the specified key.
* @param string $key key identifying the flash message
* @return boolean whether the specified flash message exists
*/
...
...
framework/web/User.php
View file @
1fbf81be
This diff is collapsed.
Click to expand it.
framework/web/UserEvent.php
0 → 100644
View file @
1fbf81be
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\web
;
use
yii\base\Event
;
/**
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
UserEvent
extends
Event
{
/**
* @var Identity the identity object associated with this event
*/
public
$identity
;
/**
* @var boolean whether the login is cookie-based. This property is only meaningful
* for [[User::EVENT_BEFORE_LOGIN]] and [[User::EVENT_AFTER_LOGIN]] events.
*/
public
$fromCookie
;
/**
* @var boolean whether the login or logout should proceed.
* Event handlers may modify this property to determine whether the login or logout should proceed.
* This property is only meaningful for [[User::EVENT_BEFORE_LOGIN]] and [[User::EVENT_BEFORE_LOGOUT]] events.
*/
public
$isValid
;
}
\ No newline at end of file
tests/unit/framework/base/ComponentTest.php
View file @
1fbf81be
...
...
@@ -352,7 +352,7 @@ class NewComponent extends Component
public
function
raiseEvent
()
{
$this
->
trigger
(
'click'
,
new
Event
(
$this
)
);
$this
->
trigger
(
'click'
,
new
Event
);
}
}
...
...
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