forked from doctrine/phpcr-odm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request doctrine#565 from he-li/doctrine#563
Check keys instead of values
- Loading branch information
Showing
4 changed files
with
169 additions
and
1 deletion.
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
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,89 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\CMS; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; | ||
use Doctrine\ODM\PHPCR\DocumentRepository; | ||
use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; | ||
|
||
/** | ||
* @PHPCRODM\Document(repositoryClass="Doctrine\Tests\Models\CMS\CmsArticlePersonRepository", referenceable=true) | ||
*/ | ||
class CmsArticlePerson | ||
{ | ||
/** @PHPCRODM\Id(strategy="repository") */ | ||
public $id; | ||
/** @PHPCRODM\String(nullable=true) */ | ||
public $name; | ||
/** @PHPCRODM\Referrers(referencedBy="persons", referringDocument="Doctrine\Tests\Models\CMS\CmsArticle", cascade="persist") */ | ||
public $articlesReferrers; | ||
|
||
public function __construct() | ||
{ | ||
$this->articlesReferrers = new ArrayCollection(); | ||
} | ||
|
||
/** | ||
* @param mixed $articlesReferrers | ||
*/ | ||
public function setArticlesReferrers($articlesReferrers) | ||
{ | ||
$this->articlesReferrers = $articlesReferrers; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getArticlesReferrers() | ||
{ | ||
return $this->articlesReferrers; | ||
} | ||
|
||
/** | ||
* @param mixed $id | ||
*/ | ||
public function setId($id) | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param mixed $name | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
} | ||
|
||
class CmsArticlePersonRepository extends DocumentRepository implements RepositoryIdInterface | ||
{ | ||
/** | ||
* Generate a document id | ||
* | ||
* @param object $document | ||
* @return string | ||
*/ | ||
public function generateId($document, $parent = null) | ||
{ | ||
return '/functional/'.$document->name; | ||
} | ||
} |
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