PHP code example of janpecha / leanmapper-extension
1. Go to this page and download the library: Download janpecha/leanmapper-extension library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
janpecha / leanmapper-extension example snippets
php
use Nette\DI\CompilerExtension;
use JP\LeanMapperExtension\IEntityProvider;
class FooExtension extends CompilerExtension implements IEntityProvider
{
// from IEntityProvider
function getEntityMappings()
{
return array(
array(
'table' => 'foo_articles',
'primaryKey' => 'id',
'entity' => Foo\Model\Article::class,
'repository' => Foo\Model\ArticleRepository::class, # only mapping, you need manually register repository to DI
),
// ...
);
}
}
php
use Nette\DI\CompilerExtension;
use JP\LeanMapperExtension\IStiMappingProvider;
class FooExtension extends CompilerExtension implements IStiMappingProvider
{
function getStiMappings()
{
return [
Model\Entity\Client::class => [ // base entity
// type => target entity
'company' => Model\Entity\ClientCompany::class,
],
// ...
];
}
function getStiTypeFields()
{
return [
Model\Entity\Client::class => 'clientType',
];
}
}