I am using TYPO3 and I have in my extension my own model, controller and repository file. In the Backend I created a record which worked without any issues. But when I try to load the FE I get the following error in DataMapper.php
PHP Warning: class_parents(): object or string expected in /home/app/vendor/typo3/cms/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php line 284
00284: if ($propertyData['type'] === 'DateTime' || in_array('DateTime', class_parents($propertyData['type']))) {
I debugged it and found out that $propertyName contains the correct property name 'street' but $propertyData is an empty array.
My model looks like this:
<?php
namespace Snowflake\Htwapartmentexchange\Domain\Model;
use Snowflake\ApiRepository\Helpers\DateTime;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Apartment extends AbstractEntity
{
protected $apartmentType = '';
protected $street = '';
protected $zip = '';
protected $city = '';
protected $price = '';
protected $countRooms = '';
protected $area = '';
protected $availableDate = '';
protected $description = '';
protected $firstname = '';
protected $lastname = '';
protected $mobile = '';
protected $mail = '';
protected $pictures = null;
/**
* Apartment constructor.
* @param $apartmentType
* @param $street
* @param $zip
* @param $city
* @param $price
* @param $countRooms
* @param $area
* @param $availableDate
* @param $description
* @param $firstname
* @param $lastname
* @param $mobile
* @param $mail
* @param $pictures
*/
public function __construct($apartmentType, $street, $zip, $city, $price, $countRooms, $area, $availableDate, $description, $firstname, $lastname, $mobile, $mail, $pictures)
{
$this->apartmentType = $apartmentType;
$this->street = $street;
$this->zip = $zip;
$this->city = $city;
$this->price = $price;
$this->countRooms = $countRooms;
$this->area = $area;
$this->availableDate = $availableDate;
$this->description = $description;
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->mobile = $mobile;
$this->mail = $mail;
$this->pictures = $pictures;
}
/**
* @return mixed
*/
public function getApartmentType()
{
return $this->apartmentType;
}
/**
* @param mixed $apartmentType
*/
public function setApartmentType($apartmentType)
{
$this->apartmentType = $apartmentType;
}
/**
* @return mixed
*/
public function getStreet()
{
return $this->street;
}
/**
* @param mixed $street
*/
public function setStreet($street)
{
$this->street = $street;
}
/**
* @return mixed
*/
public function getZip()
{
return $this->zip;
}
/**
* @param mixed $zip
*/
public function setZip($zip)
{
$this->zip = $zip;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getPrice()
{
return $this->price;
}
/**
* @param mixed $price
*/
public function setPrice($price)
{
$this->price = $price;
}
/**
* @return mixed
*/
public function getCountRooms()
{
return $this->countRooms;
}
/**
* @param mixed $countRooms
*/
public function setCountRooms($countRooms)
{
$this->countRooms = $countRooms;
}
/**
* @return mixed
*/
public function getArea()
{
return $this->area;
}
/**
* @param mixed $area
*/
public function setArea($area)
{
$this->area = $area;
}
/**
* @return DateTime
*/
public function getAvailableDate()
{
return $this->availableDate;
}
/**
* @param DateTime $availableDate
*/
public function setAvailableDate($availableDate)
{
$this->availableDate = $availableDate;
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->description;
}
/**
* @param mixed $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return mixed
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* @param mixed $firstname
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
}
/**
* @return mixed
*/
public function getLastname()
{
return $this->lastname;
}
/**
* @param mixed $lastname
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
}
/**
* @return mixed
*/
public function getMobile()
{
return $this->mobile;
}
/**
* @param mixed $mobile
*/
public function setMobile($mobile)
{
$this->mobile = $mobile;
}
/**
* @return mixed
*/
public function getMail()
{
return $this->mail;
}
/**
* @param mixed $mail
*/
public function setMail($mail)
{
$this->mail = $mail;
}
/**
* @return mixed
*/
public function getPictures()
{
return $this->pictures;
}
/**
* @param mixed $pictures
*/
public function setPictures($pictures)
{
$this->pictures = $pictures;
}
}
Can you tell me what is wrong?
Found a solution.
The problem was that I didn't use PHPDoc comments on my model.
So I changed every property from this
protected $street = '';
to this
/**
* @var string
*/
protected $street = '';