Skip to content

Commit 84e720b

Browse files
author
diabl0
committed
Updated readme
1 parent 709bad4 commit 84e720b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,25 @@ drop() just needs the name of the collection name to be dropped:
609609
$collectionHandler->drop('example');
610610
```
611611

612+
# Custom Document class
613+
614+
If you want to use custom document class you can pass it's name to DocumentHandler or CollectionHandler using method `setDocumentClass`.
615+
Remember that Your class must extend `\ArangoDBClient\Document`.
616+
617+
```php
618+
$ch = new CollectionHandler($connection);
619+
$ch->setDocumentClass('\AppBundle\Entity\Product');
620+
$cursor = $ch->all('product');
621+
// All returned documents will be \AppBundle\Entity\Product instances
622+
623+
624+
$dh = new DocumentHandler($connection);
625+
$dh->setDocumentClass('\AppBundle\Entity\Product');
626+
$product = $dh->get('products', 11231234);
627+
// Product will be \AppBundle\Entity\Product instance
628+
```
629+
630+
See file examples/customDocumentClass.php for more details.
612631

613632
<a name="logging_exceptions"></a>
614633
## Logging exceptions

0 commit comments

Comments
 (0)