Edit on GitHub
Jump to docs navigation

Extending / Advanced / Storage Repositories & Entity Mappings

Note: You are currently reading the documentation for Bolt 3.1. Looking for the documentation for Bolt 3.5 instead?

Bolt 3 comes with an extensible storage interface.

If your extension needs to register entity and repository mappings, your extension loader class should import StorageTrait, implement the registerRepositoryMappings() function and call extendRepositoryMapping() in your extension loader class.

ExampleΒΆ

namespace Bolt\Extension\DropBear\KoalaCatcher;

use Bolt\Extension\DropBear\KoalaCatcher\Storage\Entity;
use Bolt\Extension\DropBear\KoalaCatcher\Storage\Repository;
use Bolt\Extension\SimpleExtension;
use Bolt\Extension\StorageTrait;
use Silex\Application;

/**
 * An extension for catching koalas.
 *
 * @author Kenny Koala <kenny@dropbear.com.au>
 */
class KoalaCatcherExtension extends SimpleExtension
{
    use StorageTrait;

    /**
     * {@inheritdoc}
     */
    protected function registerServices(Application $app)
    {
        $this->extendRepositoryMapping();
    }

    /**
     * {@inheritdoc}
     */
    protected function registerRepositoryMappings()
    {
        return [
            'gumtree' => [Entity\GumTree::class => Repository\GumTree::class],
        ];
    }

Note: The above example uses "class name resolution" via the ::class keyword.

Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.