Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 3f6ecbe

Browse files
committed
Merge branch '1.2' into merge-1.2
Conflicts: .travis.yml Provider/PhpcrMenuProvider.php
2 parents e69252a + eb056fc commit 3f6ecbe

File tree

9 files changed

+186
-5
lines changed

9 files changed

+186
-5
lines changed

Admin/MenuNodeAdmin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function buildBreadcrumbs($action, MenuItemInterface $menu = null)
169169
}
170170

171171
$parentAdmin->setSubject($parentDoc);
172+
$parentAdmin->setRequest($this->request);
172173
$parentEditNode = $parentAdmin->buildBreadcrumbs($action, $menu);
173174
if ($parentAdmin->isGranted('EDIT' && $parentAdmin->hasRoute('edit'))) {
174175
$parentEditNode->setUri(

Provider/PhpcrMenuProvider.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
1515
use Doctrine\ODM\PHPCR\DocumentManager;
16-
use Knp\Menu\Loader\LoaderInterface;
1716
use Knp\Menu\Loader\NodeLoader;
17+
use PHPCR\RepositoryException;
1818
use Symfony\Component\HttpFoundation\Request;
1919
use PHPCR\PathNotFoundException;
2020
use PHPCR\Util\PathHelper;
@@ -27,9 +27,9 @@
2727
class PhpcrMenuProvider implements MenuProviderInterface
2828
{
2929
/**
30-
* @var LoaderInterface
30+
* @var NodeLoader
3131
*/
32-
protected $loader = null;
32+
protected $loader;
3333

3434
/**
3535
* @var Request
@@ -217,9 +217,20 @@ protected function find($name, array $options, $throw)
217217
return false;
218218
}
219219

220-
$path = PathHelper::absolutizePath($name, $this->getMenuRoot());
221220
$dm = $this->getObjectManager();
222221
$session = $dm->getPhpcrSession();
222+
223+
try {
224+
$path = PathHelper::absolutizePath($name, $this->getMenuRoot());
225+
PathHelper::assertValidAbsolutePath($path, false, true, $session->getNamespacePrefixes());
226+
} catch (RepositoryException $e) {
227+
if ($throw) {
228+
throw $e;
229+
}
230+
231+
return false;
232+
}
233+
223234
if ($this->getPrefetch() > 0) {
224235
try {
225236
if (

Resources/translations/CmfMenuBundle.cs.xliff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@
114114
<source>form.label_weak</source>
115115
<target>Slabé propojení</target>
116116
</trans-unit>
117+
<trans-unit id="show.label_id">
118+
<source>show.label_id</source>
119+
<target>Id</target>
120+
</trans-unit>
121+
<trans-unit id="show.label_name">
122+
<source>show.label_name</source>
123+
<target>Název</target>
124+
</trans-unit>
125+
<trans-unit id="show.label_label">
126+
<source>show.label_label</source>
127+
<target>Označení</target>
128+
</trans-unit>
129+
<trans-unit id="show.label_uri">
130+
<source>show.label_uri</source>
131+
<target>URI</target>
132+
</trans-unit>
133+
<trans-unit id="show.label_content">
134+
<source>show.label_content</source>
135+
<target>Obsah</target>
136+
</trans-unit>
117137
<trans-unit id="help.items_help">
118138
<source>help.items_help</source>
119139
<target>Klepněte na položku, kterou chcete upravit. Klikněte pravým tlačítkem myši pro přidání nových záznamů.</target>

Resources/translations/CmfMenuBundle.de.xliff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,26 @@
106106
<source>form.label_link_type</source>
107107
<target>Linktyp</target>
108108
</trans-unit>
109+
<trans-unit id="show.label_id">
110+
<source>show.label_id</source>
111+
<target>Id</target>
112+
</trans-unit>
113+
<trans-unit id="show.label_name">
114+
<source>show.label_name</source>
115+
<target>Name</target>
116+
</trans-unit>
117+
<trans-unit id="show.label_label">
118+
<source>show.label_label</source>
119+
<target>Beschriftung</target>
120+
</trans-unit>
121+
<trans-unit id="show.label_uri">
122+
<source>show.label_uri</source>
123+
<target>URI</target>
124+
</trans-unit>
125+
<trans-unit id="show.label_content">
126+
<source>show.label_content</source>
127+
<target>Inhalt</target>
128+
</trans-unit>
109129
<trans-unit id="help.items_help">
110130
<source>help.items_help</source>
111131
<target>Klicken Sie auf ein Element, um es zu bearbeiten. Rechtsklick um Einträge hinzuzufügen.</target>

Resources/translations/CmfMenuBundle.en.xliff

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@
114114
<source>form.label_weak</source>
115115
<target>Weak association</target>
116116
</trans-unit>
117+
118+
<trans-unit id="show.label_id">
119+
<source>show.label_id</source>
120+
<target>Id</target>
121+
</trans-unit>
122+
<trans-unit id="show.label_name">
123+
<source>show.label_name</source>
124+
<target>Name</target>
125+
</trans-unit>
126+
<trans-unit id="show.label_label">
127+
<source>show.label_label</source>
128+
<target>Label</target>
129+
</trans-unit>
130+
<trans-unit id="show.label_uri">
131+
<source>show.label_uri</source>
132+
<target>URI</target>
133+
</trans-unit>
134+
<trans-unit id="show.label_content">
135+
<source>show.label_content</source>
136+
<target>Content</target>
137+
</trans-unit>
138+
117139
<trans-unit id="help.items_help">
118140
<source>help.items_help</source>
119141
<target>Click on item to edit, right click to create new items.</target>

Resources/translations/CmfMenuBundle.fr.xliff

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@
114114
<source>form.label_weak</source>
115115
<target>Association faible</target>
116116
</trans-unit>
117+
118+
<trans-unit id="show.label_id">
119+
<source>show.label_id</source>
120+
<target>Id</target>
121+
</trans-unit>
122+
<trans-unit id="show.label_name">
123+
<source>show.label_name</source>
124+
<target>Nom</target>
125+
</trans-unit>
126+
<trans-unit id="show.label_label">
127+
<source>show.label_label</source>
128+
<target>Label</target>
129+
</trans-unit>
130+
<trans-unit id="show.label_uri">
131+
<source>show.label_uri</source>
132+
<target>URI</target>
133+
</trans-unit>
134+
<trans-unit id="show.label_content">
135+
<source>show.label_content</source>
136+
<target>Contenu</target>
137+
</trans-unit>
138+
117139
<trans-unit id="help.items_help">
118140
<source>help.items_help</source>
119141
<target>Cliquez sur un élément pour le modifier, cliquez avec la touche droite pour ajouter des éléments.</target>

Resources/translations/CmfMenuBundle.sk.xliff

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@
114114
<source>form.label_weak</source>
115115
<target>Slabé prepojenie</target>
116116
</trans-unit>
117+
118+
<trans-unit id="show.label_id">
119+
<source>show.label_id</source>
120+
<target>Id</target>
121+
</trans-unit>
122+
<trans-unit id="show.label_name">
123+
<source>show.label_name</source>
124+
<target>Názov</target>
125+
</trans-unit>
126+
<trans-unit id="show.label_label">
127+
<source>show.label_label</source>
128+
<target>Označenie</target>
129+
</trans-unit>
130+
<trans-unit id="show.label_uri">
131+
<source>show.label_uri</source>
132+
<target>URI</target>
133+
</trans-unit>
134+
<trans-unit id="show.label_content">
135+
<source>show.label_content</source>
136+
<target>Obsah</target>
137+
</trans-unit>
138+
117139
<trans-unit id="help.items_help">
118140
<source>help.items_help</source>
119141
<target>Kliknite na položku, ktorú chcete upraviť. Kliknite pravým tlačidlom myši pre pridanie nových záznamov.</target>

Resources/translations/CmfMenuBundle.sl.xliff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@
114114
<source>form.label_weak</source>
115115
<target>Slaba pridružitev</target>
116116
</trans-unit>
117+
<trans-unit id="show.label_id">
118+
<source>show.label_id</source>
119+
<target>Id</target>
120+
</trans-unit>
121+
<trans-unit id="show.label_name">
122+
<source>show.label_name</source>
123+
<target>Ime</target>
124+
</trans-unit>
125+
<trans-unit id="show.label_label">
126+
<source>show.label_label</source>
127+
<target>Oznaka</target>
128+
</trans-unit>
129+
<trans-unit id="show.label_uri">
130+
<source>show.label_uri</source>
131+
<target>URI</target>
132+
</trans-unit>
133+
<trans-unit id="show.label_content">
134+
<source>show.label_content</source>
135+
<target>Vsebina</target>
136+
</trans-unit>
117137
<trans-unit id="help.items_help">
118138
<source>help.items_help</source>
119139
<target>Kliknite na element za urejanje, desni klik za ustvarjanje novih elementov.</target>

Tests/Unit/Provider/PhpcrMenuProviderTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ private function getDmMock($path)
2222
->method('getNode')
2323
->with($path)
2424
;
25+
$session->expects($this->once())
26+
->method('getNamespacePrefixes')
27+
->will($this->returnValue(array('jcr', 'nt')))
28+
;
2529
$dm = $this
2630
->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
2731
->disableOriginalConstructor()
@@ -90,14 +94,53 @@ public function testHas($menuRoot, $name, $expectedPath)
9094
$menuRoot
9195
);
9296

93-
$provider->has($name);
97+
$this->assertTrue($provider->has($name));
98+
}
99+
100+
public function testHasNot()
101+
{
102+
$session = $this->getMock('PHPCR\SessionInterface');
103+
$session->expects($this->never())
104+
->method('getNode')
105+
;
106+
$session->expects($this->any())
107+
->method('getNamespacePrefixes')
108+
->will($this->returnValue(array('jcr', 'nt')))
109+
;
110+
$objectManager = $this
111+
->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
112+
->disableOriginalConstructor()
113+
->getMock()
114+
;
115+
$objectManager->expects($this->any())
116+
->method('getPhpcrSession')
117+
->will($this->returnValue($session))
118+
;
119+
$objectManager->expects($this->never())
120+
->method('find')
121+
;
122+
123+
$managerRegistry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
124+
$managerRegistry->expects($this->any())
125+
->method('getManager')
126+
->will($this->returnValue($objectManager));
127+
128+
$provider = new PhpcrMenuProvider(
129+
$this->getMock('Knp\Menu\FactoryInterface'),
130+
$managerRegistry,
131+
'/foo'
132+
);
133+
134+
$this->assertFalse($provider->has('notavalidnamespace:bar'));
135+
$this->assertFalse($provider->has('not:a:valid:name'));
94136
}
95137

96138
public function getMenuTests()
97139
{
98140
return array(
99141
array('/test/menu', 'foo', '/test/menu/foo'),
100142
array('/test/menu', '/another/menu/path', '/another/menu/path'),
143+
array('/test/menu', 'jcr:namespaced', '/test/menu/jcr:namespaced'),
101144
);
102145
}
103146
}

0 commit comments

Comments
 (0)