Doctrine 1
  1. Doctrine 1
  2. DC-277

Doctrine_Core::loadModels() is getting class name from file name and not the actual class name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Invalid
    • Affects Version/s: 1.2.0-BETA3
    • Fix Version/s: None
    • Component/s: Import/Export
    • Labels:
      None

      Description

      If models has any prefix Doctrine_Core::loadModels() fails as fails all export scripts, because for models:

      Model_Test
      Model_Test2

      it returns:

      array(
      'Test' => 'Test',
      'Test2' => 'Test2'
      )

      This is incorrect and Doctrine_Core::filterInvalidModels() filters out these classes, hence none of the models become available.

      Expected behaviour: classPrefix should be possible to pass to configuration of task (now I need to manually copy/paste/edit all tasks to add required class prefix).

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I made a fix in Doctrine 1.2 that should help. Be sure you set the model loading to be pear style.

        $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);
        
        Show
        Jonathan H. Wage added a comment - I made a fix in Doctrine 1.2 that should help. Be sure you set the model loading to be pear style. $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);
        Hide
        Juozas Kaziukenas added a comment -

        It does fix some things, I will explain the problem in more detail:

        I have models like this (zf-style)

        $options = array(
        'pearStyle' => true,
        'generateTableClasses' => true,
        'classPrefix' => 'Model_',
        'baseClassPrefix' => 'Base_',
        'baseClassesDirectory' => null,
        'classPrefixFiles' => false,
        'generateAccessors' => false,
        );

        As you can see, models doesn't have a folder Model, they are just in folder models, so my result is:

        ./models
        ....Product.php --> Model_Product
        ....Base
        ........Product.php --> Model_Base_Product

        Hence the prefix cannot be determined from folder name as it can be anything I want.

        Possible fix: take into account prefix (define as a property?) or use reflection.

        Show
        Juozas Kaziukenas added a comment - It does fix some things, I will explain the problem in more detail: I have models like this (zf-style) $options = array( 'pearStyle' => true, 'generateTableClasses' => true, 'classPrefix' => 'Model_', 'baseClassPrefix' => 'Base_', 'baseClassesDirectory' => null, 'classPrefixFiles' => false, 'generateAccessors' => false, ); As you can see, models doesn't have a folder Model, they are just in folder models, so my result is: ./models ....Product.php --> Model_Product ....Base ........Product.php --> Model_Base_Product Hence the prefix cannot be determined from folder name as it can be anything I want. Possible fix: take into account prefix (define as a property?) or use reflection.
        Hide
        Jonathan H. Wage added a comment -

        You need to have 'classPrefixFiles' => true. With pearStyle it is required that the name of your class represent the path to the class on disk. So if you change classPrefixFiles to true everything will be fine and work the way it is supposed to. The prefix option for loadModels is not recommended.

        Show
        Jonathan H. Wage added a comment - You need to have 'classPrefixFiles' => true. With pearStyle it is required that the name of your class represent the path to the class on disk. So if you change classPrefixFiles to true everything will be fine and work the way it is supposed to. The prefix option for loadModels is not recommended.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Juozas Kaziukenas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: