Skip to content

Commit 4522b9c

Browse files
committed
Added some features
- Default document capability - Default document for basic Content - PHPCR createTestNode method
1 parent d79e0da commit 4522b9c

File tree

3 files changed

+105
-7
lines changed

3 files changed

+105
-7
lines changed

skeleton/app/config/dist/phpcrodm.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
'de' => array('en', 'fr'),
1616
'fr' => array('en', 'de'),
1717
),
18+
'mappings' => array(
19+
'test_default' => array(
20+
'type' => 'annotation',
21+
'prefix' => 'Symfony\Cmf\Component\Testing\Document',
22+
'dir' => CMF_TEST_ROOT_DIR.'/src/Symfony/Cmf/Component/Testing/Document',
23+
'is_bundle' => false,
24+
),
25+
),
1826
),
1927
);
2028

@@ -24,13 +32,12 @@
2432
$phpcrOdmDocPrefix = sprintf('%s\Tests\Functional\App\Document', $bundleFQN);
2533

2634
if (file_exists($phpcrOdmDocDir)) {
27-
$config['odm']['mappings'] = array(
28-
'test' => array(
29-
'type' => 'annotation',
30-
'prefix' => $phpcrOdmDocPrefix,
31-
'dir' => $phpcrOdmDocDir,
32-
'is_bundle' => false,
33-
),
35+
36+
$config['odm']['mappings']['test_additional'] = array(
37+
'type' => 'annotation',
38+
'prefix' => $phpcrOdmDocPrefix,
39+
'dir' => $phpcrOdmDocDir,
40+
'is_bundle' => false,
3441
);
3542
}
3643

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Component\Testing\Document;
4+
5+
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
6+
7+
/**
8+
* Test content document
9+
*
10+
* Very simple, referenceable document.
11+
*
12+
* @PHPCRODM\Document(referenceable=true)
13+
*/
14+
class Content
15+
{
16+
/**
17+
* @PHPCRODM\Id(strategy="parent")
18+
*/
19+
protected $id;
20+
21+
/**
22+
* @PHPCRODM\ParentDocument
23+
*/
24+
protected $parent;
25+
26+
/**
27+
* @PHPCRODM\NodeName
28+
*/
29+
protected $name;
30+
31+
/**
32+
* @PHPCRODM\String
33+
*/
34+
protected $title;
35+
36+
public function setId($id)
37+
{
38+
$this->id = $id;
39+
}
40+
41+
public function getId()
42+
{
43+
return $this->id;
44+
}
45+
46+
public function setParent($parent)
47+
{
48+
$this->parent = $parent;
49+
}
50+
51+
public function getParent()
52+
{
53+
return $this->parent;
54+
}
55+
56+
public function setName($name)
57+
{
58+
$this->name = $name;
59+
}
60+
61+
public function getName()
62+
{
63+
return $this->name;
64+
}
65+
66+
public function getTitle()
67+
{
68+
return $this->title;
69+
}
70+
71+
public function setTitle($title)
72+
{
73+
$this->title = $title;
74+
}
75+
}
76+

src/Symfony/Cmf/Component/Testing/Functional/DbManager/PHPCR.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,19 @@ public function loadFixtureClass($loader, $className)
7575
}
7676
}
7777
}
78+
79+
public function createTestNode()
80+
{
81+
$session = $this->container->get('doctrine_phpcr.session');
82+
83+
if ($session->nodeExists('/test')) {
84+
$session->getNode('/test')->remove();
85+
}
86+
87+
if (! $session->nodeExists('/test')) {
88+
$session->getRootNode()->addNode('test', 'nt:unstructured');
89+
}
90+
91+
$session->save();
92+
}
7893
}

0 commit comments

Comments
 (0)