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
41177b02
Commit
41177b02
authored
Jul 10, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update UPGRADE.md
fixed indentation
parent
b90f8865
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
44 deletions
+44
-44
UPGRADE.md
framework/UPGRADE.md
+44
-44
No files found.
framework/UPGRADE.md
View file @
41177b02
...
...
@@ -77,50 +77,50 @@ Upgrade from Yii 2.0 Beta
*
`\yii\rbac\PhpManager`
now stores data in three separate files instead of one. In order to convert old file to
new ones save the following code as
`convert.php`
that should be placed in the same directory your
`rbac.php`
is in:
```
php
<?php
$oldFile
=
'rbac.php'
;
$itemsFile
=
'items.php'
;
$assignmentsFile
=
'assignments.php'
;
$rulesFile
=
'rules.php'
;
$oldData
=
include
$oldFile
;
function
saveToFile
(
$data
,
$fileName
)
{
$out
=
var_export
(
$data
,
true
);
$out
=
"<?php
\n
return "
.
$out
.
";"
;
$out
=
str_replace
([
'array ('
,
')'
],
[
'['
,
']'
],
$out
);
file_put_contents
(
$fileName
,
$out
);
}
$items
=
[];
$assignments
=
[];
if
(
isset
(
$oldData
[
'items'
]))
{
foreach
(
$oldData
[
'items'
]
as
$name
=>
$data
)
{
if
(
isset
(
$data
[
'assignments'
]))
{
foreach
(
$data
[
'assignments'
]
as
$userId
=>
$assignmentData
)
{
$assignments
[
$userId
]
=
$assignmentData
[
'roleName'
];
}
unset
(
$data
[
'assignments'
]);
}
$items
[
$name
]
=
$data
;
}
}
$rules
=
[];
if
(
isset
(
$oldData
[
'rules'
]))
{
$rules
=
$oldData
[
'rules'
];
}
saveToFile
(
$items
,
$itemsFile
);
saveToFile
(
$assignments
,
$assignmentsFile
);
saveToFile
(
$rules
,
$rulesFile
);
echo
"Done!
\n
"
;
```
Run it once, delete
`rbac.php`
. If you've configured
`authFile`
property, remove the line from config and instead
configure
`itemFile`
,
`assignmentFile`
and
`ruleFile`
.
```php
<?php
$oldFile = 'rbac.php';
$itemsFile = 'items.php';
$assignmentsFile = 'assignments.php';
$rulesFile = 'rules.php';
$oldData = include $oldFile;
function saveToFile($data, $fileName) {
$out = var_export($data, true);
$out = "<?php\nreturn " . $out . ";";
$out = str_replace(['array (', ')'], ['[', ']'], $out);
file_put_contents($fileName, $out);
}
$items = [];
$assignments = [];
if (isset($oldData['items'])) {
foreach ($oldData['items'] as $name => $data) {
if (isset($data['assignments'])) {
foreach ($data['assignments'] as $userId => $assignmentData) {
$assignments[$userId] = $assignmentData['roleName'];
}
unset($data['assignments']);
}
$items[$name] = $data;
}
}
$rules = [];
if (isset($oldData['rules'])) {
$rules = $oldData['rules'];
}
saveToFile($items, $itemsFile);
saveToFile($assignments, $assignmentsFile);
saveToFile($rules, $rulesFile);
echo "Done!\n";
```
Run it once, delete
`rbac.php`
. If you've configured
`authFile`
property, remove the line from config and instead
configure
`itemFile`
,
`assignmentFile`
and
`ruleFile`
.
*
Static helper
`yii\helpers\Security`
has been converted into an application component. You should change all usage of
its methods to a new syntax, for example: instead of
`yii\helpers\Security::hashData()`
use
`Yii::$app->getSecurity()->hashData()`
.
...
...
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