Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mark Scherer
committed
May 6, 2016
1 parent
8a5e2e2
commit 2dbc64c
Showing
25 changed files
with
160 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
<?php | ||
|
||
use Cake\Core\Configure; | ||
use Cake\Database\Type; | ||
use Cake\Log\Log; | ||
|
||
Log::config('geo', [ | ||
'className' => 'Cake\Log\Engine\FileLog', | ||
'path' => LOGS, | ||
'levels' => ['debug'], | ||
'scopes' => ['geocode'], | ||
'file' => 'geocode', | ||
]); | ||
$className = Configure::read('Log.defaultClassName') ?: 'Cake\Log\Engine\FileLog'; | ||
if (!Log::config('geo')) { | ||
Log::config('geo', [ | ||
'className' => $className, | ||
'path' => LOGS, | ||
'levels' => ['debug'], | ||
'scopes' => ['geocode'], | ||
'file' => 'geocode', | ||
]); | ||
} | ||
|
||
Type::map('object', 'Geo\Database\Type\ObjectType'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
namespace Geo\Database\Type; | ||
|
||
use Cake\Database\Driver; | ||
use Cake\Database\Type; | ||
use PDO; | ||
|
||
/** | ||
* This can serialize and unserialize objects. | ||
*/ | ||
class ObjectType extends Type { | ||
|
||
/** | ||
* @param string|null $value | ||
* @param \Cake\Database\Driver $driver | ||
* | ||
* @return object|null | ||
*/ | ||
public function toPHP($value, Driver $driver) { | ||
if ($value === null) { | ||
return $value; | ||
} | ||
return unserialize($value); | ||
} | ||
|
||
/** | ||
* @param object|string|null $value | ||
* | ||
* @return object|null | ||
*/ | ||
public function marshal($value) { | ||
if ($value === null) { | ||
return $value; | ||
} | ||
if (is_object($value)) { | ||
return $value; | ||
} | ||
dd($value); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dereuromark
Owner
|
||
return unserialize($value); | ||
} | ||
|
||
/** | ||
* @param object|null $value | ||
* @param \Cake\Database\Driver $driver | ||
* | ||
* @return string|null | ||
*/ | ||
public function toDatabase($value, Driver $driver) { | ||
if ($value === null) { | ||
return $value; | ||
} | ||
return serialize($value); | ||
} | ||
|
||
/** | ||
* @param mixed|null $value | ||
* @param \Cake\Database\Driver $driver | ||
* | ||
* @return int | ||
*/ | ||
public function toStatement($value, Driver $driver) { | ||
if ($value === null) { | ||
return PDO::PARAM_NULL; | ||
} | ||
return PDO::PARAM_STR; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
@dereuromark it seems a bit agressive to have a
dd()
here :D