Skip to content

Commit

Permalink
added removeChild func to Migration class
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-chepurnoi committed Jan 13, 2017
1 parent 46ddeef commit e19d75f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ To be able create the migrations, you need to add the following code to your con
8. `updateRule()`: updating a rule
9. `removeRule()`: removing a rule
10. `addChild()`: creating a child
11. `assign()`: assign a role to a user
12. `removeChild()`: removing a child
13. `assign()`: assign a role to a user


###Creating Migrations
Expand Down
20 changes: 20 additions & 0 deletions migrations/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,26 @@ protected function addChild($parent, $child)
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}

/**
* Removes child.
*
* @param Item|string $parent Either name or Item instance which is parent
* @param Item|string $child Either name or Item instance which is child
*/
protected function removeChild($parent, $child)
{
if (is_string($parent)) {
$parent = $this->findItem($parent);
}
if (is_string($child)) {
$child = $this->findItem($child);
}
echo " > removing $child->name from $parent->name ...";
$time = microtime(true);
$this->authManager->removeChild($parent, $child);
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}

/**
* Assigns a role to a user.
*
Expand Down

0 comments on commit e19d75f

Please sign in to comment.