From 5d9d563db948c8b984aadb538e56d47f00db58d1 Mon Sep 17 00:00:00 2001 From: Liviu Balan Date: Sat, 10 Feb 2018 19:16:07 +0200 Subject: [PATCH] Add createdAt property + setter and getter "createdAt" property and "setCreatedAt" is not defined on section "Using Callbacks to Serialize Properties with Object Instances" so the PHP Fatal error is triggered: Call to undefined method Person::setCreatedAt() --- components/serializer.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index 98935c75aaa..88360575def 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -72,6 +72,7 @@ exists in your project:: private $age; private $name; private $sportsman; + private $createdAt; // Getters public function getName() @@ -84,6 +85,11 @@ exists in your project:: return $this->age; } + public function getCreatedAt() + { + return $this->createdAt; + } + // Issers public function isSportsman() { @@ -105,6 +111,11 @@ exists in your project:: { $this->sportsman = $sportsman; } + + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + } } Now, if you want to serialize this object into JSON, you only need to