-
-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for serializing new doctrine ODM proxy objects
- Loading branch information
Hafsah Haynes
committed
Nov 12, 2019
1 parent
90c670f
commit 92e2955
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JMS\Serializer\Tests\Fixtures; | ||
|
||
use Closure; | ||
use ProxyManager\Proxy\LazyLoadingInterface; | ||
|
||
class SimpleObjectLazyLoading extends SimpleObject implements LazyLoadingInterface | ||
{ | ||
public $__isInitialized__ = false; | ||
|
||
private $initializer; | ||
|
||
private $baz = 'baz'; | ||
|
||
public function __load() | ||
{ | ||
if (!$this->__isInitialized__) { | ||
$this->camelCase = 'proxy-boo'; | ||
$this->__isInitialized__ = true; | ||
} | ||
} | ||
|
||
public function __isInitialized() | ||
{ | ||
return $this->__isInitialized__; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setProxyInitializer(?Closure $initializer = null) | ||
{ | ||
$this->initializer = $initializer; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getProxyInitializer(): ?Closure | ||
{ | ||
return $this->initializer; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function initializeProxy(): bool | ||
{ | ||
if (!$this->__isInitialized__) { | ||
$this->camelCase = 'proxy-boo'; | ||
$this->__isInitialized__ = true; | ||
|
||
return !$this->initializer || call_user_func($this->initializer); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isProxyInitialized(): bool | ||
{ | ||
return $this->__isInitialized__; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters