I found a good solution in this post.
The short answer is to add
\Doctrine\ODM\MongoDB\Mapping\Types\Type::registeredType('mytype', 'My\Type\Class');
in MyBundleClass::__consruct()
. This will get the type registered before any warmup happens with the cache.
Using Type::registeredType()
instead of Type::addType()
will avoid checking to see if the type is already registered. In the case of Type::addType()
will throw an exception if it has already been added.