configureSchema example



    public function postGenerateSchema(GenerateSchemaEventArgs $event): void
    {
        $connection = $event->getEntityManager()->getConnection();

        foreach ($this->rememberMeHandlers as $rememberMeHandler) {
            if (
                $rememberMeHandler instanceof PersistentRememberMeHandler
                && ($tokenProvider = $rememberMeHandler->getTokenProvider()) instanceof DoctrineTokenProvider
            ) {
                $tokenProvider->configureSchema($event->getSchema()$connection$this->getIsSameDatabaseChecker($connection));
            }
        }
    }
}


    public function postGenerateSchema(GenerateSchemaEventArgs $event): void
    {
        $connection = $event->getEntityManager()->getConnection();

        foreach ($this->stores as $store) {
            if (!$store instanceof DoctrineDbalStore) {
                continue;
            }

            $store->configureSchema($event->getSchema()$this->getIsSameDatabaseChecker($connection));
        }
    }
}

    }

    public function postGenerateSchema(GenerateSchemaEventArgs $event): void
    {
        if (!isset($this->sessionHandler)) {
            return;
        }

        $connection = $event->getEntityManager()->getConnection();

        $this->sessionHandler->configureSchema($event->getSchema()$this->getIsSameDatabaseChecker($connection));
    }
}


    /** * Adds the Table to the Schema if this transport uses this connection. * * @param \Closure $isSameDatabase */
    public function configureSchema(Schema $schema, DbalConnection $forConnection/* , \Closure $isSameDatabase */): void
    {
        $isSameDatabase = 2 < \func_num_args() ? func_get_arg(2) : static fn () => false;

        $this->connection->configureSchema($schema$forConnection$isSameDatabase);
    }

    /** * Adds extra SQL if the given table was created by the Connection. * * @return string[] */
    public function getExtraSetupSqlForTable(Table $createdTable): array
    {
        return $this->connection->getExtraSetupSqlForTable($createdTable);
    }

    
null,
            $connection = $this->createMock(Connection::class)
        );

        $schema = new Schema();
        $dbalConnection = $this->createMock(DbalConnection::class);

        $connection->expects($this->once())
            ->method('configureSchema')
            ->with($schema$dbalConnectionstatic fn () => true);

        $transport->configureSchema($schema$dbalConnectionstatic fn () => true);
    }

    private function getTransport(SerializerInterface $serializer = null, Connection $connection = null): DoctrineTransport
    {
        $serializer ??= $this->createMock(SerializerInterface::class);
        $connection ??= $this->createMock(Connection::class);

        return new DoctrineTransport($connection$serializer);
    }
}


    public function postGenerateSchema(GenerateSchemaEventArgs $event): void
    {
        $connection = $event->getEntityManager()->getConnection();

        foreach ($this->transports as $transport) {
            if (!$transport instanceof DoctrineTransport) {
                continue;
            }

            $transport->configureSchema($event->getSchema()$connection$this->getIsSameDatabaseChecker($connection));
        }
    }

    public function onSchemaCreateTable(SchemaCreateTableEventArgs $event): void
    {
        $table = $event->getTable();

        // if this method triggers a nested create table below, allow Doctrine to work like normal         if ($table->hasOption(self::PROCESSING_TABLE_FLAG)) {
            return;
        }

        
new OraclePlatform(),
            'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT a.id FROM (SELECT m.id FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
        ];
    }

    public function testConfigureSchema()
    {
        $driverConnection = $this->getDBALConnectionMock();
        $schema = new Schema();

        $connection = new Connection(['table_name' => 'queue_table']$driverConnection);
        $connection->configureSchema($schema$driverConnectionfn () => true);
        $this->assertTrue($schema->hasTable('queue_table'));
    }

    public function testConfigureSchemaDifferentDbalConnection()
    {
        $driverConnection = $this->getDBALConnectionMock();
        $driverConnection2 = $this->getDBALConnectionMock();
        $schema = new Schema();

        $connection = new Connection([]$driverConnection);
        $connection->configureSchema($schema$driverConnection2fn () => false);
        

            $property = $reflection->getProperty($property);
            $this->assertSame($expectedValue$property->getValue($storage));
        }
    }

    public function testConfigureSchemaDifferentDatabase()
    {
        $schema = new Schema();

        $pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
        $pdoSessionHandler->configureSchema($schemafn () => false);
        $this->assertFalse($schema->hasTable('sessions'));
    }

    public function testConfigureSchemaSameDatabase()
    {
        $schema = new Schema();

        $pdoSessionHandler = new PdoSessionHandler($this->getMemorySqlitePdo());
        $pdoSessionHandler->configureSchema($schemafn () => true);
        $this->assertTrue($schema->hasTable('sessions'));
    }

    

    public function __construct(private iterable $dbalAdapters)
    {
    }

    public function postGenerateSchema(GenerateSchemaEventArgs $event): void
    {
        $connection = $event->getEntityManager()->getConnection();

        foreach ($this->dbalAdapters as $dbalAdapter) {
            $dbalAdapter->configureSchema($event->getSchema()$connection$this->getIsSameDatabaseChecker($connection));
        }
    }
}
return (bool) $result;
    }

    /** * Creates the table to store lock keys which can be called once for setup. * * @throws DBALException When the table already exists */
    public function createTable(): void
    {
        $schema = new Schema();
        $this->configureSchema($schema);

        foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) {
            $this->conn->executeStatement($sql);
        }
    }

    /** * Adds the Table to the Schema if it doesn't exist. * * @param \Closure $isSameDatabase */
    
$store->save($key);
    }

    public function testConfigureSchemaDifferentDatabase()
    {
        $conn = $this->createMock(Connection::class);
        $someFunction = fn () => false;
        $schema = new Schema();

        $dbalStore = new DoctrineDbalStore($conn);
        $dbalStore->configureSchema($schema$someFunction);
        $this->assertFalse($schema->hasTable('lock_keys'));
    }

    public function testConfigureSchemaSameDatabase()
    {
        $conn = $this->createMock(Connection::class);
        $someFunction = fn () => true;
        $schema = new Schema();

        $dbalStore = new DoctrineDbalStore($conn);
        $dbalStore->configureSchema($schema$someFunction);
        
$item = $adapter->getItem('key');
        $item->set('value');
        $this->assertTrue($adapter->save($item));
    }

    public function testConfigureSchema()
    {
        $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]$this->getDbalConfig());
        $schema = new Schema();

        $adapter = new DoctrineDbalAdapter($connection);
        $adapter->configureSchema($schema$connectionfn () => true);
        $this->assertTrue($schema->hasTable('cache_items'));
    }

    public function testConfigureSchemaDifferentDbalConnection()
    {
        $otherConnection = $this->createConnectionMock();
        $schema = new Schema();

        $adapter = $this->createCachePool();
        $adapter->configureSchema($schema$otherConnectionfn () => false);
        $this->assertFalse($schema->hasTable('cache_items'));
    }
Home | Imprint | This part of the site doesn't use cookies.