2017 © Pedro Peláez
 

symfony-bundle doctrine-extensions-bundle

Provides extensions to how Doctrine is integrated with Symfony like enabling repositories to have extra constructor arguments and behind the scenes retrieval/instantiation via the container.

image

lendable/doctrine-extensions-bundle

Provides extensions to how Doctrine is integrated with Symfony like enabling repositories to have extra constructor arguments and behind the scenes retrieval/instantiation via the container.

  • Thursday, June 28, 2018
  • by ppamment
  • Repository
  • 3 Watchers
  • 0 Stars
  • 3,376 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 15 % Grown

The README.md

Lendable Doctrine Extensions Bundle

Build Status Coverage Status Total Downloads Scrutinizer Code Quality, (*1)

Licensed under the MIT License., (*2)

Provides extensions to how Doctrine is integrated with Symfony. This includes:, (*3)

  • Allowing repositories to have extra constructor arguments and behind the scenes retrieval / instantiation via the container.

Requirements

  • PHP >= 7.0
  • Symfony >= 2.7

Installation

Require the bundle with Composer:, (*4)

composer require lendable/doctrine-extensions-bundle

Enable the bundle:, (*5)

<?php
// app/AppKernel.php

public function registerBundles() 
{
    $bundles = [
      // ...
      new Lendable\DoctrineExtensionsBundle\LendableDoctrineExtensionsBundle(),        
      // ...        
    ];
}

Usage

Repositories with dependencies

A repository with extra constructor arguments such as:, (*6)

<?php
// src/App/Entity/Repository/ExampleRepository.php

namespace App\Entity\Repository;

class ExampleRepository extends EntityRepository
{
    public function __construct(
        EntityManager $entityManager, 
        ClassMetadata $classMetadata,
        string $customRawValue,
        string $customParameter, 
        CustomService $customService,
        array $customArray) 
    {
        parent::__construct($entityManager, $classMetadata);

        $this->customRawValue = $customRawValue;
        $this->customParameter = $customParameter;
        $this->customService = $customService;
        $this->customArray = $customArray;
    }
}

Should be configured to inform the bundle how these extra dependencies should be sourced., (*7)


lendable_doctrine_extensions: repositories: App\Entity\Repository\ExampleRepository: entity: App\Entity\Example managers: ['default', 'custom_manager'] args: - 'a literal raw value' - '%custom_parameter%' - '@custom_service' - config: '@config_service' raw_value: 'a literal raw value'

An argument can either be:, (*8)

  • Raw scalar.
  • Parameter reference (%wrapped%).
  • Service reference (@prefixed).
  • An indexed/associative array of any of the above.

The repository can now be retrieved as usual via the Doctrine Registry or EntityManager., (*9)

<?php

// Via the registry...

$repository = $container->get('doctrine')->getRepository(App\Entity\Example::class);

// Via the entity manager...

$repository = $container->get('doctrine')->getManager()->getRepository(App\Entity\Example::class);

The Versions

28/06 2018

dev-master

9999999-dev

Provides extensions to how Doctrine is integrated with Symfony like enabling repositories to have extra constructor arguments and behind the scenes retrieval/instantiation via the container.

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle doctrine symfony lendable

18/11 2017

dev-feature/add-php-lint-as-ci-step

dev-feature/add-php-lint-as-ci-step

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle doctrine symfony lendable

17/11 2017
17/11 2017

dev-feature/symfony4-ready

dev-feature/symfony4-ready

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle doctrine symfony lendable