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
58516ae8
Commit
58516ae8
authored
Dec 15, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support…
Fixes #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support keeping the generated slug unchanged
parent
4dd15a66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
CHANGELOG.md
framework/CHANGELOG.md
+1
-1
SluggableBehavior.php
framework/behaviors/SluggableBehavior.php
+4
-3
No files found.
framework/CHANGELOG.md
View file @
58516ae8
...
...
@@ -5,9 +5,9 @@ Yii Framework 2 Change Log
-----------------------
-
Bug #6404: advanced application template
`Alert`
widget was generating duplicate IDs in case of multiple flashes (SDKiller)
-
Enh #6434: Added
`yii\behaviors\SluggableBehavior::immutable`
to support keeping the generated slug unchanged (trntv)
-
Enh #6467:
`ActiveForm`
will scroll to the nearest visible element when the first error input is hidden (newartix)
2.
0.1 December 07, 2014
-----------------------
...
...
framework/behaviors/SluggableBehavior.php
View file @
58516ae8
...
...
@@ -77,8 +77,9 @@ class SluggableBehavior extends AttributeBehavior
*/
public
$value
;
/**
* @var boolean whether to generate new slug if it already filled but attribute was changed.
* If enabled behavior will not generate new slug after attributes in model was changed.
* @var boolean whether to generate a new slug if it has already been generated before.
* If true, the behavior will not generate a new slug even if [[attribute]] is changed.
* @since 2.0.2
*/
public
$immutable
=
false
;
/**
...
...
@@ -138,7 +139,7 @@ class SluggableBehavior extends AttributeBehavior
$owner
=
$this
->
owner
;
if
(
!
$owner
->
getIsNewRecord
()
&&
!
empty
(
$owner
->
{
$this
->
slugAttribute
}))
{
$isNewSlug
=
false
;
if
(
!
$this
->
immutable
)
{
if
(
!
$this
->
immutable
)
{
foreach
(
$attributes
as
$attribute
)
{
if
(
$owner
->
isAttributeChanged
(
$attribute
))
{
$isNewSlug
=
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