Skip to content

Commit 14be5d4

Browse files
committed
added new field type 'hash'
1 parent bafe41c commit 14be5d4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/Doctrine/ODM/MongoDB/Mapping/Driver/DoctrineAnnotations.php

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ final class Field extends Annotation
5959
{
6060
public $type = 'string';
6161
}
62+
final class Hash extends Annotation
63+
{
64+
public $type = 'hash';
65+
}
6266
final class Boolean extends Annotation
6367
{
6468
public $type = 'boolean';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/*
3+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14+
*
15+
* This software consists of voluntary contributions made by many individuals
16+
* and is licensed under the LGPL. For more information, see
17+
* <http://www.doctrine-project.org>.
18+
*/
19+
20+
namespace Doctrine\ODM\MongoDB\Mapping\Types;
21+
22+
/**
23+
* The Array type.
24+
*
25+
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26+
* @link www.doctrine-project.org
27+
* @since 1.0
28+
* @version $Revision$
29+
* @author Bulat Shakirzyanov <mallluhuct@gmail.com>
30+
*/
31+
class HashType implements Type
32+
{
33+
public function convertToDatabaseValue($value)
34+
{
35+
return (array) $value;
36+
}
37+
38+
public function convertToPHPValue($value)
39+
{
40+
return (array) $value;
41+
}
42+
}

0 commit comments

Comments
 (0)