Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from beowulfenator/master
issue #8 and raw value getter
- Loading branch information
Showing
6 changed files
with
292 additions
and
27 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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace data; | ||
|
||
use Yii; | ||
use yii\helpers\JSON; | ||
|
||
class BookBadFields extends Book | ||
{ | ||
|
||
public function behaviors() | ||
{ | ||
return | ||
[ | ||
[ | ||
'class' => \voskobovich\behaviors\ManyToManyBehavior::className(), | ||
'relations' => [ | ||
'author' => [ | ||
'authors', | ||
'fields' => [ | ||
'list_json' => [ | ||
'get' => function($value) { | ||
return JSON::encode($value); | ||
}, | ||
'set' => function($value) { | ||
return JSON::decode($value); | ||
}, | ||
], | ||
], | ||
], | ||
'author_list' => [ | ||
'reviews', | ||
'fields' => [ | ||
'json' => [ | ||
'get' => function($value) { | ||
return JSON::encode($value); | ||
}, | ||
'set' => function($value) { | ||
return JSON::decode($value); | ||
}, | ||
], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace data; | ||
|
||
use Yii; | ||
use yii\helpers\JSON; | ||
|
||
class BookJsonFields extends Book | ||
{ | ||
|
||
public function behaviors() | ||
{ | ||
return | ||
[ | ||
[ | ||
'class' => \voskobovich\behaviors\ManyToManyBehavior::className(), | ||
'relations' => [ | ||
'author_list' => [ | ||
'authors', | ||
'fields' => [ | ||
'json' => [ | ||
'get' => function($value) { | ||
return JSON::encode($value); | ||
}, | ||
'set' => function($value) { | ||
return JSON::decode($value); | ||
}, | ||
], | ||
], | ||
], | ||
'review_list' => [ | ||
'reviews', | ||
'fields' => [ | ||
'json' => [ | ||
'get' => function($value) { | ||
return JSON::encode($value); | ||
}, | ||
'set' => function($value) { | ||
return JSON::decode($value); | ||
}, | ||
], | ||
'implode' => [ | ||
'get' => function($value) { | ||
return implode(',', $value); | ||
}, | ||
'set' => function($value) { | ||
return explode(',', $value); | ||
}, | ||
], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
} |
Oops, something went wrong.