Показаны сообщения с ярлыком mongodb. Показать все сообщения
Показаны сообщения с ярлыком mongodb. Показать все сообщения

среда, 13 марта 2019 г.

[MongoDB] [Symfony] "Could not find the document manager for class" fix with autowiring

For repository use this class below. Notice that it uses ManagerRegistry instead of Symfony\Bridge\Doctrine\RegistryInterface
<?php

use AppBundle\Document\Product;
use Doctrine\Bundle\MongoDBBundle\Repository\ServiceDocumentRepository;
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;

class ProductRepository extends ServiceDocumentRepository
{
    public function __construct(ManagerRegistry $managerRegistry)
    {
        parent::__construct($managerRegistry, Product::class);
    }
}

вторник, 18 декабря 2018 г.

PHP + Mongodb Invalid type specified "object" how to fix

Add to your bundle class in build() method: Type::addType('object', 'Payum\Bridge\Doctrine\Types\ObjectType');

For example:
<?php
namespace Acme\PaymentBundle;

use Doctrine\ODM\MongoDB\Types\Type;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmePaymentBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        Type::addType('object', 'Payum\Bridge\Doctrine\Types\ObjectType');
    }
}
This error also occurs if you trying to add mongodb token storage to Payum payment system.

среда, 4 июля 2018 г.

Notice: undefined index id after changing MongoDB id to string

after using a php annotation @Mongo\Id(strategy="NONE") you can receive Notice: undefined index id PHP error, for this just run symfony cache:clear command.