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
4dd15a66
Commit
4dd15a66
authored
Dec 09, 2014
by
Eugine Terentev
Committed by
Qiang Xue
Dec 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds immutable property fit SluggableBehavior fixes #6430
parent
9f20c06d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
SluggableBehavior.php
framework/behaviors/SluggableBehavior.php
+7
-0
No files found.
framework/behaviors/SluggableBehavior.php
View file @
4dd15a66
...
...
@@ -77,6 +77,11 @@ 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.
*/
public
$immutable
=
false
;
/**
* @var boolean whether to ensure generated slug value to be unique among owner class records.
* If enabled behavior will validate slug uniqueness automatically. If validation fails it will attempt
* generating unique slug value from based one until success.
...
...
@@ -133,6 +138,7 @@ class SluggableBehavior extends AttributeBehavior
$owner
=
$this
->
owner
;
if
(
!
$owner
->
getIsNewRecord
()
&&
!
empty
(
$owner
->
{
$this
->
slugAttribute
}))
{
$isNewSlug
=
false
;
if
(
!
$this
->
immutable
){
foreach
(
$attributes
as
$attribute
)
{
if
(
$owner
->
isAttributeChanged
(
$attribute
))
{
$isNewSlug
=
true
;
...
...
@@ -140,6 +146,7 @@ class SluggableBehavior extends AttributeBehavior
}
}
}
}
if
(
$isNewSlug
)
{
$slugParts
=
[];
...
...
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