Skip to content

Commit 91a6afe

Browse files
committed
formatting
1 parent 666cda4 commit 91a6afe

3 files changed

Lines changed: 36 additions & 34 deletions

File tree

src/Illuminate/Database/Schema/Builder.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,30 @@ protected function createBlueprint($table, Closure $callback = null)
285285
return new Blueprint($table, $callback, $prefix);
286286
}
287287

288+
/**
289+
* Register a custom Doctrine mapping type.
290+
*
291+
* @param string $class
292+
* @param string $name
293+
* @param string $type
294+
* @return void
295+
*
296+
* @throws \Doctrine\DBAL\DBALException
297+
*/
298+
public function registerCustomDoctrineType($class, $name, $type)
299+
{
300+
if (Type::hasType($name)) {
301+
return;
302+
}
303+
304+
Type::addType($name, $class);
305+
306+
$this->connection
307+
->getDoctrineSchemaManager()
308+
->getDatabasePlatform()
309+
->registerDoctrineTypeMapping($type, $name);
310+
}
311+
288312
/**
289313
* Get the database connection instance.
290314
*
@@ -318,28 +342,4 @@ public function blueprintResolver(Closure $resolver)
318342
{
319343
$this->resolver = $resolver;
320344
}
321-
322-
/**
323-
* Register your own Doctrine mapping type.
324-
*
325-
* @param string $class
326-
* @param string $name
327-
* @param string $type
328-
* @return void
329-
*
330-
* @throws \Doctrine\DBAL\DBALException
331-
*/
332-
public function registerCustomDBALType($class, $name, $type)
333-
{
334-
if (Type::hasType($name)) {
335-
return;
336-
}
337-
338-
Type::addType($name, $class);
339-
340-
$this->connection
341-
->getDoctrineSchemaManager()
342-
->getDatabasePlatform()
343-
->registerDoctrineTypeMapping($type, $name);
344-
}
345345
}

src/Illuminate/Database/Schema/MySqlBuilder.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
class MySqlBuilder extends Builder
99
{
1010
/**
11-
* MySqlBuilder constructor.
11+
* Create a new builder instance.
1212
*
1313
* @param \Illuminate\Database\Connection $connection
14+
* @return void
15+
*
1416
* @throws \Doctrine\DBAL\DBALException
1517
*/
1618
public function __construct(Connection $connection)
1719
{
1820
parent::__construct($connection);
1921

20-
$this->registerCustomDBALTypes();
22+
$this->registerCustomDoctrineTypes();
2123
}
2224

2325
/**
@@ -129,18 +131,18 @@ protected function getAllViews()
129131
}
130132

131133
/**
132-
* Register custom DBAL types for the MySQL builder.
134+
* Register the custom Doctrine mapping types for the MySQL builder.
133135
*
134136
* @return void
135137
*
136138
* @throws \Doctrine\DBAL\DBALException
137139
*/
138-
private function registerCustomDBALTypes()
140+
protected function registerCustomDoctrineTypes()
139141
{
140-
if (! $this->connection->isDoctrineAvailable()) {
141-
return;
142+
if ($this->connection->isDoctrineAvailable()) {
143+
$this->registerCustomDoctrineType(
144+
TinyInteger::class, TinyInteger::NAME, 'TINYINT'
145+
);
142146
}
143-
144-
$this->registerCustomDBALType(TinyInteger::class, TinyInteger::NAME, 'TINYINT');
145147
}
146148
}

tests/Integration/Database/SchemaBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function test_drop_all_views()
4141
$this->assertTrue(true);
4242
}
4343

44-
public function test_register_custom_DBAL_type()
44+
public function test_register_custom_doctrine_type()
4545
{
46-
Schema::registerCustomDBALType(TinyInteger::class, TinyInteger::NAME, 'TINYINT');
46+
Schema::registerCustomDoctrineType(TinyInteger::class, TinyInteger::NAME, 'TINYINT');
4747

4848
Schema::create('test', function (Blueprint $table) {
4949
$table->string('test_column');

0 commit comments

Comments
 (0)