I removed the old symfony version of DisconnectedClassMetadataFactory and
use the one in the ORM now. Maybe in a future version of Doctrine2 we can
allow the inheritance mapping to be specified and not use reflection for
that.

- Jon

On Mon, Nov 22, 2010 at 10:12 AM, Thomas Rabaix <[email protected]>wrote:

> Thanks for your reply. Also I just have a quick chat with Jonathan. here
> the copy :
>
> Jonathan Wage   ‣       sort of, it is a complicated issue
> Jonathan Wage   ‣       hence why we have that weird solution in place
> Jonathan Wage   ‣       it may not be an issue anymore
> Jonathan Wage   ‣       what was being worked around may be fixed by nw
> Jonathan Wage   ‣       now
> Jonathan Wage   ‣       i will have to do some looking
>        Thomas  ‣       ok, great as for now the xml and yml version +
> inheritance is quite broken.
> Thomas  ‣       and not usable
>        Jonathan Wage   ‣       its usable just as long as you write your
> own entities
> Jonathan Wage   ‣       and dont try and generate anything
> Jonathan Wage   ‣       b/c thats all it is used for
> Jonathan Wage   ‣       is to generate your entities
>        Thomas  ‣       yes I add extra field inside the xml files
> Thomas  ‣       then run the generate
> Thomas  ‣       and with the change I made => boom
>        Jonathan Wage   ‣       the problem is this feature ws not meant to
> be used like that
> Jonathan Wage   ‣       its not like you change your mapping, regenerate
> Jonathan Wage   ‣       like in symfony1
> Jonathan Wage   ‣       the feature is meant to be a import from an old
> project
>        Thomas  ‣       ok, but It works withou inheritance
>        Jonathan Wage   ‣       with doctrine2, you write oyur domain in php
> code
> Jonathan Wage   ‣       i know
> Jonathan Wage   ‣       because in Doctrine2, the inheritance is not mapped
> Jonathan Wage   ‣       it is read at runtime from the classes
> Jonathan Wage   ‣       and cached in the ClassMetadata instances
>        Thomas  ‣       ok then what the point of the xml or yml then ?
> Thomas  ‣       if at the end we need to code property and method
>        Jonathan Wage   ‣       the point is to map your php classes that
> you have written
> Jonathan Wage   ‣       you dont write your mapping files first
> Jonathan Wage   ‣       write your php classes first
> Jonathan Wage   ‣       the structure
> Jonathan Wage   ‣       inheritance
> Jonathan Wage   ‣       ionterfaces
> Jonathan Wage   ‣       this is object oriented domain modeling
> Jonathan Wage   ‣       not xml/yaml domain modeling
>        Thomas  ‣       ok, then annotation is better then
>        Jonathan Wage   ‣       you design with your object domain then map
> it
> Jonathan Wage   ‣       no
> Jonathan Wage   ‣       forget mapping in the first step of designing your
> domain
> Jonathan Wage   ‣       write php classes
> Jonathan Wage   ‣       inject dependencies through constructure and
> setters
> Jonathan Wage   ‣       then, when you are done..map it to Doctirne2
>        Thomas  ‣       ok, that point is maybe not clear in the
> documentation.
>        Jonathan Wage   ‣       well it is clear that symfony2 and doctrine2
> are not symfony1
>        Thomas  ‣       but I get your point
>        Jonathan Wage   ‣       and we've tried to say its not like sf1 and
> d1
> Jonathan Wage   ‣       where you work from the database
> Jonathan Wage   ‣       and tables
>        Thomas  ‣       I get it from the wrong side
>        Jonathan Wage   ‣       then generate your domain
> Jonathan Wage   ‣       you just design in regular old php code
> Jonathan Wage   ‣       its not hard to class
> Jonathan Wage   ‣       to write a class
> Jonathan Wage   ‣       class User { private $id; private $username; }
> Jonathan Wage   ‣       it doesnt have to work 100% you just design
> Jonathan Wage   ‣       lay out your domain
> Jonathan Wage   ‣       when you think in terms of tables and columns
> Jonathan Wage   ‣       instead of objects and depdencies
> Jonathan Wage   ‣       your design is going to suck
>        Thomas  ‣       yes I get that
>        Jonathan Wage   ‣       so we stil have a problem in the code that
> could be better
> Jonathan Wage   ‣       the issue is Doctrine2 reads the inheritance of
> classes using php reflection
> Jonathan Wage   ‣       at runtime and caches it in the metadata
> Jonathan Wage   ‣       so when the class does not exist
> Jonathan Wage   ‣       the class metadata loading fails
> Jonathan Wage   ‣       when you try and generate the class the first time
>        Thomas  ‣       ok can I share this chat on the mailing list ?
>        Jonathan Wage   ‣       ya
>        Thomas  ‣       thanks
>
>
> On 22 nov. 2010, at 17:01, Benjamin Eberlei wrote:
>
> >
> > No thats wrong. XML and YML are stable.
> >
> > What is not supported is XML,YML AND EntityGenerator. You are perfectly
> > fine when writing the entity code yourself.
> >
> > The second problem is actually the same with regard to the
> > EntityGenerator.
> >
> > Just keep in mind "inheritance + EntityGenerator = not (fully)
> supported".
> > There is actually code generated, but you have to work on it a bit
> > manually
> > to get it working.
> >
> > greetings,
> > Benjamin
> >
> > On Mon, 22 Nov 2010 16:45:29 +0100, Thomas Rabaix
> > <[email protected]>
> > wrote:
> >> Ok, I just runs into these problems ...
> >>
> >> So, my understanding is
> >>      => that the yml and xml format is broken and there is no solution.
> >>      => The only stable solution is to use annotation.
> >>
> >> I don't get your explanation from the point 2. The class can be non
> >> existant but the definition is set inside the XML or yml file. The
> > solution
> >> will be to add an extra check to load information from these files.
> >>
> >> On 22 nov. 2010, at 16:28, Benjamin Eberlei wrote:
> >>
> >>>
> >>> Two problems:
> >>>
> >>> 1. Using XML and YAML Mapping you cannot perform Reflection on the not
> >>> existing classes (in case of the EntityGenerator). Most of the Class
> >>> Metadata code however relies on Reflection. This is why the
> > disconnected
> >>> stuff is necessary (maybe we should call it Unreflected).
> >>>
> >>> 2. The problem is inheritance hierachies cannot be generated from the
> >>> YAML
> >>> and XML metadata information (EntityGenerator). Its just not supported
> >>> conceptually, because the mapping information is missing the
> > information
> >>> which class is parent to which other. That is why the
> >>> DisconnectedClassMetadata is necessary to return an empty array()
> > instead
> >>> of trying to call get_parent_classes for a non existant class.
> >>>
> >>> greetings,
> >>> Benjamin
> >>>
> >>> On Mon, 22 Nov 2010 15:52:52 +0100, Thomas Rabaix
> >>> <[email protected]>
> >>> wrote:
> >>>> Hello,
> >>>>
> >>>> The DoctrineCommand::getBundleMetadatas function uses a
> >>>> SymfonyDisconnectedClassMetadataFactory which failed to load
> > information
> >>>> from parent class as the
> >>> DisconnectedClassMetadataFactory::getParentClass
> >>>> always return an empty array. I have made a quick patch here, I don't
> >>> want
> >>>> to create a pull request as I don't know any side effect.
> >>>>
> >>>> I don't see the point of SymfonyDisconnectedClassMetadataFactory ...
> > as
> >>>> the class will never load all entities information.
> >>>>
> >>>> diff --git
> >>> a/src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php
> >>>> b/src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php
> >>>> index da04e18..96e2e76 100644
> >>>> --- a/src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php
> >>>> +++ b/src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php
> >>>> @@ -139,7 +139,8 @@ abstract class DoctrineCommand extends Command
> >>>>        $bundleMetadatas = array();
> >>>>        $entityManagers = $this->getDoctrineEntityManagers();
> >>>>        foreach ($entityManagers as $key => $em) {
> >>>> -            $cmf = new SymfonyDisconnectedClassMetadataFactory($em);
> >>>> +//            $cmf = new
> > SymfonyDisconnectedClassMetadataFactory($em);
> >>>> +            $cmf = $em->getMetadataFactory();
> >>>>            $metadatas = $cmf->getAllMetadata();
> >>>>            foreach ($metadatas as $metadata) {
> >>>>
> >>>> @@ -151,19 +152,4 @@ abstract class DoctrineCommand extends Command
> >>>>
> >>>>        return $bundleMetadatas;
> >>>>    }
> >>>> -}
> >>>> -
> >>>> -class SymfonyDisconnectedClassMetadataFactory extends
> >>>> DisconnectedClassMetadataFactory
> >>>> -{
> >>>> -    /**
> >>>> -     * @override
> >>>> -     */
> >>>> -    protected function _newClassMetadataInstance($className)
> >>>> -    {
> >>>> -        if (class_exists($className)) {
> >>>> -            return new ClassMetadata($className);
> >>>> -        } else {
> >>>> -            return new ClassMetadataInfo($className);
> >>>> -        }
> >>>> -    }
> >>>> }
> >>>
> >>> --
> >>> If you want to report a vulnerability issue on symfony, please send it
> >>> to security at symfony-project.com
> >>>
> >>> You received this message because you are subscribed to the Google
> >>> Groups "symfony developers" group.
> >>> To post to this group, send email to [email protected]
> >>> To unsubscribe from this group, send email to
> >>> [email protected]<symfony-devs%[email protected]>
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/symfony-devs?hl=en
> >
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
> >
> > You received this message because you are subscribed to the Google
> > Groups "symfony developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<symfony-devs%[email protected]>
> > For more options, visit this group at
> > http://groups.google.com/group/symfony-devs?hl=en
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-devs%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>



-- 
Jonathan H. Wage
http://www.twitter.com/jwage

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to