The exception [InvalidArgumentValueException('Could not serialize Domain Object $className. It is neither an Entity with identity properties set, nor a Value Object.', 1260881688)][1]
is thrown in the UriBuilder
, thus when a model shall be used as argument for creating a link.
The instance of Vendor\Extension\Domain\Model\Object
must either fulfill these requirements:
- can be represented as array (is array or implements
Iterator
interface) OR
- extends
TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject
AND one of
- extends
TYPO3\CMS\Extbase\DomainObject\AbstractValueObject
OR
- having a valid
uid
, not null
Thus, if you instantiated the object directly in the controller, the uid
property is not defined yet. This property is assigned if domain objects are fetched or added with a repository.
TypeConverters
TypeConverters allow to convert from a given identifier (some string representation, hash-value, ...) to a proper domain object. The following links show how to do that for the concept of an IBAN (International Bank Account Identifier).
TypeConverters have to registerd in ext_localconf.php
like this:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter(
\H4ck3r31\BankAccountExample\Domain\Property\TypeConverter\IbanTypeConverter::class
);
The Iban
object can be used then in your controller:
public function someAction(Iban $iban) { ... }
Use array representation of your object
Another alternative could be to assign an array representation of the domain object to the view and use that to fill the link arguments:
$this->view->assign('myObject', $object->toArray());
When invoking a controller action, the object is reconstituted from the submitted array keys and are used as properties - thus array keys and properties must have the same naming, or a persistence column mapping is defined.
public function someAction(MyObject $object) { ... }
In my previously mentioned bank account example it looks like this:
The term "Dto" is the abbreviation for "Data Transfer Object", thus it's not a real domain entity, does not have a proper UID and is just used to encapsulate information in a domain object when passing that to different components.