Giter VIP home page Giter VIP logo

doctrine-json-odm's Introduction

Doctrine JSON ODM

An Object-Document Mapper (ODM) for Doctrine ORM leveraging new JSON types of modern RDBMS.

tests Scrutinizer Code Quality StyleCI

Did you ever dream of a tool creating powerful data models mixing traditional, efficient relational mappings with modern schema-less and NoSQL-like ones?

With Doctrine JSON ODM, it's now possible to create and query such hybrid data models with ease. Thanks to modern JSON types of RDBMS, querying schema-less documents is easy, powerful and fast as hell (similar in performance to a MongoDB database)! You can even define indexes for those documents.

Doctrine JSON ODM allows to store PHP objects as JSON documents in modern, dynamic columns of an RDBMS. It works with JSON and JSONB columns of PostgreSQL (>= 9.4) and the JSON column type of MySQL (>= 5.7.8).

For more information about concepts behind Doctrine JSON ODM, take a look at the presentation given by Benjamin Eberlei at Symfony Catalunya 2016.

Install

To install the library, use Composer, the PHP package manager:

composer require dunglas/doctrine-json-odm

If you are using Symfony or API Platform, you don't need to do anything else! If you use Doctrine directly, use a bootstrap code similar to the following:

<?php

require_once __DIR__.'/../vendor/autoload.php'; // Adjust to your path

use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Setup;
use Dunglas\DoctrineJsonOdm\Serializer;
use Dunglas\DoctrineJsonOdm\Type\JsonDocumentType;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\UidNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;

if (!Type::hasType('json_document')) {
    Type::addType('json_document', JsonDocumentType::class);
    Type::getType('json_document')->setSerializer(
        new Serializer([new BackedEnumNormalizer(), new UidNormalizer(), new DateTimeNormalizer(), new ArrayDenormalizer(), new ObjectNormalizer()], [new JsonEncoder()])
    );
}

// Sample bootstrapping code here, adapt to fit your needs
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/../src'], $_ENV['DEBUG'] ?? false); // Adapt to your path

$conn = [
    'dbname' => $_ENV['DATABASE_NAME'],
    'user' => $_ENV['DATABASE_USER'],
    'password' => $_ENV['DATABASE_PASSWORD'],
    'host' => $_ENV['DATABASE_HOST'],
    'driver' => 'pdo_mysql' // or pdo_pgsql
];

return EntityManager::create($conn, $config);

Usage

Doctrine JSON ODM provides a json_document column type for properties of Doctrine entities.

The content of properties mapped with this type is serialized in JSON using the Symfony Serializer then, it is stored in a dynamic JSON column in the database.

When the object will be hydrated, the JSON content of this column is transformed back to its original values, thanks again to the Symfony Serializer. All PHP objects and structures will be preserved.

You can store any type of (serializable) PHP data structures in properties mapped using the json_document type.

Example:

namespace App\Entity;

use Doctrine\ORM\Mapping\{Entity, Column, Id, GeneratedValue};

// This is a typical Doctrine ORM entity.
#[Entity]
class Foo
{
  #[Column]
  #[Id]
  #[GeneratedValue]
  public int $id;

  #[Column]
  public string $name;

  // Can contain anything: array, objects, nested objects...
  #[Column(type: 'json_document', options: ['jsonb' => true])]
  public $misc;

  // Works with private and protected methods with getters and setters too.
}
namespace App\Entity;

// This is NOT an entity! It's a POPO (Plain Old PHP Object). It can contain anything.
class Bar
{
    public string $title;
    public float $weight;
}
namespace App\Entity;

// This is NOT an entity. It's another POPO and it can contain anything.
class Baz
{
    public string $name;
    public int $size;
}

Store a graph of random object in the JSON type of the database:

// $entityManager = $managerRegistry->getManagerForClass(Foo::class);

$bar = new Bar();
$bar->title = 'Bar';
$bar->weight = 12.3;

$baz = new Baz();
$baz->name = 'Baz';
$baz->size = 7;

$foo = new Foo();
$foo->name = 'Foo';
$foo->misc = [$bar, $baz];

$entityManager->persist($foo);
$entityManager->flush();

Retrieve the object graph back:

$foo = $entityManager->find(Foo::class, $foo->getId());
var_dump($foo->misc); // Same as what we set earlier

Using type aliases

Using custom type aliases as #type rather than FQCNs has a couple of benefits:

  • In case you move or rename your document classes, you can just update your type map without migrating database content
  • For applications that might store millions of records with JSON documents, this can also save some storage space

You can introduce type aliases at any point in time. Already persisted JSON documents with class names will still get deserialized correctly.

Using Symfony

In order to use type aliases, add the bundle configuration, e.g. in config/packages/doctrine_json_odm.yaml:

dunglas_doctrine_json_odm:
    type_map:
        foo: App\Something\Foo
        bar: App\SomethingElse\Bar

With this, Foo objects will be serialized as:

{ "#type": "foo", "someProperty": "someValue" }

Another option is to use your own custom type mapper implementing Dunglas\DoctrineJsonOdm\TypeMapperInterface. For this, just override the service definition:

services:
    dunglas_doctrine_json_odm.type_mapper: '@App\Something\MyFancyTypeMapper'

Without Symfony

When instantiating Dunglas\DoctrineJsonOdm\Serializer, you need to pass an extra argument that implements Dunglas\DoctrineJsonOdm\TypeMapperInterface.

For using the built-in type mapper:

    // …
    use Dunglas\DoctrineJsonOdm\Serializer;
    use Dunglas\DoctrineJsonOdm\TypeMapper;
    use App\Something\Foo;
    use App\SomethingElse\Bar;
    
    // For using the built-in type mapper:
    $typeMapper = new TypeMapper([
        'foo' => Foo::class,
        'bar' => Bar::class,
    ]);
    
    // Or implement TypeMapperInterface with your own class:
    $typeMapper = new MyTypeMapper();

    // Then pass it into the Serializer constructor
    Type::getType('json_document')->setSerializer(
        new Serializer([new ArrayDenormalizer(), new ObjectNormalizer()], [new JsonEncoder()], $typeMapper)
    );

Limitations when updating nested properties

Due to how Doctrine works, it will not detect changes to nested objects or properties. The reason for this is that Doctrine compares objects by reference to optimize UPDATE queries. If you experience problems where no UPDATE queries are executed, you might need to clone the object before you set it. That way Doctrine will notice the change. See #21 for more information.

FAQ

What DBMS are supported?

PostgreSQL 9.4+ and MySQL 5.7+ are supported.

Which versions of Doctrine are supported?

Doctrine ORM 2.6+ and DBAL 2.6+ are supported.

How to use the JSONB type of PostgreSQL?

Then, you need to set an option in the column mapping:

// ...

    #[Column(type: 'json_document', options: ['jsonb' => true])]
    public $foo;

// ...

Does the ODM support nested objects and object graphs?

Yes.

Can I use the native PostgreSQL and MySQL /JSON functions?

Yes! You can execute complex queries using native queries.

Alternatively, install scienta/doctrine-json-functions to be able to use run JSON functions in DQL and query builders.

How to change the (de)serialization context

You may need to change the (de)serialization context, for instance to avoid escaping slashes.

If you are using Symfony, modify your Kernel like this:

<?php
// src/Kernel.php

declare(strict_types=1);

namespace App;

use Doctrine\DBAL\Types\Type;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Serializer\Encoder\JsonEncode;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    public function boot(): void
    {
        parent::boot();

        $type = Type::getType('json_document');
        $type->setSerializationContext([JsonEncode::OPTIONS => JSON_UNESCAPED_SLASHES]);
        $type->setDeserializationContext([/* ... */]);
    }
}

How can I add additional normalizers?

The Symfony Serializer is easily extensible. This bundle registers and uses a service with ID dunglas_doctrine_json_odm.serializer as the serializer for the JSON type. This means we can easily override it in our services.yaml to use additional normalizers. As an example we inject a custom normalizer service. Be aware that the order of the normalizers might be relevant depending on the normalizers you use.

    # Add DateTime Normalizer to Dunglas' Doctrine JSON ODM Bundle
    dunglas_doctrine_json_odm.serializer:
        class: Dunglas\DoctrineJsonOdm\Serializer
        arguments:
          - ['@App\MyCustom\Normalizer', '@?dunglas_doctrine_json_odm.normalizer.backed_enum', '@?dunglas_doctrine_json_odm.normalizer.uid', '@dunglas_doctrine_json_odm.normalizer.datetime', '@dunglas_doctrine_json_odm.normalizer.array', '@dunglas_doctrine_json_odm.normalizer.object']
          - ['@serializer.encoder.json']
          - '@?dunglas_doctrine_json_odm.type_mapper'
        public: true
        autowire: false
        autoconfigure: false

When the namespace of a used entity changes

For classes without type aliases, because we store the #type along with the data in the database, you have to migrate the already existing data in your database to reflect the new namespace.

Example: If we have a project that we migrate from AppBundle to App, we have the namespace AppBundle/Entity/Bar in our database which has to become App/Entity/Bar instead.

When you use MySQL, you can use this query to migrate the data:

UPDATE Baz
SET misc = JSON_REPLACE(misc, '$."#type"', 'App\\\Entity\\\Bar')
WHERE 'AppBundle\\\Entity\\\Bar' = JSON_EXTRACT(misc, '$."#type"');

Credits

This bundle is brought to you by Kévin Dunglas and awesome contributors. Sponsored by Les-Tilleuls.coop.

Former Maintainers

Yanick Witschi helped maintain this bundle, thanks!

doctrine-json-odm's People

Contributors

ajgarlag avatar alsbury avatar amenophis avatar back-2-95 avatar bpolaszek avatar bricejulia avatar cbourgois avatar cvekcoding avatar dgoosens avatar ducatel avatar dunglas avatar fracz avatar hhamon avatar hmartin avatar jderusse avatar juliusstoerrle avatar kerianmm avatar michaelesmith avatar mlocati avatar nek- avatar norkunas avatar parijke avatar pierstoval avatar samnela avatar tamasszigeti avatar the-twenty-five avatar timonf avatar toflar avatar toofff avatar vudaltsov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrine-json-odm's Issues

Storing \stdClass object in json_document

I have a really non-typed JSON input that successfully decoded into stdClass object with json_decode($json) But after persisting the whole entity in Postgres I can only see {"#type": "stdClass"} without any actual data in JSONB column. If I add $assoc = true parameter to json_decode, it successfully saves an array. That's OK for storing and retrieving data. But using arrows instead of square brackets could be more fun. Moreover I found out that on hitting https://github.com/dunglas/doctrine-json-odm/blob/master/src/Serializer.php#L23 $normalizedData local variable is an empty array while $data is still "well-formed" stdClass with huge amount of properties. Is it feature or bug?

Symf5: You have requested a non-existent service "dunglas_doctrine_json_odm.serial

J'ai cette erreur lorsque j'essaie d'installer le package sur mon serveur. (fonctionne très bien sur mon ordi)
Ubuntu 16.04.6 LTS
PHP 7.4.7

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In Container.php line 280:
!!
!!    You have requested a non-existent service "dunglas_doctrine_json_odm.serial
!!    izer".
!!
!!
!!
Script @auto-scripts was called via post-install-cmd

Heeeelp!

Deserialize nested object

Hello,

When I save object with nested object everything works properly and insertion in DB is correct (object is well serialized), but when I want to get my data the nested object wasn't deserialized. Is someone as any idea on how to achieve that ?

Example :

class Foo
{
    /**
     * ...
     */

    /**
     * @ORM\Column(name="configuration", type="json_document", nullable=true)
     */
    public $configuration;

    /**
     * Get configuration.
     */
    public function getConfiguration()
    {
        return $this->configuration;
    }

    /**
     * Set configuration.
     */
    public function setConfiguration($configuration)
    {
        $this->configuration = $configuration;
    }
}

class FooConfiguration
{
    public $bar;
    public $date;
}

Usage

$foo = new Foo();

$foo = new FooConfiguration()
$foo->bar = 'test';
$foo->date = new \Datetime();

$foo->setConfiguration($fooConfiguration);

$em->persist($foo);
$em->flush();

On insertion my date is well serialized but I can't get my \DateTime object back on deserialization

Thank you for your time.

Deserialize return array

Hi, I would like to perform a recursive deserialization. But the problem is that the function return an array instead of object.
services.yaml =>

  # Add DateTime Normalizer to Dunglas' Doctrine JSON ODM Bundle
    dunglas_doctrine_json_odm.serializer:
        class: Dunglas\DoctrineJsonOdm\Serializer
        arguments:
            - ['@dunglas_doctrine_json_odm.normalizer.array', '@serializer.normalizer.datetime', '@dunglas_doctrine_json_odm.normalizer.object']
            - ['@serializer.encoder.json']
        public: true
$userOrder = $serializer->deserialize($request->getContent(), UserOrder::class, 'json');

$userorder is an array instead of object.

this is my entity =>

<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\MaxDepth;

/**
 * @ORM\Entity
 */
class UserOrder
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue(strategy="UUID")
     * @ORM\Column(type="guid", unique=true)
     */
    private $id;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $status;

    /**
     * @var OrderDetail[] | ArrayCollection
     * @ORM\OneToMany(targetEntity=OrderDetail::class, mappedBy="order", orphanRemoval=true, cascade={"persist"})
     */
    private $orderDetails;
....

I can get an object with this instruction in my controller :

$normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor());
$serializer = new Serializer([new ArrayDenormalizer(), $normalizer], [new JsonEncoder()]);
$userOrder = $serializer->deserialize($request->getContent(), UserOrder::class, 'json');

But I would like to use the serializer service directly, is there any way for perform a recursive deserialization with doctrine-json-odm and get real object, not an array ? Thanks for your time

Normalize Collection

Hello,
I notice that the collections are also serialized with the bundle formatting.

Do you think it would be interesting to simplify the standardization of doctrine collections?

Before:

  "logCashes": {
    "keys": [
      0
    ],
    "#type": "Doctrine\\Common\\Collections\\ArrayCollection",
    "empty": false,
    "values": [
      {
        "id": 2123,
        "#type": "PepperBay\\CoreBundle\\ValueObject\\Foo",
        "label": "bar",
        "orderNum": "12345",
        "realDate": null,
        "cashStatus": "Ferme",
        "currencyAmount": 240
      }
    ],
    "iterator": {
      "#type": "ArrayIterator",
      "flags": 0,
      "arrayCopy": [
        {
          "id": 2123,
          "#type": "PepperBay\\CoreBundle\\ValueObject\\Foo",
          "label": "bar",
          "orderNum": "12345",
          "realDate": null,
          "cashStatus": "Ferme",
          "currencyAmount": 240
        }
      ]
    }
  },

After:

  "logCashes": {
    "#type": "Doctrine\\Common\\Collections\\ArrayCollection",
      "0":  {
        "id": 2123,
        "#type": "PepperBay\\CoreBundle\\ValueObject\\Foo",
        "label": "bar",
        "orderNum": "12345",
        "realDate": null,
        "cashStatus": "Ferme",
        "currencyAmount": 240
      }
  }

ObjectNormalizer.php

...
    public function normalize($object, $format = null, array $context = [])
    {
        if ($object instanceof Collection) {
            return array_merge(['#type' => ClassUtils::getClass($object)], $this->serializer->normalize(iterator_to_array($object), $format, $context));
        }

        return array_merge(['#type' => ClassUtils::getClass($object)], $this->objectNormalizer->normalize($object, $format, $context));
    }
...

Join the forces

Hi @dunglas! First congratulations!

I have been looking for a project to mapping object/json to work with postgres, but I not found.

I'm working on a project called taxonomy.
I think could join forces.

What do you think?

Store `#type` in top level objects only

Can we store the #type key in top level objects only?

For any other object in the graph, we should leverage the standard symfony serializer ability to extract the the object class reading the phpdoc or type-hint.

it is better to use ODM metadata instead of serializer

I think it is better to use ODM for jsonb instead of serializer, for example,

  /**
   * Can contain anything (array, objects, nested objects...).
   *
   * @ORM\Column(type="json_document", options={"jsonb": true, "entity"="App\Entity\A_POLO"})
   */
  public $misc;

<document name="App\Entity\A_POLO"

   <field name="name" column="name" type="string" length="255" />
    <field name="createdAt" column="created_at" type="datetime" nullable="true" >
    </field>
    <field name="updatedAt" column="updated_at" type="datetime" nullable="true">
    </field>

Support for API Platform

Hi,

I'm trying to implement this tool on my Symfony 3 project using API Platform 2. Here is my schema:

/**
 * @ORM\Entity
 *
 * @Resource(attributes={
 *     "normalization_context"={"groups"={"dues_default_output"}},
 *     "denormalization_context"={"groups"={"dues_default_input"}}
 * })
 */
class Dues
{
    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var Club
     *
     * @ORM\Column(type="json_document", options={"jsonb": true})
     *
     * @Groups({"dues_default_output", "dues_default_input"})
     */
    private $club;

    /**
     * @var bool
     *
     * @ORM\Column(type="string")
     *
     * @Groups({"dues_default_output", "dues_default_input"})
     */
    private $foo;
}

I'm trying to create a Dues object with its Club object. Here is the request:

{
    "foo": "bar",
    "club": {
        "name": "US CAGNES TENNIS",
        "website": "http://www.uscagnestennis.org",
        "address": "Avenue du colonel Jean-Pierre",
        "zipcode": "06800",
        "city": "Cagnes sur mer"
    }
}

Maybe API Platform 2 doesn't support this yet, or maybe it's not related to API Platform neither, but I get this error:

No resource class found for object of type "LesTilleuls\\ClubBundle\\Entity\\Club"

Any idea how could I fix it?

MariaDB 10.2+ Support?

While MariaDB has no native JSON Type, the JSON related API exists. Whether the data is internally stored as JSON or as LONGTEXT is not important to me, therefore the question whether using this bundle with Doctrine 2.6 on MariaDB 10.2+ will work or not.

DateTime::__construct() expects parameter 1 to be string, array given

My entity has:

     /**
     * @var \DateTime $createdAt
     * @ApiProperty
     * @Groups("read")
     */
     private $createdAt;

    /**
     * @var \DateTime $updatedAt
     * @ApiProperty
     * @Groups("read")
     */
    private $updatedAt;

    /**
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * @param \DateTime $createdAt
     */
        public function setCreatedAt(\DateTime $createdAt)
    {
        $this->createdAt = $createdAt;
    }

    /**
     * @param \DateTime $updatedAt
     */
    public function setUpdatedAt(\DateTime $updatedAt)
    {
        $this->updatedAt = $updatedAt;
    }

I added to services.yaml:

        class: 'Symfony\Component\Serializer\Serializer'
        arguments:
          - ['@serializer.normalizer.datetime', '@dunglas_doctrine_json_odm.normalizer.object']
          - ['@serializer.encoder.json']
        public: true

But I get the error message:
DateTime::__construct() expects parameter 1 to be string, array given

How to fix this?

POPOs data is not being persisted

Thanks for your nice bundle. I got the issue: if I change the json_document related plain php object property, it won't persisted by default.

...
$foo->misc[0]->setName('New Name');
$em->persist($foo);
$em->flush(); //nothing to update by uow

[QUESTION] Autowire Serializer

Hi there.

I use autowiring for services and actions.

When enabling doctrine-json-odm bundle i get the following error for all places where i have autowire / DI for Symfony Serialzer:
Unable to autowire argument of type "Symfony\Compone
nt\Serializer\Serializer" for the service "emma\appbundle\action\adminstatistics\premiumorganizationsaction". Multiple services exist for th
is class (serializer, dunglas_doctrine_json_odm.serializer)

I think the reason is clear to me but i dont know how to solve it.

Thanks for helping!

Cheers Ben

Doctrine seems to not see changes in objects kept in jsonb fields.

Doctrine entity named A has field "b"(jsonb) which contains object B. B has two fields "c and d", both strings.

When I update field c of b
A->b->c = new value entity manager -> flush

Nothing is saved to database. I expected it to update field c of object b in database, but old value remains.

Is that anticipated behaviour? Is that my error, doctrine, or this bundle?

When I put new object to filed b, then changes are registered and field is updated.

I've hope that i was clear enough.

Nested objects are not persisted

Hello.

I have a problem with saving an POPO in database for my Symfony 3.3 project.

I create a new entity (Character), which helds a CharacterSkills POPO, which contains two arrays.= for other POPO, Skill.
`

(in Character.php)
{ 
/**
     * @ORM\Column(type="json_document",nullable=true, options={"jsonb": true})
     */
    public $skillList;

`

namespace AppBundle\Utilities;


use AppBundle\Utilities\Skills\Skill;
class CharacterSkills
{
    private $commonSkills = array();

    private $battleSkills = array();
}

The problem is, that something wrong happens during serialization, I use MariaDB (from XAMPP, MySQL 5.7+), and after putting the POPO in Entity and persisting, Doctrine calculates ChangeSet properly (proved by dumping in my custom event listener), but in database goes only info 'bout type of CharacterSkills:

{"#type":"AppBundle\Utilities\CharacterSkills"}

What wrong is happening? Doctrine and DBAL are updated. Further var_dumping shows, that data is lost in Symfony\Component\Serializer\Serializer.php normalization , but why this can happen?

Allow installation on symfony 5.x

Currently doctrine-json-dom cannot be installed in a Symfony 5.x application. Is there work beyond simply upping the version constraints?

Deprecation Warning with doctrine/dbal 2.6.x-dev

Hi, I'm using this bundle with the master/2.6.x-dev branch of Doctrine (which is needed at the moment to support MySQL natibe JSON). I get this deprecation warning:

User Deprecated: The "Dunglas\DoctrineJsonOdm\Type\JsonDocumentType" class extends "Doctrine\DBAL\Types\JsonArrayType" that is deprecated Use JsonType instead

This raises the question, if Doctrine implements native JSON by itself, dropping the old JSON-array-type in favor of it? Will this bundle then be needed at all? Would be great!

Greets,
spackmat

Could not denormalize object of type "", no supporting normalizer found

Hello 👋 and thanks for this bundle.
I can't get my user object with doctrine find method.
First of all this is my service.yaml and my model:

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    #Add DateTime Normalizer
    dunglas_doctrine_json_odm.serializer:
        class: Symfony\Component\Serializer\Serializer
        arguments:
            - ['@dunglas_doctrine_json_odm.normalizer.array', '@serializer.normalizer.datetime', '@dunglas_doctrine_json_odm.normalizer.object']
            - ['@serializer.encoder.json']
        public: true
        autowire: false
<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * @ORM\Entity(repositoryClass="App\Repository\ProUserRepository")
 */
class ProUser implements UserInterface
{
...
    /**
     * @ORM\Column(type="string", nullable=true, length=15)
     * @Assert\Length(allowEmptyString="false", min="5", max="15")
     */
    private $phone;

    /** @ORM\Column(type="string", length=60, nullable=true)
     */
    private $public_mail;

    /**
     * @ORM\Column(type="json_document", options={"jsonb": true}, nullable=true)
     */
    private $document;

...

I can save my object in database but my find request fail.
Capture d’écran 2020-07-14 à 11 12 14
It seems to deserialize is call in JsonDocumentType without passing type :
return $this->getSerializer()->deserialize($value, '', $this->format, $this->deserializationContext);

Do you have an idea about this ? it is a service configuration problem ?

when i save data i'm getting extra slashes in symfony4

If I create some json, for example:

{
  "date": "2018-10-05 20:38:37",
  "data_retention_policy": "test",
  "error_code": null,
  "error_message": null
}

using the following code:

$request_type = 'createNewUnitTestRequestSetMetadata';
$wrs_json_metadata = WebextractMetadata::$request_type()->getJSON();
echo "wrs_json_metadata is: " . $wrs_json_metadata;
# yields => {"date":"2018-10-05 20:38:37","data_retention_policy":"test","error_code":null,"error_message":null}
$wrs = new WebextractRequestSet();
$date = new \DateTime('@' . strtotime(json_decode($wrs_json_metadata)->date));
$wrs->setDateRequested($date);
$wrs->setMetadata($wrs_json_metadata);
$em->persist($wrs);
$em->flush();

When I look in the database the json values are stored as:

mysql> select metadata from webextract_request_set where id = 5\G;
*************************** 1. row ***************************
metadata: "{\"date\":\"2018-10-05 20:38:37\",\"data_retention_policy\":\"test\",\"error_code\":null,\"error_message\":null}"
1 row in set (0.00 sec)

Am I doing something wrong here? I simply composer require dunglas/doctrine-json-odm and then used php bin/console entity:create and created the metadata column as a json_document field type.

As you may note i'm trying to store the json string to the Entity, should I be trying to store the json object and not a string representation of it?

Thanks for your time. -David

Cannot use the bundle using Symfony4/Flex

I try to use this library on a fresh project using SYmfony4/Flex.

I've an error You have requested a non-existent service "dunglas_doctrine_json_odm.serializer" on my project after install the package with Composer.

Step to reproduce :

$  composer create-project "symfony/skeleton:dev-master" my-project 4.0.0-RC1
$ cd my-project/
$ composer require orm
$ composer require dunglas/doctrine-json-odm
# Then I register the bundle into `config/bundles.php` because it was not detected by Flex
$ bin/console cache:clear

In Container.php line 263:
                                                                                     
  You have requested a non-existent service "dunglas_doctrine_json_odm.serializer".  

Add support to methods name without the need get/set/is

Classes as a:

class ExampleOne
{
    private $name;
    private $type;
    public function __construct($name, $type)
    {
        $this->name = $name;
        $this->type = $type;
    }
    public function name()
    {
        return $this->name;
    }
    public function type()
    {
        return $this->type;
    }

As result:

{"#type":"Domain\\Model\\ExampleOne"}

The expected would be:

{"#type":"Domain\\Model\\ExampleOne", "name": "foo", "type": "bar"}

Sorry to my english

Bad Normalization of DateTime and DateTimeZone

The Normalization of Datetimezone and Datetimedoes not work well since the extracted attributes do not match the real attribute name.
Example for Datetime zone :
The object looks like

DateTimeZone {#857 ▼
  +"timezone_type": 3
  +"timezone": "UTC"
}

where the methods are

  • public array getLocation ( void )
  • public string getName ( void )
  • public int getOffset ( DateTime $datetime )

The raised exception is : Cannot create an instance of DateTimeZone from serialized data because its constructor requires parameter "timezone" to be present.

Is there a way to fix this ?

It always sees changes when generating migration script

Consider the following entity:

/**
 * @ORM\Table
 * @ORM\Entity
 */
class SomeEntity{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="json_document", options={"jsonb": true})
     */
    private $label;
  
    // ...
}

The migration script that is generated with bin/console doctrine:migratoins:diff looks like this:

 public function up(Schema $schema) {
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
        $this->addSql('CREATE SEQUENCE "some_entity_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
        $this->addSql('CREATE TABLE "some_entity" (id INT NOT NULL, label JSONB NOT NULL, PRIMARY KEY(id))');
    }

However, when I run the migrations generation again, the next migration appears:

    public function up(Schema $schema)
    {
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
        $this->addSql('ALTER TABLE some_entity ALTER label TYPE JSONB');
    }

Every call to bin/console doctrine:migratoins:diff results in new migrations script that looks the same.

Persisting ArrayCollection

It's possible to persist an arrayCollection? I'm trying to persist with xml with:

    <field name="priceCollection" column="priceCollection" type="json_document"/>

My database is MariaDB 10.4 I'm using migrations.When I persist I only see void elements

{"#type":"App\Domain\Shared\Price\PriceCollection","keys":[0],"values":[{"#type":"App\Domain\Shared\Price\Price"}],"empty":false,"iterator":{"#type":"ArrayIterator","arrayCopy":[{"#type":"App\Domain\Shared\Price\Price"}],"flags":0}}

Use this package without Symfony

Hi,

There is a way to use this package in doctrine 2 without Symfony ?

From the readme

Doctrine JSON ODM can also be used standalone, without any framework, but the documentation hasn't been redacted yet (PRs welcome!).

So seems to be possible but I cannot found any resource about that.

Can you help me for that ?
Thanks in advance ;)

Use Doctrine-JSON-ODM with JSM Serializer

Hello,
I use JMS Serializer in my project (so the Symfony's Serializer is disabled) and I'd like to use Doctrine-JSON-ODM but nothing explains how to do it.

The error displayed :

The service "dunglas_doctrine_json_odm.serializer" has a dependency on a no
!!    n-existent service "serializer.property_accessor".

When I set an alias on dunglas_doctrine_json_odm.serializer in services.yaml like this:

services:
    dunglas_doctrine_json_odm.serializer:
        alias: jms_serializer
        public: true

The error is now :

!!
!!  Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Dunglas\DoctrineJsonOdm\Type\JsonDocumentType::setSerializer() must implement interface Symfony\Component\Serializer\SerializerInterface, instance of JMS\Serializer\Serializer given, called in /var/www/html/backend/vendor/dunglas/doctrine-json-odm/src/Bundle/DunglasDoctrineJsonOdmBundle.php on line 36 in /var/www/html/backend/vendor/dunglas/doctrine-json-odm/src/Type/JsonDocumentType.php on line 65
!!
!!  Symfony\Component\Debug\Exception\FatalThrowableError: Argument 1 passed to Dunglas\DoctrineJsonOdm\Type\JsonDocumentType::setSerializer() must implement interface Symfony\Component\Serializer\SerializerInterface, instance of JMS\Serializer\Serializer given, called in /var/www/html/backend/vendor/dunglas/doctrine-json-odm/src/Bundle/DunglasDoctrineJsonOdmBundle.php on line 36 in /var/www/html/backend/vendor/dunglas/doctrine-json-odm/src/Type/JsonDocumentType.php on line 65
!!
!!  Call Stack:
!!      2.2013   37534088   1. Symfony\Component\Debug\ErrorHandler->handleException() /var/www/html/backend/vendor/symfony/debug/ErrorHandler.php:0
!!
!!

Is JSM Serializer incompatible with Doctrine-JSON-ODM ?

DBAL master implemented MySQL-JSON now

The README.md mentioned doctrine/dbal#2266 as a requirement for MySQL-support. This PR was dropped in favor of doctrine/dbal#2653, which was merged to master three days ago. Hooray.

Does that mean, this bundle here is now ready for use with the master branch of Doctine DBAL? Or does it need any changes to support it?

Greets, spackmat

Must be available. Call the "setSerializer" method.

Hello,
we encounter a problem on our project:
An instance of "Symfony\Component\Serializer\SerializerInterface" must be available. Call the "setSerializer" method.
We followed the installation steps, but even on a new project we have the same error.

Here is a test project:

https://github.com/DanielStudioSystems/doctrine-json-odm-exemple
For the quick test we used a bdd with the Foo entity
Then create a controller with the route \ test

Here is the error message:

image

Can you help us ?

Is validation supported?

Hey, first of all congrats on this project i've been watching it (and waiting for it ^^') from afar for a while and it looks just great.

So, just to be sure, if i use @Valid annotation on my json_document property, the whole thing will be validated, right?

Doctrine uses `LONGTEXT` instead of `JSON` (using MySQL 5.7.18)

Lib Version
PHP 7.1.12
MySQL 5.7.18
PDO Client API version => mysqlnd 5.0.12-dev - 20150407
Symfony 3.3.10
Doctrine JSON ODM 0.1.1 - 2de29f7

Entity mapping:

    /**
     * @ORM\Column(type="json_document")
     */
    private $filterSettings;

Expected output from bin/console doctrine:schema:update --dump-sql (JSON NOT NULL):

CREATE TABLE sym_filters (id INT AUTO_INCREMENT NOT NULL, creator_sym_user_id INT DEFAULT NULL, type VARCHAR(10) NOT NULL, filter_settings JSON NOT NULL, INDEX IDX_C22A14267A9614D5 (creator_sym_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;

Actual output from bin/console doctrine:schema:update --dump-sql ( LONGTEXT NOT NULL COMMENT '(DC2Type:json_document)'):

CREATE TABLE sym_filters (id INT AUTO_INCREMENT NOT NULL, creator_sym_user_id INT DEFAULT NULL, type VARCHAR(10) NOT NULL, filter_settings LONGTEXT NOT NULL COMMENT '(DC2Type:json_document)', INDEX IDX_C22A14267A9614D5 (creator_sym_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;

Symfony 3.3 : non-existent service "serializer.property_accessor"

On Symfony 3.3, initialisation failed with this error:

The service "dunglas_doctrine_json_odm.serializer" has a dependency on a non-existent service "serializer.property_accessor".

It seems on this version, property accessor service is not available through serializer.property_accessor, but property_accessor.

vagrant@ubuntu-xenial:~/projects/myProject/backend$ console debug:container PropertyAccessorInterface                  
                                                                                                                             
 Select one of the following services to display its information [Symfony\Component\PropertyAccess\PropertyAccessorInterface]
:                                                                                                                            
  [0] Symfony\Component\PropertyAccess\PropertyAccessorInterface                                                             
 > 0                                                                                                                         
                                                                                                                             
                                                                                                                             
 // This service is an alias for the service property_accessor                                                               
                                                                                                                             
Information for Service "property_accessor"                                                                                  
===========================================                                                                                  
                                                                                                                             
 ---------------- ---------------------------------------------------                                                        
  Option           Value                                                                                                     
 ---------------- ---------------------------------------------------                                                        
  Service ID       property_accessor                                                                                         
  Class            Symfony\Component\PropertyAccess\PropertyAccessor                                                         
  Tags             -                                                                                                         
  Public           no                                                                                                        
  Synthetic        no                                                                                                        
  Lazy             no                                                                                                        
  Shared           yes                                                                                                       
  Abstract         no                                                                                                        
  Autowired        no                                                                                                        
  Autoconfigured   no                                                                                                        
 ---------------- ---------------------------------------------------                                  

Workaround:

services:
    serializer.property_accessor: '@property_accessor'

Can't get it working with Sf4

First, I wish you a happy new year !

I try to setup the bundle on a Symfony 4 project and I have a random unexpected error :
An instance of "Symfony\Component\Serializer\SerializerInterface" must be available. Call the "setSerializer" method.

For more context, I use API Platform and try to persist an entity with a value object on it in an Action
Sometimes it works, sometimes not... When I try to debug the DunglasDoctrineJsonOdmBundle class in the boot method, I can see the right instance when dumping the JsonDocumentType::getSerializer method.

Unrecognized option "property_info" under "framework"

Hi,

I have just installed your bundle in my symfony 2.7 project, added you bundle class in the AppKernel.php file to load it in my project but I get the following error message :

InvalidConfigurationException in ArrayNode.php line 312:
Unrecognized option "property_info" under "framework"

The project runs with PHP 7.1, Symfony Framework 2.7

Is there something missing in my configuration, some parameters in the config.yml file ?

Here is the composer.json file :

{
    "description": "VE Cloud website",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.7.14",
        "twig/twig": "^1.0",
        "doctrine/orm": "2.5.x-dev",
        "doctrine/dbal": "2.5.x-dev",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "symfony/serializer": "^2.8",
        "sensio/distribution-bundle": "~4.0",
        "sensio/framework-extra-bundle": "v3.0.16",
        "incenteev/composer-parameter-handler": "~2.0",

        "twig/extensions": "~1.0",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "beberlei/DoctrineExtensions": "dev-master",
        "apy/datagrid-bundle": "dev-master",
        "craue/twigextensions-bundle": "dev-master",
        "stof/doctrine-extensions-bundle": "dev-master",
        "gedmo/doctrine-extensions": "v2.4.1", 
        "phpforce/common": "dev-master",
        "phpforce/soap-client": "dev-master",
        "phpforce/salesforce-bundle": "dev-master",
        "guzzlehttp/guzzle" : "v6.1.1",
        "liuggio/ExcelBundle": "v1.0.6",
        "besimple/soap-client": "0.3.*@dev",
        "ob/highcharts-bundle": "1.*",
        "eluceo/ical": "0.1.3",
        "zendframework/zend-json": "v2.6.1",
        "box/spout": "dev-master",
        "cocur/slugify": "dev-master",
        "verint/enterprise-feedback-bundle" : "dev-master",
        "symfony/var-dumper": "3.4.*@dev",
        "dunglas/doctrine-json-odm" : "v0.1.0",
        "syslogic/doctrine-json-functions":"~2.0",
        "soundasleep/html2text": "~0.5"
        
    },
    "require-dev": {
        "sensio/generator-bundle": "v2.3.5",
        "raulfraile/ladybug-bundle": "~1.0",
        "elao/web-profiler-extra-bundle": "dev-master",
        "leaseweb/version-information-bundle": "dev-master"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "vendor-dir": "vendor_2.7"
    },
    "minimum-stability": "dev",
    "extra": {
        "symfony-assets-install": "symlink",
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    }
}

Here is my AppKernel.php :

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // Symfony Standard Edition bundles
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),

            // 3rd party vendor bundles
            new Dunglas\DoctrineJsonOdm\Bundle\DunglasDoctrineJsonOdmBundle(),
            new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
            new APY\DataGridBundle\APYDataGridBundle(),
            new Craue\TwigExtensionsBundle\CraueTwigExtensionsBundle(),
            new Liuggio\ExcelBundle\LiuggioExcelBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            //new Zenstruck\SlugifyBundle\ZenstruckSlugifyBundle(),
            new Ob\HighchartsBundle\ObHighchartsBundle(),
        	new Verint\FeedbackBundle\VerintFeedbackBundle(),

//            new LanKit\DatatablesBundle\LanKitDatatablesBundle(),
//
            //  Systems vendor bundles
            new Systems\AuditBundle\SystemsAuditBundle(),
            new Systems\DirectoryBundle\SystemsDirectoryBundle(),
            new Systems\GitlabBundle\SystemsGitlabBundle(),
        	new Systems\SparkBundle\SystemsSparkBundle(),
            new Systems\MenuBundle\SystemsMenuBundle( $this ),

            // Application bundles
            new AdminToolsBundle\AdminToolsBundle(),
            new AuditBundle\AuditBundle(),
            new CompanyBundle\CompanyBundle(),
            new DataGridBundle\DataGridBundle(),
            new DirectoryBundle\DirectoryBundle(),
            new EmployeeBundle\EmployeeBundle(),
            new EntitlementBundle\EntitlementBundle(),
            new FeedbackBundle\FeedbackBundle(),
            new FsatBundle\FsatBundle(),
            new GitlabBundle\GitlabBundle(),
            new HIPBundle\HIPBundle(),
            new IcdrBundle\IcdrBundle(),
            new IssueReportBundle\IssueReportBundle(),
            new MetricsBundle\MetricsBundle(),
            new SalesForceBundle\SalesForceBundle(),
            new SecurityBundle\SecurityBundle(),
            new SharedAccountBundle\SharedAccountBundle(),
            new UsageBundle\UsageBundle(),
            new WebsiteBundle\WebsiteBundle(),
            new ProfileBundle\ProfileBundle(),
            new MessageBundle\MessageBundle(),
            new GroupCalendarBundle\GroupCalendarBundle(),
        	new SparkBundle\SparkBundle(),
            new ReportsBundle\ReportsBundle(),
            new AgentCaseOriginBundle\AgentCaseOriginBundle(),
            new ScoreCardsBundle\ScoreCardsBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // Bundles used for development and testing
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new RaulFraile\Bundle\LadybugBundle\RaulFraileLadybugBundle();
            //$bundles[] = new Lsw\VersionInformationBundle\LswVersionInformationBundle();
            $bundles[] = new Elao\WebProfilerExtraBundle\WebProfilerExtraBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}

And the config.yml file :

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: '@WebsiteBundle/Resources/config/listener.yml' }

# Craue Twig Extensions bundle
craue_twig_extensions:  ~

# Framework Configuration
framework:
    secret:       '%secret%'
    router:
        resource: '%kernel.root_dir%/config/routing.yml'
        strict_requirements: '%kernel.debug%'
    csrf_protection: false
    form:
        csrf_protection:
            enabled: false
    validation:      { enable_annotations: true }
    templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
    default_locale:  '%locale%'
    trusted_proxies: ~
    fragments: { path: /_proxy }
    session:
        cookie_domain: '%website.domain%'
        handler_id:    session.handler.pdo

parameters:
    templating.helper.assets.class: WebsiteBundle\Twig\AssetsHelper
# Switch User Listener
    security.authentication.switchuser_listener.class: SecurityBundle\Authentication\SwitchUserListener
# Session configuration
    pdo.db_options:
        db_table:     websitesession
        db_id_col:    session_id
        db_data_col:  session_value
        db_time_col:  session_time
        db_lifetime_col: session_lifetime
    formtype.audit.class: AuditBundle\Form\Type\AuditType

services:
    pdo:
        class: PDO
        arguments:
            - 'mysql:host=%database_host%;dbname=%database_name%'
            - '%database_user%'
            - '%database_password%'
        calls:
            - [setAttribute, [3, 2]]
    session.handler.pdo:
        class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        arguments:
            - '@pdo'
            - '%pdo.db_options%'


# Twig Configuration
twig:
    debug:            '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    form_themes:
        - 'WebsiteBundle:Form:theme.html.twig'
        - 'FeedbackBundle:Form:theme.html.twig'
        - '::checkbox_layout.html.twig'
#    globals:
#        currentUser:  '@context.user'
#        currentEmployee:  '@context.employee'

# Assetic Configuration
assetic:
    debug:          '%kernel.debug%'
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: %kernel.root_dir%/Resources/java/compiler.jar
        #yui_css:
        #    jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar

# Swiftmailer Configuration
swiftmailer:
    transport: '%mailer_transport%'
    host:      '%mailer_host%'
    username:  '%mailer_user%'
    password:  '%mailer_password%'
    spool: { type: memory }

# Doctrine configuration
doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   '%database_driver%'
                host:     '%database_host%'
                dbname:   '%database_name%'
                user:     '%database_user%'
                password: '%database_password%'
                charset:  UTF8
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        resolve_target_entities:
            Systems\AuditBundle\Model\UserInterface: SecurityBundle\Entity\User
            Systems\AuditBundle\Model\ReferenceInterface: SalesForceBundle\Entity\SfdcCase
            Systems\AuditBundle\Model\MetadataInterface: AuditBundle\Entity\Metadata

        entity_managers:
            default:
                auto_mapping: true
                # metadata_cache_driver: apc
                # query_cache_driver: apc
                # result_cache_driver: apc
                dql:
                    string_functions:
                        GROUP_CONCAT: DoctrineExtensions\Query\Mysql\GroupConcat
                        IFNULL:       DoctrineExtensions\Query\Mysql\IfNull
                        YEAR:         DoctrineExtensions\Query\Mysql\Year
                        MONTH:        DoctrineExtensions\Query\Mysql\Month
                        DAY:          DoctrineExtensions\Query\Mysql\Day
                        RAND:         DoctrineExtensions\Query\Mysql\Rand
                        TIMESTAMPDIFF: DoctrineExtensions\Query\Mysql\TimestampDiff
                        WEEK:         DoctrineExtensions\Query\Mysql\Week
                        HOUR:         DoctrineExtensions\Query\Mysql\Hour
                        CONCAT_R1R5:  MetricsBundle\CustomSql\ConcatR1R5
                        SUBSTR_INDEX: MetricsBundle\CustomSql\SubStringIndex
                        DATE_FORMAT:  MetricsBundle\CustomSql\DateFormat
                        ROUND:        MetricsBundle\CustomSql\Round
                        LEFT:         MetricsBundle\CustomSql\Left
                        FLOOR:        MetricsBundle\CustomSql\Floor
                        FULL_GROUP_CONCAT: MetricsBundle\CustomSql\FullGroupConcat
                        SECTOTIME:    MetricsBundle\CustomSql\SecondToTime
                        JSON_EXTRACT: Syslogic\DoctrineJsonFunctions\Query\AST\Functions\Mysql\JsonExtract
                        JSON_SEARCH: Syslogic\DoctrineJsonFunctions\Query\AST\Functions\Mysql\JsonSearch
                        

# Doctrine Extensions
stof_doctrine_extensions:
    orm:
        default:
            timestampable: true
            sluggable: true
            sortable: true

#zenstruck_slugify:
#    twig: true # enable twig filter
#    mode: array # iconv or array mode

#  Company Bundle
_company:
    fiscal_period:
        first_fiscal_month:
            name: November
            year: 2011
            start: '2010-10-31'
#verint EFM Feedback Bundle
verint_feedback:
    wsdlurl:  http://efm.services.vovici.com/ws/projectdata.asmx?wsdl
    userid:   veadmin
    password: API7

Thanks,
DuncanV

Can't get to work with DateTime denormalization

I've used previously the 0.1.3 version and wanted to update it to v1. I've done the setup according to the documentation, just that 3 normalizer, but somehow my dateTime is not deserialized.
I've checked it with xdebug and all 3 normalizers are registered and they have the right order.

My json string:

[{"#type": "App\\Entity\\EventSchedule", "endDate": "2020-04-11T00:00:00+02:00", "startDate": "2020-01-07T00:00:00+01:00"}]

EventSchedule

class EventSchedule
{
    /**
     * Start date.
     *
     * @var DateTimeImmutable
     */
    private $startDate;

    /**
     * End date.
     *
     * @var DateTimeImmutable
     */
    private $endDate;
}

Error message:
Failed to denormalize attribute "endDate" value for class "App\Entity\EventSchedule": Expected argument of type "DateTimeImmutable", "string" given at property path "endDate"

I would highly appreciate any help.
I have ApiPlatform installed, but in this request, it's not used. I tried just calling the service in the controller and passing the string to the deserialize event.

Caching serializer

Hello!

I would to like to know is there any reason why this serializer doesn't implement CacheableSupportsMethodInterface?

Thanks.

POPO column not persisting

Based on the docs, I'm of the understanding that I should be able to create a stdClass object as a property on an Entity, and this will be persisted as json. However, what I'm finding, is this object gets written into the DB (postgres) like so:

{"#type":"stdClass"}

All properties added to the stdClass object seem to disappear.

I've var_dumped out the Entity just to sanity check I have indeed set the data as expected, just before persisting - and it does look to be correct at this point.

If I json_encode the object first, it successfully writes the json, but as a string which is not desirable and misses the point of using this bundle. Based on that, I can only assume I've misunderstood the capabilities of this bundle, discovered a bug, or incorrectly configured it.

Here's what the entity looks like:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\AccountConfigRepository")
 */
class AccountConfig
{
    /**
     * @ORM\Id()
     * @ORM\Column(type="string", length=255)
     */
    private $uuid;

    /**
     * @ORM\Column(type="json_document", options={"jsonb": true})
     */
    private $config;

    public function getUuid(): ?string
    {
        return $this->uuid;
    }

    public function setUuid(string $uuid): self
    {
        $this->uuid = $uuid;
        return $this;
    }

    public function getConfig()
    {
        return $this->config;
    }

    public function setConfig($config): self
    {
        $this->config = $config;
        return $this;
    }
}

And here's an example of the calling code:

                $config = (object)[
                    'colour' => 'blue',
                    'phone' => '00000000000',
                ];

                $accountConfig = new AccountConfig();
                $accountConfig->setUuid($uuid);
                $accountConfig->setConfig($config);

                $entityManager->persist($accountConfig);
                $entityManager->flush();

In terms of wiring up the bundle, I'm using Symfony 4, and I've just added one line to config/bundles.php:

<?php

return [
    ...
    Dunglas\DoctrineJsonOdm\Bundle\DunglasDoctrineJsonOdmBundle::class =>  ['all' => true],
];

Any ideas? Thanks.

Add option to don't store #type along json data

Hello!

What about adding Deserialization type in the app codebase instead of storing it in the database?

Something like:

/**
  * @ORM\Column(type="json_document", class="App\Address", options={"jsonb": true})
  */
public $foo;

class could also be in options if it's easier to manage.
It's a bit like doctrine @Embedded.

My concern is that having classname stored in DB is hard to maintain as a migration strategy has to be established on each namespace change.

How to use the serializer with api platform?

I have an Enity with property "offers":
@Orm\Column(type="json_document", options={"jsonb": true})
Offers is a POPO with an id property that is of type rmsey uuid.

When API-Platform tries to persist the entity, is seems that the uuid cannot be serialized.
What would be the right definition in services.yaml to make the serialization work?

I tried something like this, but it is not working:

dunglas_doctrine_json_odm.serializer:
class: 'Dunglas\DoctrineJsonOdm\Serializer'
arguments:
- ['@api_platform.serializer.normalizer.item', '@dunglas_doctrine_json_odm.normalizer.array', '@dunglas_doctrine_json_odm.normalizer.object']
- ['@serializer.encoder.json']
public: true
autowire: false

Remote the #type attribute

Hi,
Is there a way to remove the #type attribute in the outputted json ? I have no need for denormalization.

Bool in POPO is not persisted when false

I have a bool field in my POPO:

/**
     * @var MyData
     *
     * @ORM\Column(name="data", type="json_document")
     */
    private $data;

In MyData:

/**
     * @var bool
     */
    private $foo = true;

If $foo is false, it's never persisted. And on next read, it's by default true.

I use MySQL and dunglas/doctrine-json-odm: v0.1.1.

Remove depreciation

Since a Doctrine update, we have a depreciation:

[2017-09-27 13:52:13] php.INFO: User Deprecated: The Dunglas\DoctrineJsonOdm\Type\JsonDocumentType class extends Doctrine\DBAL\Types\JsonArrayType that is deprecated Use JsonType instead {"exception":"[object] (ErrorException(code: 0): User Deprecated: The Dunglas\\DoctrineJsonOdm\\Type\\JsonDocumentType class extends Doctrine\\DBAL\\Types\\JsonArrayType that is deprecated Use JsonType instead at /srv/api/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:188)"} []

"Cannot use object of type X as array" exception

Hi, I had used for some time your bundle. Today I came with strange bug.

I make a system for creating a pen and paper RPG character sheet, i save a character as a JSON object.
When I readit from base, I get exception like in title. BaseCharacter is the object kept in database (Postgres, actually), Kawalkator is an character profession (a nested object).

It worked before nicely, butwhat I changed lately was only some PHPDoc and Type-Hints and i think that I didnt change anything more in these or other PHP classes.

What could happen?

Symfony\Component\Debug\Exception\FatalThrowableError:
Cannot use object of type AppBundle\CharacterClasses\Kawalkator as array

  at vendor\dunglas\doctrine-json-odm\src\Normalizer\ObjectNormalizer.php:63
  at Dunglas\DoctrineJsonOdm\Normalizer\ObjectNormalizer->denormalize(object(Kawalkator), 'AppBundle\\CharacterClasses\\CharacterProffesion', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Serializer.php:292)
  at Symfony\Component\Serializer\Serializer->denormalizeObject(object(Kawalkator), 'AppBundle\\CharacterClasses\\CharacterProffesion', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Serializer.php:174)
  at Symfony\Component\Serializer\Serializer->denormalize(object(Kawalkator), 'AppBundle\\CharacterClasses\\CharacterProffesion', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer.php:269)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->validateAndDenormalize('AppBundle\\CharacterClasses\\BaseCharacter', 'profession', object(Kawalkator), 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer.php:196)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize(array('alternatives' => true, 'defaultMixedPoints' => 5, 'freePoints' => 0, 'name' => 'name', 'surname' => 'surname', 'coatOfArmsPicture' => 'coat.jpg', 'coatOfArms' => 'surname', 'call' => 'call', 'portrait' => 'image.jpg', 'origin' => object(LithuaniaOrigin), 'confession' => null, 'age' => 'YOUNG', 'socialStrata' => null, 'sorceryBelief' => null, 'piety' => null, 'honour' => null, 'courage' => null, 'amorousness' => null, 'rightousness' => null, 'profession' => object(Kawalkator), 'characterType' => null, 'fortunePoints' => null, 'freeSkillPoints' => 12, 'freeAttributePoints' => 12, 'defaultSkillPoints' => 12, 'defaultAttributePoints' => 12, 'mixedPoints' => 5, 'addedAttributePoints' => array(0, 0, 0, 0, 0, 0), 'ownedPerks' => array(), 'ownedSkills' => array()), 'AppBundle\\CharacterClasses\\BaseCharacter', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
     (vendor\dunglas\doctrine-json-odm\src\Normalizer\ObjectNormalizer.php:68)
  at Dunglas\DoctrineJsonOdm\Normalizer\ObjectNormalizer->denormalize(array('alternatives' => true, 'defaultMixedPoints' => 5, 'freePoints' => 0, 'name' => 'name', 'surname' => 'surname', 'coatOfArmsPicture' => 'coat.jpg', 'coatOfArms' => 'surname', 'call' => 'call', 'portrait' => 'image.jpg', 'origin' => object(LithuaniaOrigin), 'confession' => null, 'age' => 'YOUNG', 'socialStrata' => null, 'sorceryBelief' => null, 'piety' => null, 'honour' => null, 'courage' => null, 'amorousness' => null, 'rightousness' => null, 'profession' => object(Kawalkator), 'characterType' => null, 'fortunePoints' => null, 'freeSkillPoints' => 12, 'freeAttributePoints' => 12, 'defaultSkillPoints' => 12, 'defaultAttributePoints' => 12, 'mixedPoints' => 5, 'addedAttributePoints' => array(0, 0, 0, 0, 0, 0), 'ownedPerks' => array(), 'ownedSkills' => array()), '', 'json', array())
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Serializer.php:292)
  at Symfony\Component\Serializer\Serializer->denormalizeObject(array('#type' => 'AppBundle\\CharacterClasses\\BaseCharacter', 'alternatives' => true, 'defaultMixedPoints' => 5, 'freePoints' => 0, 'name' => 'name', 'surname' => 'surname', 'coatOfArmsPicture' => 'coat.jpg', 'coatOfArms' => 'surname', 'call' => 'call', 'portrait' => 'image.jpg', 'origin' => array('#type' => 'AppBundle\\CharacterClasses\\LithuaniaOrigin', 'originSkill' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT')), 'name' => 'Litwa', 'description' => 'Z Wielkiego Księstwa. Łeb +2, Łowiectwo + 2 lub Tropienie +1', 'attributes' => array(0, 0, 0, 0, 0, 2), 'alternativeSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT'))), 'confession' => null, 'age' => 'YOUNG', 'socialStrata' => null, 'sorceryBelief' => null, 'piety' => null, 'honour' => null, 'courage' => null, 'amorousness' => null, 'rightousness' => null, 'profession' => array('#type' => 'AppBundle\\CharacterClasses\\Kawalkator', 'defaultType' => 0, 'description' => null, 'alternativePerks' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'alternativeSkills' => array(array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN'))), 'attributes' => array(3, 4, 5, 6, 7, 8), 'classSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedPerk' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'name' => 'Kawalkator', 'defaultFreePoints' => 0, 'defaultMixedPoints' => 5, 'defaultSkills' => array(), 'defaultPerks' => array()), 'characterType' => null, 'fortunePoints' => null, 'freeSkillPoints' => 12, 'freeAttributePoints' => 12, 'defaultSkillPoints' => 12, 'defaultAttributePoints' => 12, 'mixedPoints' => 5, 'addedAttributePoints' => array(0, 0, 0, 0, 0, 0), 'ownedPerks' => array(), 'ownedSkills' => array()), '', 'json', array())
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Serializer.php:174)
  at Symfony\Component\Serializer\Serializer->denormalize(array('#type' => 'AppBundle\\CharacterClasses\\BaseCharacter', 'alternatives' => true, 'defaultMixedPoints' => 5, 'freePoints' => 0, 'name' => 'name', 'surname' => 'surname', 'coatOfArmsPicture' => 'coat.jpg', 'coatOfArms' => 'surname', 'call' => 'call', 'portrait' => 'image.jpg', 'origin' => array('#type' => 'AppBundle\\CharacterClasses\\LithuaniaOrigin', 'originSkill' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT')), 'name' => 'Litwa', 'description' => 'Z Wielkiego Księstwa. Łeb +2, Łowiectwo + 2 lub Tropienie +1', 'attributes' => array(0, 0, 0, 0, 0, 2), 'alternativeSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT'))), 'confession' => null, 'age' => 'YOUNG', 'socialStrata' => null, 'sorceryBelief' => null, 'piety' => null, 'honour' => null, 'courage' => null, 'amorousness' => null, 'rightousness' => null, 'profession' => array('#type' => 'AppBundle\\CharacterClasses\\Kawalkator', 'defaultType' => 0, 'description' => null, 'alternativePerks' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'alternativeSkills' => array(array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN'))), 'attributes' => array(3, 4, 5, 6, 7, 8), 'classSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedPerk' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'name' => 'Kawalkator', 'defaultFreePoints' => 0, 'defaultMixedPoints' => 5, 'defaultSkills' => array(), 'defaultPerks' => array()), 'characterType' => null, 'fortunePoints' => null, 'freeSkillPoints' => 12, 'freeAttributePoints' => 12, 'defaultSkillPoints' => 12, 'defaultAttributePoints' => 12, 'mixedPoints' => 5, 'addedAttributePoints' => array(0, 0, 0, 0, 0, 0), 'ownedPerks' => array(), 'ownedSkills' => array()), '', 'json', array())
     (vendor\symfony\symfony\src\Symfony\Component\Serializer\Serializer.php:132)
  at Symfony\Component\Serializer\Serializer->deserialize(array('#type' => 'AppBundle\\CharacterClasses\\BaseCharacter', 'alternatives' => true, 'defaultMixedPoints' => 5, 'freePoints' => 0, 'name' => 'name', 'surname' => 'surname', 'coatOfArmsPicture' => 'coat.jpg', 'coatOfArms' => 'surname', 'call' => 'call', 'portrait' => 'image.jpg', 'origin' => array('#type' => 'AppBundle\\CharacterClasses\\LithuaniaOrigin', 'originSkill' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT')), 'name' => 'Litwa', 'description' => 'Z Wielkiego Księstwa. Łeb +2, Łowiectwo + 2 lub Tropienie +1', 'attributes' => array(0, 0, 0, 0, 0, 2), 'alternativeSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łowiectwo', 'description' => 'Opis łowiectwa', 'value' => 2, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'HUNT'))), 'confession' => null, 'age' => 'YOUNG', 'socialStrata' => null, 'sorceryBelief' => null, 'piety' => null, 'honour' => null, 'courage' => null, 'amorousness' => null, 'rightousness' => null, 'profession' => array('#type' => 'AppBundle\\CharacterClasses\\Kawalkator', 'defaultType' => 0, 'description' => null, 'alternativePerks' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'alternativeSkills' => array(array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN'))), 'attributes' => array(3, 4, 5, 6, 7, 8), 'classSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedSkills' => array(array('#type' => 'AppBundle\\CharacterClasses\\BaseSkill', 'name' => 'Łacina', 'description' => 'Język łaciński', 'value' => 1, 'assocAttribute' => 3, 'isCommon' => true, 'code' => 'LATIN')), 'selectedPerk' => array(array('#type' => 'AppBundle\\CharacterClasses\\BasePerk', 'name' => 'Ostroznosc', 'description' => 'Opis ostroznosci', 'cost' => '-3', 'code' => 'CAUTION')), 'name' => 'Kawalkator', 'defaultFreePoints' => 0, 'defaultMixedPoints' => 5, 'defaultSkills' => array(), 'defaultPerks' => array()), 'characterType' => null, 'fortunePoints' => null, 'freeSkillPoints' => 12, 'freeAttributePoints' => 12, 'defaultSkillPoints' => 12, 'defaultAttributePoints' => 12, 'mixedPoints' => 5, 'addedAttributePoints' => array(0, 0, 0, 0, 0, 0), 'ownedPerks' => array(), 'ownedSkills' => array()), '', 'json', array())
     (vendor\dunglas\doctrine-json-odm\src\Type\JsonDocumentType.php:116)
  at Dunglas\DoctrineJsonOdm\Type\JsonDocumentType->convertToPHPValue('{"#type":"AppBundle\\\\CharacterClasses\\\\BaseCharacter","alternatives":true,"defaultMixedPoints":5,"freePoints":0,"name":"name","surname":"surname","coatOfArmsPicture":"coat.jpg","coatOfArms":"surname","call":"call","portrait":"image.jpg","origin":{"#type":"AppBundle\\\\CharacterClasses\\\\LithuaniaOrigin","originSkill":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141owiectwo","description":"Opis \\u0142owiectwa","value":2,"assocAttribute":3,"isCommon":true,"code":"HUNT"}],"name":"Litwa","description":"Z Wielkiego Ksi\\u0119stwa. \\u0141eb +2, \\u0141owiectwo + 2 lub Tropienie +1","attributes":[0,0,0,0,0,2],"alternativeSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141owiectwo","description":"Opis \\u0142owiectwa","value":2,"assocAttribute":3,"isCommon":true,"code":"HUNT"}]},"confession":null,"age":"YOUNG","socialStrata":null,"sorceryBelief":null,"piety":null,"honour":null,"courage":null,"amorousness":null,"rightousness":null,"profession":{"#type":"AppBundle\\\\CharacterClasses\\\\Kawalkator","defaultType":0,"description":null,"alternativePerks":[{"#type":"AppBundle\\\\CharacterClasses\\\\BasePerk","name":"Ostroznosc","description":"Opis ostroznosci","cost":"-3","code":"CAUTION"}],"alternativeSkills":[[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}]],"attributes":[3,4,5,6,7,8],"classSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}],"selectedSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}],"selectedPerk":[{"#type":"AppBundle\\\\CharacterClasses\\\\BasePerk","name":"Ostroznosc","description":"Opis ostroznosci","cost":"-3","code":"CAUTION"}],"name":"Kawalkator","defaultFreePoints":0,"defaultMixedPoints":5,"defaultSkills":[],"defaultPerks":[]},"characterType":null,"fortunePoints":null,"freeSkillPoints":12,"freeAttributePoints":12,"defaultSkillPoints":12,"defaultAttributePoints":12,"mixedPoints":5,"addedAttributePoints":[0,0,0,0,0,0],"ownedPerks":[],"ownedSkills":[]}', object(PostgreSQL92Platform))
     (vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator.php:131)
  at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateRowData(array('id_1' => 107, 'chardata_2' => '{"#type":"AppBundle\\\\CharacterClasses\\\\BaseCharacter","alternatives":true,"defaultMixedPoints":5,"freePoints":0,"name":"name","surname":"surname","coatOfArmsPicture":"coat.jpg","coatOfArms":"surname","call":"call","portrait":"image.jpg","origin":{"#type":"AppBundle\\\\CharacterClasses\\\\LithuaniaOrigin","originSkill":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141owiectwo","description":"Opis \\u0142owiectwa","value":2,"assocAttribute":3,"isCommon":true,"code":"HUNT"}],"name":"Litwa","description":"Z Wielkiego Ksi\\u0119stwa. \\u0141eb +2, \\u0141owiectwo + 2 lub Tropienie +1","attributes":[0,0,0,0,0,2],"alternativeSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141owiectwo","description":"Opis \\u0142owiectwa","value":2,"assocAttribute":3,"isCommon":true,"code":"HUNT"}]},"confession":null,"age":"YOUNG","socialStrata":null,"sorceryBelief":null,"piety":null,"honour":null,"courage":null,"amorousness":null,"rightousness":null,"profession":{"#type":"AppBundle\\\\CharacterClasses\\\\Kawalkator","defaultType":0,"description":null,"alternativePerks":[{"#type":"AppBundle\\\\CharacterClasses\\\\BasePerk","name":"Ostroznosc","description":"Opis ostroznosci","cost":"-3","code":"CAUTION"}],"alternativeSkills":[[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}]],"attributes":[3,4,5,6,7,8],"classSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}],"selectedSkills":[{"#type":"AppBundle\\\\CharacterClasses\\\\BaseSkill","name":"\\u0141acina","description":"J\\u0119zyk \\u0142aci\\u0144ski","value":1,"assocAttribute":3,"isCommon":true,"code":"LATIN"}],"selectedPerk":[{"#type":"AppBundle\\\\CharacterClasses\\\\BasePerk","name":"Ostroznosc","description":"Opis ostroznosci","cost":"-3","code":"CAUTION"}],"name":"Kawalkator","defaultFreePoints":0,"defaultMixedPoints":5,"defaultSkills":[],"defaultPerks":[]},"characterType":null,"fortunePoints":null,"freeSkillPoints":12,"freeAttributePoints":12,"defaultSkillPoints":12,"defaultAttributePoints":12,"mixedPoints":5,"addedAttributePoints":[0,0,0,0,0,0],"ownedPerks":[],"ownedSkills":[]}', 'user_id_3' => null), array())
     (vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator.php:69)
  at Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateAllData()
     (vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\AbstractHydrator.php:150)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(object(PDOStatement), object(ResultSetMapping), array())
     (vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\Entity\BasicEntityPersister.php:720)
  at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->load(array('id' => 107), null, null, array(), null, 1, null)
     (vendor\doctrine\orm\lib\Doctrine\ORM\EntityRepository.php:196)
  at Doctrine\ORM\EntityRepository->findOneBy(array('id' => 107))
     (src\AppBundle\Controller\DPController.php:326)
  at AppBundle\Controller\DPController->attributeAction(object(Request))
  at call_user_func_array(array(object(DPController), 'attributeAction'), array(object(Request)))
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:153)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:169)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web\app_dev.php:29)
  at require('C:\\Users\\MARCWISN\\DP\\dzikiePola\\web\\app_dev.php')
     (vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle\Resources\router.php:42)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.