forked from doctrine/phpcr-odm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify unique node types via mapping to allow proper outer joins -- d…
- Loading branch information
Showing
14 changed files
with
233 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,9 @@ class Document | |
* @var boolean | ||
*/ | ||
public $referenceable; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
public $uniqueNodeType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\CMS; | ||
|
||
use Doctrine\ODM\PHPCR\DocumentRepository; | ||
use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; | ||
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; | ||
|
||
/** | ||
* @PHPCRODM\Document( | ||
* nodeType="phpcr:cms_profile", | ||
* referenceable=true, | ||
* repositoryClass="Doctrine\Tests\Models\CMS\CmsProfileRepository", | ||
* uniqueNodeType=true | ||
* ) | ||
*/ | ||
class CmsProfile | ||
{ | ||
/** @PHPCRODM\Id(strategy="repository") */ | ||
public $id; | ||
|
||
/** @PHPCRODM\Uuid */ | ||
public $uuid; | ||
|
||
/** @PHPCRODM\Field(type="string") */ | ||
public $data; | ||
|
||
/** @PHPCRODM\ReferenceOne(targetDocument="CmsUser", cascade="persist") */ | ||
public $user; | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getUuid() | ||
{ | ||
return $this->uuid; | ||
} | ||
|
||
public function setData($data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function setUser(CmsUser $user) | ||
{ | ||
$this->user = $user; | ||
} | ||
|
||
public function getUser() | ||
{ | ||
return $this->user; | ||
} | ||
} | ||
|
||
class CmsProfileRepository extends DocumentRepository implements RepositoryIdInterface | ||
{ | ||
/** | ||
* Generate a document id | ||
* | ||
* @param object $document | ||
* @return string | ||
*/ | ||
public function generateId($document, $parent = null) | ||
{ | ||
return '/functional/' . $document->user->username . '/' . $document->data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/Doctrine/Tests/ODM/PHPCR/Mapping/Model/UniqueNodeTypeMappingObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ODM\PHPCR\Mapping\Model; | ||
|
||
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; | ||
|
||
/** | ||
* A class that has a unique node type among other mapped documents. | ||
* | ||
* @PHPCRODM\Document(uniqueNodeType=true) | ||
*/ | ||
class UniqueNodeTypeMappingObject | ||
{ | ||
/** @PHPCRODM\Id */ | ||
public $id; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ping/Model/xml/Doctrine.Tests.ODM.PHPCR.Mapping.Model.UniqueNodeTypeMappingObject.dcm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping | ||
https://github.com/doctrine/phpcr-odm/raw/master/doctrine-phpcr-odm-mapping.xsd"> | ||
<document name="Doctrine\Tests\ODM\PHPCR\Mapping\Model\UniqueNodeTypeMappingObject" uniqueNodeType="true"> | ||
<id name="id" /> | ||
</document> | ||
</doctrine-mapping> |
3 changes: 3 additions & 0 deletions
3
...ping/Model/yml/Doctrine.Tests.ODM.PHPCR.Mapping.Model.UniqueNodeTypeMappingObject.dcm.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Doctrine\Tests\ODM\PHPCR\Mapping\Model\UniqueNodeTypeMappingObject: | ||
uniqueNodeType: true | ||
id: id |