stephpy / timeline-bundle

Symfony2 bundle to make timeline
192 stars 57 forks source link

Component Entity not containing model #119

Closed ppounder closed 10 years ago

ppounder commented 10 years ago

Hi there, I've followed your installation docs and attempted to insert an action and I'm getting the following error

[Semantical Error] line 0, col 60 near 'model = :model ...\Entity\Component has no field or association named model 

Checking my entity and resulting DB table, Component only has the id field in. I've downloaded your demo version which contains these fields, but are built in the DoctrineMigrations script. Ultimately I'm trying to pass my FOSUserBundle $user object into the subject and have tried the following

$subject       = $actionManager->findOrCreateComponent($user);

where $user is the actual single user object I've also tried:

$subject       = $actionManager->findOrCreateComponent('User', $user->getId());

But get the same error. Would appreciate any help, I know this hasn't been worked on for a while but I'm assuming everything is stable and working. I'm running Symfony 2.4.1, but expect it to work ok. Kind regards Paul Pounder

ppounder commented 10 years ago

UPDATE: I can see the fields in the Base Component in Spy\Timeline\Model\Component but it's not coming through when I update my schema. TimelineBundle is in the AppKernal. I'm using ORM. Baffled.

stephpy commented 10 years ago

Hi, it seems you forgot to inherits from BaseComponent into your Entity\Component class.

<?php

namespace Yo\UrBundle\Entity;

use Spy\TimelineBundle\Entity\Component as BaseComponent;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="spy_timeline_component")
 */
class Component extends BaseComponent
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

Else you'll have more than id field in component table.

You have to inherits on baseObjects on EACH entities (and not inherit from Spy\Timeline\Model\Component but Spy\Timeline\Entity\Component)

ppounder commented 10 years ago

Hi Stephane,

This is my Component Entity

<?php

namespace Acme\DemoBundle\Entity;

use Spy\TimelineBundle\Entity\Component as BaseComponent;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="spy_timeline_component")
 */
class Component extends BaseComponent
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

It seems identical. I guess I could add the required fields directly into this entity, but obviously would rather it work by building it from the extended entity class(es). Is there anything else you need to see that might help?

Regards Paul

stephpy commented 10 years ago

Mmmmh, weird, BaseComponent here should load this file and btw add other fields.

What is your doctrine versions ? composer show -i | grep doctrine

ppounder commented 10 years ago

That's what I thought. I'm pretty much running up to date I think with Doctrine, and Symfony 2.4.1:

doctrine/annotations v1.1.2 Docblock Annotations Parser doctrine/cache v1.3.0 Caching library offering an object-oriented API for many cache backends doctrine/collections v1.2 Collections Abstraction library doctrine/common v2.4.1 Common Library for Doctrine projects doctrine/data-fixtures v1.0.0 Data Fixtures for all Doctrine Object Managers doctrine/dbal v2.4.2 Database Abstraction Layer doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle doctrine/doctrine-fixtures-bundle dev-master 42ac886 Symfony DoctrineFixturesBundle doctrine/inflector v1.0 Common String Manipulations with regard to casing and singular/plural rules. doctrine/lexer v1.0 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers. doctrine/orm v2.4.1 Object-Relational-Mapper for PHP

ppounder commented 10 years ago

I'm using PHP Storm when I click on BaseComponent it takes me to https://github.com/stephpy/TimelineBundle/blob/master/Entity/Component.php Which extends: https://github.com/stephpy/timeline/blob/master/src/Spy/Timeline/Model/Component.php

stephpy commented 10 years ago

It's ok for inherits,

It seems something changed on Doctrine or there is a mistake on the configuration of your application.

Mistake is clear, mapping of super class Spy\TimelineBundle/Entity/Component.php is not used in doctrine. :\

Launch ./app/console doctrine:mapping:info, you should see Acme\DemoBundle\Entity\Component and Spy\TimelineBundle\Entity\Component in the list.

Other question, have you same issue on other entities ?

ppounder commented 10 years ago

Hmm that's interesting. I can't see the Spy\TimelineBundle/Entity/Component.php in the mapping:info but I can see my FOSUserBundle super classes ok. Completely baffled now :)

This is my config:

spy_timeline:
    drivers:
        orm:
            object_manager: doctrine.orm.entity_manager
            classes:
                timeline:         Acme\DemoBundle\Entity\Timeline
                action:           Acme\DemoBundle\Entity\Action
                component:        Acme\DemoBundle\Entity\Component
                action_component: Acme\DemoBundle\Entity\ActionComponent
ppounder commented 10 years ago

RIght I have it!. I am using a second entity manager. I hadn't added SpyTimelineBundle into the mappings for that entity manager.

My apologies for wasting your time. It's working now.

stephpy commented 10 years ago

Oh :) Nice to know, not thought to this possibility.

Thanks ;)