本文整理匯總了PHP中Doctrine\ODM\PHPCR\DocumentManager::getPhpcrSession方法的典型用法代碼示例。如果您正苦於以下問題:PHP DocumentManager::getPhpcrSession方法的具體用法?PHP DocumentManager::getPhpcrSession怎麽用?PHP DocumentManager::getPhpcrSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::getPhpcrSession方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\ODM\\PHPCR\\Functional\\QuerySql2TestObj';
$this->dm = $this->createDocumentManager();
$this->node = $this->resetFunctionalNode($this->dm);
$versionNode = $this->node->addNode('node1', 'nt:unstructured');
$versionNode->setProperty('username', 'dbu');
$versionNode->setProperty('numbers', array(3, 1, 2));
$versionNode->setProperty('phpcr:class', $this->type);
$versionNode = $this->node->addNode('node2', 'nt:unstructured');
$versionNode->setProperty('username', 'johannes');
$versionNode->setProperty('numbers', array(3, 1, 2));
$versionNode->setProperty('phpcr:class', $this->type);
$versionNode = $this->node->addNode('node3', 'nt:unstructured');
$versionNode->setProperty('username', 'lsmith');
$versionNode->setProperty('numbers', array(3, 1, 2));
$versionNode->setProperty('phpcr:class', $this->type);
$versionNode = $this->node->addNode('node4', 'nt:unstructured');
$versionNode->setProperty('username', 'uwe');
$versionNode->setProperty('numbers', array(3, 1, 2));
$versionNode->setProperty('phpcr:class', $this->type);
$versionNode = $this->node->addNode('node5', 'nt:unstructured');
$versionNode->setProperty('numbers', array(3, 1, 2));
$this->dm->getPhpcrSession()->save();
$this->dm = $this->createDocumentManager();
}
示例2: testSaveTranslation
public function testSaveTranslation()
{
// First save some translations
$data = array();
$data['topic'] = 'Some interesting subject';
$data['text'] = 'Lorem ipsum...';
$node = $this->getTestNode();
$strategy = new ChildTranslationStrategy($this->dm);
$strategy->saveTranslation($data, $node, $this->metadata, 'en');
// Save translation in another language
$data['topic'] = 'Un sujet intéressant';
$strategy->saveTranslation($data, $node, $this->metadata, 'fr');
$this->dm->getPhpcrSession()->save();
// Then test we have what we expect in the content repository
$node_en = $this->session->getNode($this->nodeNameForLocale('en'));
$node_fr = $this->session->getNode($this->nodeNameForLocale('fr'));
$this->assertTrue($node_en->hasProperty('topic'));
$this->assertTrue($node_fr->hasProperty('topic'));
$this->assertTrue($node_en->hasProperty('text'));
$this->assertTrue($node_fr->hasProperty('text'));
$this->assertFalse($node_fr->hasProperty('author'));
$this->assertFalse($node_en->hasProperty('author'));
$this->assertEquals('Some interesting subject', $node_en->getPropertyValue('topic'));
$this->assertEquals('Un sujet intéressant', $node_fr->getPropertyValue('topic'));
$this->assertEquals('Lorem ipsum...', $node_en->getPropertyValue('text'));
$this->assertEquals('Lorem ipsum...', $node_fr->getPropertyValue('text'));
}
示例3: setUp
public function setUp()
{
$this->dm = $this->createDocumentManager();
$this->node = $this->resetFunctionalNode($this->dm);
$session = $this->dm->getPhpcrSession();
if (!$session instanceof \Jackalope\Session) {
$this->markTestSkipped('Not a Jackalope session');
}
$cnd = <<<CND
<test='http://test.fr'>
[test:protected_property_test] > nt:hierarchyNode
- reference (REFERENCE)
- changeme (STRING)
CND;
$cnd2 = <<<CND
<test='http://test.fr'>
[test:protected_property_test2] > nt:hierarchyNode
- reference (REFERENCE)
- reference2 (REFERENCE)
CND;
$ntm = $session->getWorkspace()->getNodeTypeManager();
try {
$ntm->registerNodeTypesCnd($cnd, true);
$ntm->registerNodeTypesCnd($cnd2, true);
} catch (\PHPCR\UnsupportedRepositoryOperationException $e) {
$this->markTestSkipped('CND parsing not supported');
}
}
示例4: setUp
public function setUp()
{
$this->dm = $this->createDocumentManager(array(__DIR__));
$repository = $this->dm->getPhpcrSession()->getRepository();
if (!$repository->getDescriptor('node.type.management.orderable.child.nodes.supported')) {
$this->markTestSkipped('PHPCR repository doesn\'t support orderable child nodes');
}
$this->node = $this->resetFunctionalNode($this->dm);
$parent = $this->dm->find(null, $this->node->getPath());
$node1 = new Generic();
$node1->setParentDocument($parent);
$node1->setNodename('source');
$this->dm->persist($node1);
$this->childrenNames = array('first', 'second', 'third', 'fourth');
foreach ($this->childrenNames as $childName) {
$child = new Generic();
$child->setNodename($childName);
$child->setParentDocument($node1);
$this->dm->persist($child);
}
$node2 = new Generic();
$node2->setNodename('target');
$node2->setParentDocument($parent);
$this->dm->persist($node2);
$this->dm->flush();
$this->dm->clear();
}
示例5: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\Models\\CMS\\CmsUser';
$this->dm = $this->createDocumentManager(array(__DIR__));
$this->node = $this->resetFunctionalNode($this->dm);
$user = $this->node->addNode('lsmith');
$user->setProperty('username', 'lsmith');
$user->setProperty('numbers', array(3, 1, 2));
$user->setProperty('phpcr:class', $this->type, \PHPCR\PropertyType::STRING);
$this->dm->getPhpcrSession()->save();
}
示例6: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\Models\\CMS\\CmsUser';
$this->dm = $this->createDocumentManager();
$session = $this->dm->getPhpcrSession();
$root = $session->getNode('/');
if ($root->hasNode('functional')) {
$root->getNode('functional')->remove();
$session->save();
}
$this->node = $root->addNode('functional');
$session->save();
}
示例7: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\ODM\\PHPCR\\Functional\\TypeUser';
$this->dm = $this->createDocumentManager(array(__DIR__));
$this->node = $this->resetFunctionalNode($this->dm);
$user = $this->node->addNode('user');
$user->setProperty('username', 'lsmith');
$user->setProperty('note', 'test');
$user->setProperty('numbers', array(3, 1, 2));
$user->setProperty('parameters', array('bar', 'dong'));
$user->setProperty('parameterKey', array('foo', 'ding'));
$user->setProperty('phpcr:class', $this->type, PropertyType::STRING);
$this->dm->getPhpcrSession()->save();
}
示例8: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\Models\\Translation\\Article';
$this->dm = $this->createDocumentManager();
$this->dm->setLocaleChooserStrategy(new LocaleChooser(array('en' => array('fr'), 'fr' => array('en')), 'en'));
$this->node = $this->resetFunctionalNode($this->dm);
$user = $this->node->addNode('thename');
$user->setProperty('phpcr:class', $this->type, \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:fr-topic', 'french', \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:fr-text', 'french text', \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:frnullfields', array('nullable'), \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:en-topic', 'english', \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:en-text', 'english text', \PHPCR\PropertyType::STRING);
$user->setProperty('phpcr_locale:ennullfields', array('nullable'), \PHPCR\PropertyType::STRING);
$this->dm->getPhpcrSession()->save();
}
示例9: __construct
/**
* Constructor
*
* @param SessionInterface $session
* @param DocumentManager $dm
*/
public function __construct(SessionInterface $session = null, DocumentManager $dm = null)
{
if (!$session && $dm) {
$session = $dm->getPhpcrSession();
}
parent::__construct($session);
$this->dm = $dm;
}
示例10: _copy
/**
* Copy file into another file (only inside one volume)
*
* @param string $source source file path
* @param string $targetDir target dir path
* @param string $name file name
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _copy($source, $targetDir, $name)
{
if ($this->dm->find(null, $targetPath = $this->_joinPath($targetDir, $name))) {
return false;
}
$this->dm->getPhpcrSession()->getWorkspace()->copy($source, $targetPath);
return true;
}
示例11: setUp
public function setUp()
{
$this->type = 'Doctrine\\Tests\\Models\\CMS\\CmsUser';
$this->dm = $this->createDocumentManager(array(__DIR__));
$this->node = $this->resetFunctionalNode($this->dm);
$user = $this->node->addNode('lsmith');
$user->setProperty('username', 'lsmith');
$user->setProperty('numbers', array(3, 1, 2));
$user->setProperty('phpcr:class', $this->type, PropertyType::STRING);
$this->dm->getPhpcrSession()->save();
// remove node for root tests
$session = $this->dm->getPhpcrSession();
$root = $session->getNode('/');
if ($root->hasNode('dbu')) {
$root->getNode('dbu')->remove();
$session->save();
}
}
示例12: testAnnotationOnPersist
/**
* Check that persisting a node with the versionable type will add the correct mixin to the node
*/
public function testAnnotationOnPersist()
{
$repository = $this->dm->getPhpcrSession()->getRepository();
if (!$repository->getDescriptor('option.versioning.supported')) {
$this->markTestSkipped('PHPCR repository doesn\'t support versioning');
}
$node = $this->createTestDocument('versionable-article-test', 'Doctrine\\Tests\\Models\\Versioning\\VersionableArticle');
$this->assertTrue($node->isNodeType('mix:simpleVersionable'));
$this->assertFalse($node->isNodeType('mix:versionable'));
// mix:versionable derives from mix:simpleVersionable, so a full versionable node will be both types
$node = $this->createTestDocument('versionable-article-test', 'Doctrine\\Tests\\Models\\Versioning\\FullVersionableArticle');
$this->assertTrue($node->isNodeType('mix:versionable'));
$this->assertTrue($node->isNodeType('mix:simpleVersionable'));
$node = $this->createTestDocument('versionable-article-test', 'Doctrine\\Tests\\Models\\Versioning\\NonVersionableArticle');
$this->assertFalse($node->isNodeType('mix:simpleVersionable'));
$this->assertFalse($node->isNodeType('mix:versionable'));
$node = $this->createTestDocument('versionable-article-test', 'Doctrine\\Tests\\Models\\Versioning\\ExtendedVersionableArticle');
$this->assertTrue($node->isNodeType('mix:simpleVersionable'));
$this->assertTrue($node->isNodeType('mix:versionable'));
}
示例13: testChangeset
public function testChangeset()
{
$user = $this->node->getNode('user');
// the property is not nullable, but this should only be checked on saving, not on loading
$user->getProperty('username')->remove();
$this->dm->getPhpcrSession()->save();
$userDoc = $this->dm->find(null, $user->getPath());
$this->assertInstanceOf($this->type, $userDoc);
$this->assertNull($userDoc->username);
// nothing should happen, we did not alter any value
$this->dm->flush();
}
示例14: testFindNullableFieldNone
/**
* No translation whatsoever is available. All translated fields have to be
* null as we do not validate on loading.
*/
public function testFindNullableFieldNone()
{
$node = $this->node->addNode('find');
$node->setProperty('phpcr:class', 'Doctrine\\Tests\\Models\\Translation\\Article');
$this->dm->getPhpcrSession()->save();
$this->dm->clear();
/** @var $doc Article */
$doc = $this->dm->find(null, $this->node->getPath() . '/find');
$this->assertEquals('en', $doc->locale);
$this->assertNull($doc->topic);
$this->assertNull($doc->text);
}
示例15: resetFunctionalNode
public function resetFunctionalNode(DocumentManager $dm)
{
$session = $dm->getPhpcrSession();
$root = $session->getNode('/');
if ($root->hasNode('functional')) {
$root->getNode('functional')->remove();
$session->save();
}
$node = $root->addNode('functional');
$session->save();
$dm->clear();
return $node;
}