setVersioned() public method

public setVersioned ( string | boolean $versionable )
$versionable string | boolean A valid versionable annotation or false to disable versioning.
 /**
  * Adds inherited fields to the subclass mapping.
  *
  * @param ClassMetadata $subClass
  * @param ClassMetadata $parentClass
  */
 private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
 {
     foreach ($parentClass->fieldMappings as $fieldName) {
         $subClass->mapField($parentClass->mappings[$fieldName], $parentClass);
     }
     foreach ($parentClass->referenceMappings as $fieldName) {
         $mapping = $parentClass->mappings[$fieldName];
         if ($mapping['type'] == ClassMetadata::MANY_TO_ONE) {
             $subClass->mapManyToOne($mapping, $parentClass);
         } else {
             $subClass->mapManyToMany($mapping, $parentClass);
         }
     }
     foreach ($parentClass->childMappings as $fieldName) {
         $mapping = $parentClass->mappings[$fieldName];
         $subClass->mapChild($mapping, $parentClass);
     }
     foreach ($parentClass->childrenMappings as $fieldName) {
         $subClass->mapChildren($parentClass->mappings[$fieldName], $parentClass);
     }
     foreach ($parentClass->referrersMappings as $fieldName) {
         $subClass->mapReferrers($parentClass->mappings[$fieldName], $parentClass);
     }
     if ($parentClass->identifier) {
         $subClass->mapId($parentClass->mappings[$parentClass->identifier], $parentClass);
     }
     if ($parentClass->node) {
         $subClass->mapNode($parentClass->mappings[$parentClass->node], $parentClass);
     }
     if ($parentClass->nodename) {
         $subClass->mapNodename($parentClass->mappings[$parentClass->nodename], $parentClass);
     }
     if ($parentClass->parentMapping) {
         $subClass->mapParentDocument($parentClass->mappings[$parentClass->parentMapping], $parentClass);
     }
     if ($parentClass->localeMapping) {
         $subClass->mapLocale($parentClass->mappings[$parentClass->localeMapping], $parentClass);
     }
     if ($parentClass->versionNameField) {
         $subClass->mapVersionName($parentClass->mappings[$parentClass->versionNameField], $parentClass);
     }
     if ($parentClass->versionCreatedField) {
         $subClass->mapVersionCreated($parentClass->mappings[$parentClass->versionCreatedField], $parentClass);
     }
     if ($parentClass->lifecycleCallbacks) {
         $subClass->mapLifecycleCallbacks($parentClass->lifecycleCallbacks);
     }
     $subClass->setReferenceable($parentClass->referenceable);
     // Versionable defaults to false - only set on child class if it is non-false
     if ($parentClass->versionable) {
         $subClass->setVersioned($parentClass->versionable);
     }
     $subClass->setTranslator($parentClass->translator);
     $subClass->setNodeType($parentClass->nodeType);
     $subClass->setCustomRepositoryClassName($parentClass->customRepositoryClassName);
 }
 /**
  * @depends testClassName
  */
 public function testSerialize(ClassMetadata $cm)
 {
     $expected = 'O:40:"Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadata":20:{s:8:"nodeType";s:15:"nt:unstructured";s:10:"identifier";s:2:"id";s:4:"name";s:39:"Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person";s:11:"idGenerator";i:2;s:8:"mappings";a:5:{s:2:"id";a:7:{s:9:"fieldName";s:2:"id";s:2:"id";b:1;s:8:"strategy";s:8:"assigned";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;s:8:"property";s:2:"id";}s:8:"username";a:5:{s:9:"fieldName";s:8:"username";s:8:"property";s:8:"username";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:7:"created";a:5:{s:9:"fieldName";s:7:"created";s:8:"property";s:7:"created";s:4:"type";s:8:"datetime";s:10:"multivalue";b:0;s:8:"nullable";b:0;}s:6:"locale";a:3:{s:9:"fieldName";s:6:"locale";s:4:"type";s:6:"locale";s:8:"property";s:6:"locale";}s:15:"translatedField";a:7:{s:9:"fieldName";s:15:"translatedField";s:10:"translated";b:1;s:8:"property";s:15:"translatedField";s:4:"type";s:6:"string";s:10:"multivalue";b:0;s:5:"assoc";N;s:8:"nullable";b:0;}}s:13:"fieldMappings";a:4:{i:0;s:2:"id";i:1;s:8:"username";i:2;s:7:"created";i:3;s:15:"translatedField";}s:17:"referenceMappings";a:0:{}s:17:"referrersMappings";a:0:{}s:22:"mixedReferrersMappings";a:0:{}s:16:"childrenMappings";a:0:{}s:13:"childMappings";a:0:{}s:25:"customRepositoryClassName";s:51:"Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\DocumentRepository";s:18:"isMappedSuperclass";b:1;s:11:"versionable";b:1;s:14:"uniqueNodeType";b:1;s:18:"lifecycleCallbacks";a:1:{s:8:"postLoad";a:1:{i:0;s:8:"callback";}}s:13:"inheritMixins";b:1;s:13:"localeMapping";s:6:"locale";s:10:"translator";s:9:"attribute";s:18:"translatableFields";a:1:{i:0;s:15:"translatedField";}}';
     $cm->setCustomRepositoryClassName('DocumentRepository');
     $cm->setVersioned(true);
     $cm->setUniqueNodeType(true);
     $cm->addLifecycleCallback('callback', 'postLoad');
     $cm->isMappedSuperclass = true;
     $this->assertEquals($expected, serialize($cm));
 }