Skip to content

Commit 126abce

Browse files
Adding support for removing features
1 parent 2c2f979 commit 126abce

6 files changed

Lines changed: 48 additions & 2 deletions

File tree

Controller/DefaultController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ public function deactivateUserAction($feature, $id)
143143
return new RedirectResponse($this->container->get('router')->generate('opensoft_rollout'));
144144
}
145145

146+
/**
147+
* @param string $feature
148+
* @return RedirectResponse
149+
*/
150+
public function removeAction($feature)
151+
{
152+
$this->getRollout()->remove($feature);
153+
154+
$this->addFlash('info', sprintf("Feature '%s' was removed from rollout.", $feature));
155+
156+
return new RedirectResponse($this->container->get('router')->generate('opensoft_rollout'));
157+
}
158+
146159
/**
147160
* @return Rollout
148161
*/

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class AcmeEmployeeGroupDefinition implements GroupDefinitionInterface
127127

128128
Implement a custom storage solution.
129129

130+
**Note:** The rollout `StorageInterface` [changed](https://github.com/opensoft/rollout/releases/tag/2.0.0) in version `2.0.0`.
131+
130132
```php
131133
<?php
132134
@@ -151,6 +153,15 @@ class MyStorage implements StorageInterface
151153
{
152154
// implement set
153155
}
156+
157+
/**
158+
* @param string $key
159+
* @since 2.0.0
160+
*/
161+
public function remove($key)
162+
{
163+
// implement remove
164+
}
154165
}
155166
```
156167

Resources/config/routing.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ opensoft_rollout_feature_deactivate_user:
4343
path: /{feature}/deactivate-user/{id}
4444
defaults:
4545
_controller: OpensoftRolloutBundle:Default:deactivateUser
46+
47+
opensoft_rollout_feature_remove:
48+
path: /{feature}/remove
49+
defaults:
50+
_controller: OpensoftRolloutBundle:Default:remove

Resources/views/Default/index.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,17 @@
148148
</ul>
149149
</td>
150150
<td>
151+
{% block rollout_feature_actions %}
151152
<a class="btn btn-default btn-sm" href="{{ path('opensoft_rollout_feature_activate', {'feature': feature.name }) }}" title="Globally activate this feature">
152153
activate
153154
</a>
154155
<a class="btn btn-default btn-sm" href="{{ path('opensoft_rollout_feature_deactivate', {'feature': feature.name }) }}" title="Globally deactivate this feature">
155156
deactivate
156157
</a>
158+
<a class="btn btn-default btn-sm" href="{{ path('opensoft_rollout_feature_remove', {'feature': feature.name }) }}" title="Globally remove this feature">
159+
remove
160+
</a>
161+
{% endblock %}
157162
</td>
158163
</tr>
159164

Storage/Doctrine/DoctrineORMStorage.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ public function set($key, $value)
6969
$feature->setSettings($value);
7070

7171
$this->em->persist($feature);
72-
$this->em->flush();
72+
$this->em->flush($feature);
73+
}
74+
75+
/**
76+
* @param string $key
77+
*/
78+
public function remove($key)
79+
{
80+
$feature = $this->repository->findOneBy(array('name' => $key));
81+
if ($feature) {
82+
$this->em->remove($feature);
83+
$this->em->flush($feature);
84+
}
7385
}
7486
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"require": {
1212
"php": ">=5.3",
1313
"symfony/framework-bundle": "~2.1",
14-
"opensoft/rollout": "~1.0"
14+
"opensoft/rollout": "~2.0"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": "*"

0 commit comments

Comments
 (0)