Skip to content

Instantly share code, notes, and snippets.

@Padam87
Last active June 4, 2017 14:52
Show Gist options
  • Save Padam87/25a331c348f5fe5f3b9ec21d4ffa55fe to your computer and use it in GitHub Desktop.
Save Padam87/25a331c348f5fe5f3b9ec21d4ffa55fe to your computer and use it in GitHub Desktop.
{
"@context":"\/app_dev.php\/contexts\/Error",
"@type":"hydra:Error",
"hydra:title":"An error occurred",
"hydra:description":"DateTime::__construct(): Failed to parse time string (asd) at position 0 (a): The timezone could not be found in the database",
"trace":[
{
"namespace":"",
"short_class":"",
"class":"",
"type":"",
"function":"",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer.php",
"line":94,
"args":[
]
},
{
"namespace":"Symfony\\Component\\Serializer\\Normalizer",
"short_class":"DateTimeNormalizer",
"class":"Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Serializer.php",
"line":292,
"args":[
[
"string",
"asd"
],
[
"string",
"DateTime"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"DateTime"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer",
"short_class":"Serializer",
"class":"Symfony\\Component\\Serializer\\Serializer",
"type":"-\u003E",
"function":"denormalizeObject",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Serializer.php",
"line":174,
"args":[
[
"string",
"asd"
],
[
"string",
"DateTime"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"DateTime"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer",
"short_class":"Serializer",
"class":"Symfony\\Component\\Serializer\\Serializer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line":289,
"args":[
[
"string",
"asd"
],
[
"string",
"DateTime"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"DateTime"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"ApiPlatform\\Core\\Serializer",
"short_class":"AbstractItemNormalizer",
"class":"ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type":"-\u003E",
"function":"denormalizeRelation",
"file":"C:\\xampp\\htdocs\\time\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line":185,
"args":[
[
"string",
"from"
],
[
"object",
"ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata"
],
[
"string",
"DateTime"
],
[
"string",
"asd"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"ApiPlatform\\Core\\Serializer",
"short_class":"AbstractItemNormalizer",
"class":"ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type":"-\u003E",
"function":"setAttributeValue",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer.php",
"line":202,
"args":[
[
"object",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"from"
],
[
"string",
"asd"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer\\Normalizer",
"short_class":"AbstractObjectNormalizer",
"class":"Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line":110,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
],
"cache_key":[
"string",
"9b5696532047a4d09ac470abb46fbf9a"
]
}
]
]
},
{
"namespace":"ApiPlatform\\Core\\Serializer",
"short_class":"AbstractItemNormalizer",
"class":"ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\api-platform\\core\\src\\JsonLd\\Serializer\\ItemNormalizer.php",
"line":107,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
],
"api_denormalize":[
"boolean",
true
]
}
]
]
},
{
"namespace":"ApiPlatform\\Core\\JsonLd\\Serializer",
"short_class":"ItemNormalizer",
"class":"ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Serializer.php",
"line":292,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer",
"short_class":"Serializer",
"class":"Symfony\\Component\\Serializer\\Serializer",
"type":"-\u003E",
"function":"denormalizeObject",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Serializer.php",
"line":174,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer",
"short_class":"Serializer",
"class":"Symfony\\Component\\Serializer\\Serializer",
"type":"-\u003E",
"function":"denormalize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\Serializer\\Serializer.php",
"line":132,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
]
}
]
]
},
{
"namespace":"Symfony\\Component\\Serializer",
"short_class":"Serializer",
"class":"Symfony\\Component\\Serializer\\Serializer",
"type":"-\u003E",
"function":"deserialize",
"file":"C:\\xampp\\htdocs\\time\\vendor\\api-platform\\core\\src\\EventListener\\DeserializeListener.php",
"line":69,
"args":[
[
"array",
{
"title":[
"string",
"asd"
],
"from":[
"string",
"asd"
],
"to":[
"null",
null
]
}
],
[
"string",
"AppBundle\\Entity\\TimeEntry"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups":[
"array",
[
[
"string",
"time_entry"
]
]
],
"collection_operation_name":[
"string",
"post"
],
"operation_type":[
"string",
"collection"
],
"api_allow_update":[
"boolean",
false
],
"resource_class":[
"string",
"AppBundle\\Entity\\TimeEntry"
],
"request_uri":[
"string",
"\/app_dev.php\/time_entries"
]
}
]
]
},
{
"namespace":"ApiPlatform\\Core\\EventListener",
"short_class":"DeserializeListener",
"class":"ApiPlatform\\Core\\EventListener\\DeserializeListener",
"type":"-\u003E",
"function":"onKernelRequest",
"file":"C:\\xampp\\htdocs\\time\\var\\cache\\dev\\appDevDebugProjectContainer.php",
"line":1520,
"args":[
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
]
]
},
{
"namespace":"",
"short_class":"appDevDebugProjectContainer",
"class":"appDevDebugProjectContainer",
"type":"-\u003E",
"function":"{closure}",
"file":null,
"line":null,
"args":[
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher"
]
]
},
{
"namespace":"",
"short_class":"",
"class":"",
"type":"",
"function":"call_user_func",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener.php",
"line":112,
"args":[
[
"object",
"Closure"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher"
]
]
},
{
"namespace":"Symfony\\Component\\EventDispatcher\\Debug",
"short_class":"WrappedListener",
"class":"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener",
"type":"-\u003E",
"function":"__invoke",
"file":null,
"line":null,
"args":[
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher"
]
]
},
{
"namespace":"",
"short_class":"",
"class":"",
"type":"",
"function":"call_user_func",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\EventDispatcher\\EventDispatcher.php",
"line":174,
"args":[
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher"
]
]
},
{
"namespace":"Symfony\\Component\\EventDispatcher",
"short_class":"EventDispatcher",
"class":"Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type":"-\u003E",
"function":"doDispatch",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\EventDispatcher\\EventDispatcher.php",
"line":43,
"args":[
[
"array",
[
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
]
]
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
]
]
},
{
"namespace":"Symfony\\Component\\EventDispatcher",
"short_class":"EventDispatcher",
"class":"Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type":"-\u003E",
"function":"dispatch",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher.php",
"line":146,
"args":[
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
]
]
},
{
"namespace":"Symfony\\Component\\EventDispatcher\\Debug",
"short_class":"TraceableEventDispatcher",
"class":"Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher",
"type":"-\u003E",
"function":"dispatch",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\HttpKernel.php",
"line":129,
"args":[
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent"
]
]
},
{
"namespace":"Symfony\\Component\\HttpKernel",
"short_class":"HttpKernel",
"class":"Symfony\\Component\\HttpKernel\\HttpKernel",
"type":"-\u003E",
"function":"handleRaw",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\HttpKernel.php",
"line":68,
"args":[
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
],
[
"integer",
1
]
]
},
{
"namespace":"Symfony\\Component\\HttpKernel",
"short_class":"HttpKernel",
"class":"Symfony\\Component\\HttpKernel\\HttpKernel",
"type":"-\u003E",
"function":"handle",
"file":"C:\\xampp\\htdocs\\time\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\Kernel.php",
"line":172,
"args":[
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
],
[
"integer",
1
],
[
"boolean",
true
]
]
},
{
"namespace":"Symfony\\Component\\HttpKernel",
"short_class":"Kernel",
"class":"Symfony\\Component\\HttpKernel\\Kernel",
"type":"-\u003E",
"function":"handle",
"file":"C:\\xampp\\htdocs\\time\\web\\app_dev.php",
"line":32,
"args":[
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
]
]
}
]
}
<?php
namespace AppBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use AppBundle\Entity\Traits\IdTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={"time_entry"}},
* "denormalization_context"={"groups"={"time_entry"}}
* }
* )
* @ORM\Entity()
*/
class TimeEntry
{
use IdTrait;
/**
* @var string
*
* @ORM\Column()
* @Assert\NotBlank()
* @Serializer\Groups({"time_entry"})
*/
protected $title;
/**
* @var \DateTime
*
* @ORM\Column(name="from_time", type="datetime")
* @Assert\NotBlank()
* @Assert\DateTime()
* @Serializer\Groups({"time_entry"})
*/
protected $from;
/**
* @var \DateTime
*
* @ORM\Column(name="to_time", type="datetime")
* @Assert\NotBlank()
* @Assert\DateTime()
* @Serializer\Groups({"time_entry"})
*/
protected $to;
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*
* @return TimeEntry
*/
public function setTitle($title) : TimeEntry
{
$this->title = $title;
return $this;
}
/**
* @return \DateTime
*/
public function getFrom()
{
return $this->from;
}
/**
* @param \DateTime $from
*
* @return TimeEntry
*/
public function setFrom(\DateTime $from) : TimeEntry
{
$this->from = $from;
return $this;
}
/**
* @return \DateTime
*/
public function getTo()
{
return $this->to;
}
/**
* @param \DateTime $to
*
* @return TimeEntry
*/
public function setTo(\DateTime $to) : TimeEntry
{
$this->to = $to;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment