当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::setDefaultDiscriminatorValue方法代码示例

本文整理汇总了PHP中Doctrine\ODM\MongoDB\Mapping\ClassMetadata::setDefaultDiscriminatorValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::setDefaultDiscriminatorValue方法的具体用法?PHP ClassMetadata::setDefaultDiscriminatorValue怎么用?PHP ClassMetadata::setDefaultDiscriminatorValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\MongoDB\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::setDefaultDiscriminatorValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadMetadata

 public static function loadMetadata(ClassMetadata $metadata)
 {
     $metadata->setInheritanceType(ClassMetadata::INHERITANCE_TYPE_NONE);
     $metadata->setCollection('cms_users');
     $metadata->addLifecycleCallback('doStuffOnPrePersist', 'prePersist');
     $metadata->addLifecycleCallback('doOtherStuffOnPrePersistToo', 'prePersist');
     $metadata->addLifecycleCallback('doStuffOnPostPersist', 'postPersist');
     $metadata->setDiscriminatorField(array('fieldName' => 'discr'));
     $metadata->setDiscriminatorMap(array('default' => __CLASS__));
     $metadata->setDefaultDiscriminatorValue('default');
     $metadata->mapField(array('id' => true, 'fieldName' => 'id'));
     $metadata->mapField(array('fieldName' => 'version', 'type' => 'int', 'version' => true));
     $metadata->mapField(array('fieldName' => 'lock', 'type' => 'int', 'lock' => true));
     $metadata->mapField(array('fieldName' => 'name', 'name' => 'username', 'type' => 'string'));
     $metadata->mapField(array('fieldName' => 'email', 'type' => 'string'));
     $metadata->mapField(array('fieldName' => 'mysqlProfileId', 'type' => 'integer'));
     $metadata->mapOneReference(array('fieldName' => 'address', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\Address', 'cascade' => array(0 => 'remove')));
     $metadata->mapManyReference(array('fieldName' => 'phonenumbers', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\Phonenumber', 'cascade' => array(1 => 'persist'), 'discriminatorField' => 'discr', 'discriminatorMap' => array('home' => 'HomePhonenumber', 'work' => 'WorkPhonenumber'), 'defaultDiscriminatorValue' => 'home'));
     $metadata->mapManyReference(array('fieldName' => 'morePhoneNumbers', 'name' => 'more_phone_numbers', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\Phonenumber'));
     $metadata->mapManyReference(array('fieldName' => 'groups', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\Group', 'cascade' => array(0 => 'remove', 1 => 'persist', 2 => 'refresh', 3 => 'merge', 4 => 'detach')));
     $metadata->mapOneEmbedded(array('fieldName' => 'embeddedPhonenumber', 'name' => 'embedded_phone_number'));
     $metadata->mapManyEmbedded(array('fieldName' => 'otherPhonenumbers', 'targetDocument' => 'Doctrine\\ODM\\MongoDB\\Tests\\Mapping\\Phonenumber', 'discriminatorField' => 'discr', 'discriminatorMap' => array('home' => 'HomePhonenumber', 'work' => 'WorkPhonenumber'), 'defaultDiscriminatorValue' => 'home'));
     $metadata->addIndex(array('username' => 'desc'), array('unique' => true, 'dropDups' => false));
     $metadata->addIndex(array('email' => 'desc'), array('unique' => true, 'dropDups' => true));
     $metadata->addIndex(array('mysqlProfileId' => 'desc'), array('unique' => true, 'dropDups' => true));
     $metadata->addIndex(array('createdAt' => 'asc'), array('expireAfterSeconds' => 3600));
     $metadata->setShardKey(array('name' => 'asc'), array('unique' => true, 'numInitialChunks' => 4096));
 }
开发者ID:dominium,项目名称:mongodb-odm,代码行数:28,代码来源:AbstractMappingDriverTest.php


注:本文中的Doctrine\ODM\MongoDB\Mapping\ClassMetadata::setDefaultDiscriminatorValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。