PHP code example of chamber-orchestra / doctrine-extensions-bundle

1. Go to this page and download the library: Download chamber-orchestra/doctrine-extensions-bundle 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/ */

    

chamber-orchestra / doctrine-extensions-bundle example snippets


// config/bundles.php
return [
    ChamberOrchestra\DoctrineExtensionsBundle\ChamberOrchestraDoctrineExtensionsBundle::class => ['all' => true],
];

use ChamberOrchestra\DoctrineExtensionsBundle\Contracts\Entity\IdInterface;
use ChamberOrchestra\DoctrineExtensionsBundle\Contracts\Entity\SoftDeleteInterface;
use ChamberOrchestra\DoctrineExtensionsBundle\Contracts\Entity\ToggleInterface;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\IdTrait;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\SoftDeleteTrait;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\ToggleTrait;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\VersionTrait;

class Article implements IdInterface, SoftDeleteInterface, ToggleInterface
{
    use IdTrait;
    use SoftDeleteTrait;
    use ToggleTrait;
    use VersionTrait;
}

$filter = $entityManager->getFilters()->enable('soft_delete');
$filter->disableForEntity(Article::class);   // 

use ChamberOrchestra\DoctrineExtensionsBundle\Repository\ServiceEntityRepository;

class ArticleRepository extends ServiceEntityRepository
{
    // getOneBy(criteria, orderBy) — throws EntityNotFoundException if not found
    // indexBy(criteria, orderBy, field) — returns array of field values matching criteria
}

$qb->select('a')->from(Article::class, 'a')->orderBy('random()');