Skip to content

Commit

Permalink
Merge pull request cakephp#6790 from ndm2/4.x-fix-outdated-database-t…
Browse files Browse the repository at this point in the history
…ype-example

4.x - Fix outdated database type examples.
  • Loading branch information
markstory authored Sep 21, 2020
2 parents 393e8ed + 3450c1f commit 1e9ba31
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 20 deletions.
13 changes: 10 additions & 3 deletions en/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,15 @@ value object and into SQL expressions::
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -568,7 +570,7 @@ value object and into SQL expressions::
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -584,6 +586,11 @@ value object and into SQL expressions::
}
// Handle other cases.
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

The above class does a few interesting things:
Expand Down
15 changes: 11 additions & 4 deletions fr/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,15 @@ faire correspondre les données dans cet objet et les expressions SQL::
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -579,7 +581,7 @@ faire correspondre les données dans cet objet et les expressions SQL::
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -593,7 +595,12 @@ faire correspondre les données dans cet objet et les expressions SQL::
if (is_array($value)) {
return new FunctionExpression('POINT', [$value[0], $value[1]]);
}
// Handle other cases.
// Manipulez d'autres cas.
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

Expand Down
13 changes: 10 additions & 3 deletions ja/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,15 @@ Type クラスが必要になります。 ::
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -531,7 +533,7 @@ Type クラスが必要になります。 ::
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -547,6 +549,11 @@ Type クラスが必要になります。 ::
}
// その他のケースを処理
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

上記のクラスは、いくつかの興味深い特徴があります。
Expand Down
15 changes: 11 additions & 4 deletions pt/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,15 @@ mapear dados nesse objeto de valor e em expressões SQL::
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -526,7 +528,7 @@ mapear dados nesse objeto de valor e em expressões SQL::
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -540,7 +542,12 @@ mapear dados nesse objeto de valor e em expressões SQL::
if (is_array($value)) {
return new FunctionExpression('POINT', [$value[0], $value[1]]);
}
// Handle other cases.
// Lidar com outros casos.
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

Expand Down
13 changes: 10 additions & 3 deletions ru/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,15 @@ json
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -532,7 +534,7 @@ json
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -548,6 +550,11 @@ json
}
// Обработка других случаев.
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

Вышеуказанный класс выполняет несколько интересных вещей:
Expand Down
13 changes: 10 additions & 3 deletions tl/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,15 @@ value object and into SQL expressions::
namespace App\Database\Type;

use App\Database\Point;
use Cake\Database\DriverInterface;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type as BaseType;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\Type\ExpressionTypeInterface;

class PointType extends BaseType implements ExpressionTypeInterface
{
public function toPHP($value, Driver $d)
public function toPHP($value, DriverInterface $d)
{
return Point::parse($value);
}
Expand All @@ -542,7 +544,7 @@ value object and into SQL expressions::
return null;
}

public function toExpression($value)
public function toExpression($value): ExpressionInterface
{
if ($value instanceof Point) {
return new FunctionExpression(
Expand All @@ -558,6 +560,11 @@ value object and into SQL expressions::
}
// Handle other cases.
}

public function toDatabase($value, DriverInterface $driver)
{
return $value;
}
}

The above class does a few interesting things:
Expand Down

0 comments on commit 1e9ba31

Please sign in to comment.