Skip to content

Commit 856cca7

Browse files
committed
user defined classes doc added
1 parent 0bac566 commit 856cca7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ $pattern = $mapper->create('shift_pattern', [
228228
echo $pattern->id; // will be set when you create an instance
229229
```
230230

231+
# User-defined classes plugin
232+
If you want you can specify classes to use for repository and entity instances.
233+
Entity and repository class implementation are ommited, but you should just extend base classes.
234+
```php
235+
$userClasses = $mappr->addPlugin(Tarantool\Mapper\Plugins\UserClasses::class);
236+
$userClasses->mapEntity('person', Application\Models\Person::class);
237+
$userClasses->mapRepository('person', Application\Repositories\Person::class);
238+
239+
$nekufa = $mapper->create('person', [
240+
'email' => '[email protected]'
241+
]);
242+
243+
get_class($nekufa); // Application\Models\Person;
244+
245+
$mapper->getSchema()->getSpace('person')->getRepository(); // will be instance of Application\Repositories\Person
246+
```
247+
231248
# Internals
232249
Mapper uses IdentityMap and query caching
233250
```php

0 commit comments

Comments
 (0)