stephpy / timeline-bundle

Symfony2 bundle to make timeline
192 stars 57 forks source link

Exception when i try to display timeline #163

Closed abenmoussa closed 9 years ago

abenmoussa commented 10 years ago

Hello, Hello,

$elements is an array of identifiers.

I want to add this action to my timeline:

$elementsComps = $this->findOrCreateComponent ('MyClass', $elements ); $action = $this->create ( $subject, 'publish_added_photo_album', array ('elements'=>$elementsComps) ); $this->updateAction ( $action );

when i try to display the timeline, i got the exception below, does method findOrCreateComponent accepts array of Ids? Thank you

ContextErrorException: Notice: Array to string conversion in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php line 568 in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php line 568 at ErrorHandler->handle('8', 'Array to string conversion', 'C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php', '568', array('literal' => array('2'))) in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php line 568 at Expr->_quoteLiteral(array('2')) in C:\wamp\www\Symfony\vendor\doctrine\orm\lib\Doctrine\ORM\Query\Expr.php line 422 at Expr->in('r.id', array(array('2'))) in C:\wamp\www\Symfony\vendor\stephpy\TimelineBundle\Spy\TimelineBundle\Filter\DataHydrator\Locator\DoctrineORM.php line 75

stephpy commented 10 years ago

Hi,

findOrCreateCompontent accepts an array of id. But it's to define ONE element (array is supported for many primary keys).

If $elementComps define +1 elements, you should call x times findOrCreateComponent. Then, on ->create, you cannot provide an ARRAY of entities, you can give an entity for one ky element0 => $element0, element1=>$element1.