Shopware 6: Cannot access private property Namespace\Class::$property
Fabian Blechschmidt
You have this error? More trace is at the end of the post.
The properties of your Entity need to be protected.
// WRONG.
class SlotExtensionEntity extends Entity
{
use EntityIdTrait;
private int $slotId;
private int $ticketsBeforeWaitlist;
private SlotEntity $slot;
// [...]
}
// Correct.
class SlotExtensionEntity extends Entity
{
use EntityIdTrait;
protected int $slotId;
protected int $ticketsBeforeWaitlist;
protected SlotEntity $slot;
// [...]
}
"errors": [
{
"code": "0",
"status": "500",
"title": "Internal Server Error",
"detail": "Cannot access private property WinkelwagenEvents\\Entities\\Slot\\SlotExtensionEntity::$slot",
"meta": {
"trace": [
{
"file": "/var/www/html/vendor/shopware/core/Framework/DataAbstractionLayer/Entity.php",
"line": 82,
"function": "__get",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Entity",
"type": "->",
"args": [
"slot"
]
},
{
"file": "/var/www/html/vendor/shopware/core/Framework/Api/Serializer/JsonApiEncoder.php",
"line": 89,
"function": "get",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Entity",
"type": "->",
"args": [
"slot"
]
},
[...]
Other articles from this category
PHPStorm/IDEA, composer updates and 100% CPU
In one of our projects PHPStorm ran a while on 100% CPU, an investigation showed, that the process „checking for available composer updates“ ran and used all the resources. Most likely it got stuck somewhere. To get rid of the problem, one can turn off this feature. In IDEA Ultimate here: [Settings] -> Languages & […]
Custom Fields, dots and MySQL’s JSON_EXTRACT
We all know custom fields – hopefully – at least this is not about the basics. You can add custom fields to nearly all entites: orders, products, categories, … You can name them whatever you like, e.g. pluginname.property – but using dots . in your custom field name is a bad idea, because then you […]
gpg failed to sign the data
I was doing some work, when suddenly my git failed to commit changed. I dig a little around, asked StackOverflow but it didn’t help. Finally when running the commit manually and not through PHPStorm I got a proper error: Ah! The key is expired! Got it. Did you know you can extend a GPG key? […]