gnu-social/src/DependencyInjection/Compiler/SchemaDefPass.php

51 lines
1.7 KiB
PHP

<?php
/*
* This file is part of GNU social - https://www.gnu.org/software/social
*
* GNU social is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNU social is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with GNU social. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Compiler pass which triggers Symgony to tell Doctrine to
* use out `SchemaDef` metadata driver
*
* @package GNUsocial
* @category DB
*
* @author Hugo Sales <hugo@fc.up.pt>
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
namespace App\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Register a new ORM driver to allow use to use the old schemaDef format
*/
class SchemaDefPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$container->findDefinition('doctrine.orm.default_metadata_driver')
->addMethodCall('addDriver',
[new Reference('app.util.schemadef_driver'), 'App\\Entity']
);
}
}