Skip to content

Commit 930a9fa

Browse files
authored
Deprecate AbstractWrapper::clear() and WrapperInterface::populate() methods
1 parent c3d13b8 commit 930a9fa

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ a release.
5151
- `Gedmo\Tool\Logging\DBAL\QueryAnalizer` class without replacement.
5252
- Using YAML mapping is deprecated, you SHOULD migrate to attributes, annotations or XML.
5353
- `Gedmo\Mapping\Event\AdapterInterface::__call()` method.
54+
- `Gedmo\Tool\Wrapper\AbstractWrapper::clear()` method.
55+
- `Gedmo\Tool\Wrapper\WrapperInterface::populate()` method.
5456

5557
### Changed
5658
- In order to use a custom cache for storing configuration of an extension, the user has to call `setCacheItemPool()`

src/Sluggable/SluggableListener.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Gedmo\Sluggable\Handler\SlugHandlerWithUniqueCallbackInterface;
1818
use Gedmo\Sluggable\Mapping\Event\SluggableAdapter;
1919
use Gedmo\Sluggable\Util\Urlizer;
20-
use Gedmo\Tool\Wrapper\AbstractWrapper;
2120

2221
/**
2322
* The SluggableListener handles the generation of slugs
@@ -241,8 +240,6 @@ public function onFlush(EventArgs $args)
241240
}
242241

243242
$this->manageFiltersAfterGeneration($om);
244-
245-
AbstractWrapper::clear();
246243
}
247244

248245
protected function getNamespace()

src/Tool/Wrapper/AbstractWrapper.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ abstract class AbstractWrapper implements WrapperInterface
4545
*/
4646
protected $om;
4747

48-
/**
49-
* List of wrapped object references
50-
*
51-
* @var array
52-
*/
53-
private static $wrappedObjectReferences;
54-
5548
/**
5649
* Wrap object factory method
5750
*
@@ -78,7 +71,10 @@ public static function wrap($object, ObjectManager $om)
7871
*/
7972
public static function clear()
8073
{
81-
self::$wrappedObjectReferences = [];
74+
@trigger_error(sprintf(
75+
'Using "%s()" method is deprecated since gedmo/doctrine-extensions 3.x and will be removed in version 4.0.',
76+
__METHOD__
77+
), E_USER_DEPRECATED);
8278
}
8379

8480
public function getObject()
@@ -93,6 +89,11 @@ public function getMetadata()
9389

9490
public function populate(array $data)
9591
{
92+
@trigger_error(sprintf(
93+
'Using "%s()" method is deprecated since gedmo/doctrine-extensions 3.x and will be removed in version 4.0.',
94+
__METHOD__
95+
), E_USER_DEPRECATED);
96+
9697
foreach ($data as $field => $value) {
9798
$this->setPropertyValue($field, $value);
9899
}

src/Tool/WrapperInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public function getPropertyValue($property);
4545
public function setPropertyValue($property, $value);
4646

4747
/**
48+
* @deprecated since gedmo/doctrine-extensions 3.x and to be removed in version 4.0.
49+
*
4850
* Populates the wrapped object with the given property values.
4951
*
5052
* @return $this

tests/Gedmo/Wrapper/EntityWrapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testSomeFunctions(): void
8888
$test = new Article();
8989
$wrapped = new EntityWrapper($test, $this->em);
9090

91-
$wrapped->populate(['title' => 'test']);
91+
$test->setTitle('test');
9292
static::assertSame('test', $wrapped->getPropertyValue('title'));
9393

9494
static::assertFalse($wrapped->hasValidIdentifier());

tests/Gedmo/Wrapper/MongoDocumentWrapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testSomeFunctions(): void
8686
$test = new Article();
8787
$wrapped = new MongoDocumentWrapper($test, $this->dm);
8888

89-
$wrapped->populate(['title' => 'test']);
89+
$test->setTitle('test');
9090
static::assertSame('test', $wrapped->getPropertyValue('title'));
9191

9292
static::assertFalse($wrapped->hasValidIdentifier());

0 commit comments

Comments
 (0)