File tree Expand file tree Collapse file tree 5 files changed +45
-3
lines changed Expand file tree Collapse file tree 5 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ a release.
3333- Timestampable: Support for custom column types (like Carbon).
3434- Translatable: Added an index to ` Translation ` entity to speed up searches using
3535 ` Gedmo\Translatable\Entity\Repository\TranslationRepository::findTranslations() ` method.
36+ - ` Gedmo\Mapping\Event\AdapterInterface::getObject() ` method.
3637
3738### Fixed
3839- Blameable, IpTraceable, Timestampable: Type handling for the tracked field values configured in the origin field.
@@ -49,6 +50,7 @@ a release.
4950- Tree: When using Closure tree strategy, it is deprecated not defining the mapping associations of the closure entity.
5051- ` Gedmo\Tool\Logging\DBAL\QueryAnalizer ` class without replacement.
5152- Using YAML mapping is deprecated, you SHOULD migrate to attributes, annotations or XML.
53+ - ` Gedmo\Mapping\Event\AdapterInterface::__call() ` method.
5254
5355### Changed
5456- In order to use a custom cache for storing configuration of an extension, the user has to call ` setCacheItemPool() `
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ class ODM implements AdapterInterface
3636
3737 public function __call ($ method , $ args )
3838 {
39+ @trigger_error (sprintf (
40+ 'Using "%s()" method is deprecated since gedmo/doctrine-extensions 3.x and will be removed in version 4.0. ' ,
41+ __METHOD__
42+ ), E_USER_DEPRECATED );
43+
3944 if (null === $ this ->args ) {
4045 throw new RuntimeException ('Event args must be set before calling its methods ' );
4146 }
@@ -86,7 +91,20 @@ public function getObjectManager()
8691 return $ this ->dm ;
8792 }
8893
89- return $ this ->__call ('getDocumentManager ' , []);
94+ if (null === $ this ->args ) {
95+ throw new \LogicException (sprintf ('Event args must be set before calling "%s()". ' , __METHOD__ ));
96+ }
97+
98+ return $ this ->args ->getDocumentManager ();
99+ }
100+
101+ public function getObject (): object
102+ {
103+ if (null === $ this ->args ) {
104+ throw new \LogicException (sprintf ('Event args must be set before calling "%s()". ' , __METHOD__ ));
105+ }
106+
107+ return $ this ->args ->getDocument ();
90108 }
91109
92110 public function getObjectState ($ uow , $ object )
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ class ORM implements AdapterInterface
3636
3737 public function __call ($ method , $ args )
3838 {
39+ @trigger_error (sprintf (
40+ 'Using "%s()" method is deprecated since gedmo/doctrine-extensions 3.x and will be removed in version 4.0. ' ,
41+ __METHOD__
42+ ), E_USER_DEPRECATED );
43+
3944 if (null === $ this ->args ) {
4045 throw new RuntimeException ('Event args must be set before calling its methods ' );
4146 }
@@ -86,7 +91,20 @@ public function getObjectManager()
8691 return $ this ->em ;
8792 }
8893
89- return $ this ->__call ('getEntityManager ' , []);
94+ if (null === $ this ->args ) {
95+ throw new \LogicException (sprintf ('Event args must be set before calling "%s()". ' , __METHOD__ ));
96+ }
97+
98+ return $ this ->args ->getEntityManager ();
99+ }
100+
101+ public function getObject (): object
102+ {
103+ if (null === $ this ->args ) {
104+ throw new \LogicException (sprintf ('Event args must be set before calling "%s()". ' , __METHOD__ ));
105+ }
106+
107+ return $ this ->args ->getEntity ();
90108 }
91109
92110 public function getObjectState ($ uow , $ object )
Original file line number Diff line number Diff line change 2222 * @author Gediminas Morkevicius <[email protected] > 2323 *
2424 * @method LifecycleEventArgs createLifecycleEventArgsInstance(object $object, ObjectManager $manager)
25+ * @method object getObject()
2526 */
2627interface AdapterInterface
2728{
2829 /**
30+ * @deprecated since gedmo/doctrine-extensions 3.x, will be removed in version 4.0.
31+ *
2932 * Calls a method on the event args object.
3033 *
3134 * @param string $method
Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ public function testAdapterBehavior(): void
5555 ->method ('getEntityManager ' );
5656
5757 $ eventArgsMock ->expects (static ::once ())
58- ->method ('getEntity ' );
58+ ->method ('getEntity ' )
59+ ->willReturn (new \stdClass ());
5960
6061 $ eventAdapter = new EventAdapterORM ();
6162 $ eventAdapter ->setEventArgs ($ eventArgsMock );
You can’t perform that action at this time.
0 commit comments