Skip to content

Commit

Permalink
Adding serialized Type
Browse files Browse the repository at this point in the history
  • Loading branch information
pnomolos committed Jun 8, 2012
1 parent 22d7d89 commit 7e650e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extensions/data/source/Spot.php
Expand Up @@ -67,6 +67,9 @@ public function __construct(array $config = array()) {
protected function _init() {
$this->configuration = new \Spot\Config();
$this->configuration->addConnection('default', $this->connectionString);

$this->configuration->typeHandler('serialized', '\li3_spot\types\Serialized');

$this->mapper = new \Spot\Mapper($this->configuration);
}

Expand Down
33 changes: 33 additions & 0 deletions types/Serialized.php
@@ -0,0 +1,33 @@
<?php
namespace li3_spot\types;
use \Spot\Entity;

class Serialized implements \Spot\Type\TypeInterface
{
/**
* Cast given value to type required
*/
public static function cast($value)
{
if(null !== $value) {
return $value;
}
return $value;
}

/**
* Geting value off Entity object
*/
public static function get(Entity $entity, $value)
{
return self::cast($value);
}

/**
* Setting value on Entity object
*/
public static function set(Entity $entity, $value)
{
return self::cast($value);
}
}

0 comments on commit 7e650e4

Please sign in to comment.