Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Child annotation and File document
Now you can include children in your documents by annotating them with Child. The ODM will automatically create a child node in the repository with the given name (if a document is assigned ...). A useful example is the File document that has a child of class Resource.
- Loading branch information
Uwe Jäger
committed
Mar 20, 2011
1 parent
d82f288
commit 09c5591
Showing
12 changed files
with
452 additions
and
11 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
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,34 @@ | ||
<?php | ||
|
||
namespace Doctrine\ODM\PHPCR\Document; | ||
|
||
/** | ||
* @phpcr:Document(alias="file", nodeType="nt:file") | ||
*/ | ||
class File | ||
{ | ||
/** @phpcr:Path */ | ||
protected $path; | ||
|
||
/** @phpcr:Node */ | ||
protected $node; | ||
|
||
/** @phpcr:Date(name="jcr:created") */ | ||
protected $created; | ||
|
||
/** @phpcr:String(name="jcr:createdBy") */ | ||
protected $createdBy; | ||
|
||
/** @phpcr:Child(name="jcr:content") */ | ||
protected $content; | ||
|
||
public function setFileContent($filename) | ||
{ | ||
if ($this->content === null) | ||
{ | ||
$this->content = new Resource(); | ||
} | ||
$this->content->setFileData(file_get_contents($filename)); | ||
} | ||
|
||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Doctrine\ODM\PHPCR\Document; | ||
|
||
/** | ||
* @phpcr:Document(alias="folder", nodeType="nt:folder") | ||
*/ | ||
class Folder | ||
{ | ||
/** @phpcr:Path */ | ||
protected $path; | ||
|
||
/** @phpcr:Node */ | ||
protected $node; | ||
|
||
/** @phpcr:Date(name="jcr:created") */ | ||
protected $created; | ||
|
||
/** @phpcr:String(name="jcr:createdBy") */ | ||
protected $createdBy; | ||
} | ||
|
||
|
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,37 @@ | ||
<?php | ||
|
||
namespace Doctrine\ODM\PHPCR\Document; | ||
|
||
/** | ||
* @phpcr:Document(alias="resource", nodeType="nt:resource") | ||
*/ | ||
class Resource | ||
{ | ||
/** @phpcr:Path */ | ||
protected $path; | ||
|
||
/** @phpcr:Node */ | ||
protected $node; | ||
|
||
/** @phpcr:Binary(name="jcr:data") */ | ||
protected $data; | ||
|
||
/** @phpcr:String(name="jcr:mimeType") */ | ||
protected $mimeType; | ||
|
||
/** @phpcr:String(name="jcr:encoding") */ | ||
protected $encoding; | ||
|
||
/** @phpcr:Date(name="jcr:lastModified") */ | ||
protected $lastModified; | ||
|
||
/** @phpcr:String(name="jcr:lastModifiedBy") */ | ||
protected $lastModifiedBy; | ||
|
||
|
||
public function setFileData($data) | ||
{ | ||
$this->data = $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
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
Oops, something went wrong.