本文整理汇总了PHP中Documents\User::setProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setProfile方法的具体用法?PHP User::setProfile怎么用?PHP User::setProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Documents\User
的用法示例。
在下文中一共展示了User::setProfile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->ids = array();
$groupA = new Group('groupA');
$groupB = new Group('groupB');
$profile = new Profile();
$profile->setFirstname('Timothy');
$tim = new User();
$tim->setUsername('Tim');
$tim->setHits(10);
$tim->addGroup($groupA);
$tim->addGroup($groupB);
$tim->setProfile($profile);
$this->dm->persist($tim);
$john = new User();
$john->setUsername('John');
$john->setHits(10);
$this->dm->persist($john);
$this->dm->flush();
$this->dm->clear();
$this->ids['tim'] = $tim->getId();
$this->ids['john'] = $john->getId();
$this->fc = $this->dm->getFilterCollection();
}
示例2: testLazyLoadReference
public function testLazyLoadReference()
{
$user = new User();
$profile = new Profile();
$profile->setFirstName('Jonathan');
$profile->setLastName('Wage');
$user->setProfile($profile);
$user->setUsername('jwage');
$this->dm->persist($user);
$this->dm->flush();
$this->dm->clear();
$query = $this->dm->createQuery('Documents\\User')->where('id', $user->getId());
$user = $query->getSingleResult();
$profile = $user->getProfile();
$this->assertTrue($profile instanceof \Proxies\DocumentsProfileProxy);
$profile->getFirstName();
$this->assertEquals('Jonathan', $profile->getFirstName());
$this->assertEquals('Wage', $profile->getLastName());
}
示例3: testDocumentNotFoundExceptionWithMongoId
/**
* @expectedException \Doctrine\ODM\MongoDB\DocumentNotFoundException
* @expectedExceptionMessage The "Proxies\__CG__\Documents\Profile" document with identifier "abcdefabcdefabcdefabcdef" could not be found.
*/
public function testDocumentNotFoundExceptionWithMongoId()
{
$profile = new Profile();
$user = new User();
$user->setProfile($profile);
$this->dm->persist($profile);
$this->dm->persist($user);
$this->dm->flush();
$this->dm->clear();
$collection = $this->dm->getDocumentCollection(get_class($user));
$invalidId = new \MongoId('abcdefabcdefabcdefabcdef');
$collection->update(array('_id' => new \MongoId($user->getId())), array('$set' => array('profile.$id' => $invalidId)));
$user = $this->dm->find(get_class($user), $user->getId());
$profile = $user->getProfile();
$profile->__load();
}
示例4: testDocumentNotFoundEvent
public function testDocumentNotFoundEvent()
{
$profile = new Profile();
$user = new User();
$user->setProfile($profile);
$this->dm->persist($profile);
$this->dm->persist($user);
$this->dm->flush();
$this->dm->clear();
$collection = $this->dm->getDocumentCollection(get_class($user));
$invalidId = new \MongoId('abcdefabcdefabcdefabcdef');
$collection->update(array('_id' => new \MongoId($user->getId())), array('$set' => array('profile.$id' => $invalidId)));
$user = $this->dm->find(get_class($user), $user->getId());
$profile = $user->getProfile();
$closure = function (DocumentNotFoundEventArgs $eventArgs) use($profile) {
$this->assertFalse($eventArgs->isExceptionDisabled());
$this->assertSame($profile, $eventArgs->getObject());
$eventArgs->disableException();
};
$this->dm->getEventManager()->addEventListener(Events::documentNotFound, new DocumentNotFoundListener($closure));
$profile->__load();
}
示例5: Configuration
$classLoader->register();
$config = new Configuration();
/*
$config->setLoggerCallable(function(array $log) {
print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
//$config->setMetadataDriverImpl(new XmlDriver(__DIR__ . '/xml'));
//$config->setMetadataDriverImpl(new YamlDriver(__DIR__ . '/yaml'));
//$config->setMetadataDriverImpl(new PHPDriver());
$dm = DocumentManager::create(new Mongo(), $config);
$profile = new Profile();
$profile->setName('Jonathan H. Wage');
$profile->addSong(new Song('Testinfuckckcg'));
$user = new User();
$user->setUsername('jwage');
$user->setPassword('changeme');
$user->addPhonenumber(new Phonenumber('6155139185'));
$user->setProfile($profile);
$configuration = new ConfigurationDoc();
$configuration->setTimezone('Eastern');
$configuration->setTheme('doctrine');
$user->setConfiguration($configuration);
$dm->persist($user);
$dm->flush();