Skip to content

Commit 18cb464

Browse files
authored
Merge pull request #199 from symfony-cmf/add_deprecation_triggers
Added deprecation messages
2 parents 2795f93 + 70bfb6a commit 18cb464

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ cache:
1515
- $HOME/.composer/cache/files
1616

1717
env:
18-
global:
19-
- SYMFONY_DEPRECATIONS_HELPER=7
18+
matrix: SYMFONY_VERSION=2.8.*
19+
global: SYMFONY_DEPRECATIONS_HELPER=7
2020

2121
matrix:
2222
include:

DependencyInjection/Compiler/RequestAwarePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function process(ContainerBuilder $container)
3131
{
3232
$services = $container->findTaggedServiceIds('cmf_request_aware');
3333
foreach ($services as $id => $attributes) {
34-
trigger_error("Service $id is using the deprecated tag cmf_request_aware");
34+
@trigger_error('The cmf_request_aware tag used by "'.$id.'" is deprecated since 1.1 and will be removed in 2.0. Use the "request_stack" service instead.', E_USER_DEPRECATED);
3535

3636
$definition = $container->getDefinition($id);
3737
$definition

Templating/Helper/CmfHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ class CmfHelper extends Helper
6262
public function __construct(SecurityContextInterface $publishWorkflowChecker = null, $registry = null, $managerName = null)
6363
{
6464
$this->publishWorkflowChecker = $publishWorkflowChecker;
65-
$this->setDoctrineRegistry($registry, $managerName);
65+
66+
if (null !== $registry) {
67+
@trigger_error('The second and third argument of '.__METHOD__.' is deprecated since 1.3 and will be removed in 2.0. Execute setDoctrineRegistry() instead.', E_USER_DEPRECATED);
68+
$this->setDoctrineRegistry($registry, $managerName);
69+
}
6670
}
6771

6872
/**

Tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function setUp()
3838
->will($this->returnValue(true))
3939
;
4040

41-
$this->helper = new CmfHelper($this->pwc, $dbManager->getRegistry(), 'default');
41+
$this->helper = new CmfHelper($this->pwc);
42+
$this->helper->setDoctrineRegistry($dbManager->getRegistry(), 'default');
4243
}
4344

4445
public function testGetDescendants()

Tests/Unit/Templating/Helper/CmfHelperTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function setUp()
5757
->will($this->returnValue($this->uow))
5858
;
5959

60-
$this->extension = new CmfHelper($this->pwc, $this->managerRegistry, 'foo');
60+
$this->extension = new CmfHelper($this->pwc);
61+
$this->extension->setDoctrineRegistry($this->managerRegistry, 'foo');
6162
}
6263

6364
public function testGetNodeName()
@@ -210,7 +211,8 @@ public function testFindManyLimitOffset()
210211
*/
211212
public function testFindManyNoWorkflow()
212213
{
213-
$this->extension = new CmfHelper(null, $this->managerRegistry, 'foo');
214+
$extension = new CmfHelper(null);
215+
$extension->setDoctrineRegistry($this->managerRegistry, 'foo');
214216

215217
$documentA = new \stdClass();
216218

@@ -220,7 +222,7 @@ public function testFindManyNoWorkflow()
220222
->will($this->returnValue($documentA))
221223
;
222224

223-
$this->extension->findMany(array('/foo', '/bar'), false, false);
225+
$extension->findMany(array('/foo', '/bar'), false, false);
224226
}
225227

226228
public function testIsPublished()
@@ -244,8 +246,10 @@ public function testIsPublished()
244246
*/
245247
public function testIsPublishedNoWorkflow()
246248
{
247-
$this->extension = new CmfHelper(null, $this->managerRegistry, 'foo');
248-
$this->extension->isPublished(new \stdClass());
249+
$extension = new CmfHelper(null);
250+
$extension->setDoctrineRegistry($this->managerRegistry, 'foo');
251+
252+
$extension->isPublished(new \stdClass());
249253
}
250254

251255
public function testIsLinkable()

0 commit comments

Comments
 (0)