<?php

namespace KupShop\CatalogBundle;

use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;

/**
 * IgnoreTablesListener class.
 */
class IgnoreTablesListener
{
    private $ignoredTables = [
        'products',
    ];

    public function postGenerateSchema(GenerateSchemaEventArgs $args)
    {
        $schema = $args->getSchema();

        $tables = $schema->getTables();
        foreach ($tables as $table) {
            if (in_array($table->getName(), $this->ignoredTables)) {
                // remove table from schema
                $schema->dropTable($table->getName());
            }
        }
    }
}
