Doctrine 1
  1. Doctrine 1
  2. DC-95

support PEAR file/class naming conventions when generating model classes with a base class

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-ALPHA3
    • Component/s: None
    • Labels:
      None

      Description

      Currently its not possible to generate base classes that are compatible with the PEAR file/class naming conventions
      user -> user.php
      base_user -> base/user.php

      The following settings do not give the desired results
               baseClassPrefix: "base_"
              baseClassesDirectory: "base"

      This seems like a very surprising, yet critical omission, which forces a symfony style autoloader instead of the Doctrine native autoloader.

        Activity

        Hide
        Andreas Möller added a comment -

        I got it to work using the following options

        baseClassPrefix = "Base_"
        baseClassesDirectory =
        baseClassName = "Default_Model_Base_Abstract"
        classPrefix = "Default_Model_"
        classPrefixFiles = FALSE
        pearStyle = TRUE

        However, I have not been able to generate tables from the models generated.

        Show
        Andreas Möller added a comment - I got it to work using the following options baseClassPrefix = "Base_" baseClassesDirectory = baseClassName = "Default_Model_Base_Abstract" classPrefix = "Default_Model_" classPrefixFiles = FALSE pearStyle = TRUE However, I have not been able to generate tables from the models generated.
        Hide
        Jonathan H. Wage added a comment -

        Are you using the generateTableClasses = TRUE option?

        Show
        Jonathan H. Wage added a comment - Are you using the generateTableClasses = TRUE option?
        Hide
        Jonathan H. Wage added a comment -

        Oh sorry, you said "generate tables from the models generated"....Misunderstood, that you meant Table classes. You are using the zend autoloader right?

        Show
        Jonathan H. Wage added a comment - Oh sorry, you said "generate tables from the models generated"....Misunderstood, that you meant Table classes. You are using the zend autoloader right?
        Hide
        Andreas Möller added a comment -

        Yes, I'm using the Zend autoloader. Or, at least this is what I would like to do, generate model classes that are prefixed by

        Default_Model_

        and keep working with the models as I have been prior to attempting to use the options

        classPrefix = "Default_Model_"
        pearStyle = TRUE
        

        At first, I made an attempt with

        generateTableClasses = FALSE

        but then, switched to

        generateTableClasses = TRUE

        and then I just turned off the file not found warnings using

        Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(TRUE);

        although this can't be the cure, I believe.

        However, tables were not generated, only after extending

        Doctrine_Export

        and adjusting

        public function exportSchema($directory = null)
            {
                $classPrefix = 'Default_Model_';
                if ($directory !== null) {
                    $models = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($directory, NULL, $classPrefix));
                } else {
                    $models = Doctrine_Core::getLoadedModels();
                }
        
                $this->exportClasses($models);
            }
        

        but this resulted in translation (I18n) tables generated as such

        content
        default__model__content__translation
        Show
        Andreas Möller added a comment - Yes, I'm using the Zend autoloader. Or, at least this is what I would like to do, generate model classes that are prefixed by Default_Model_ and keep working with the models as I have been prior to attempting to use the options classPrefix = "Default_Model_" pearStyle = TRUE At first, I made an attempt with generateTableClasses = FALSE but then, switched to generateTableClasses = TRUE and then I just turned off the file not found warnings using Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(TRUE); although this can't be the cure, I believe. However, tables were not generated, only after extending Doctrine_Export and adjusting public function exportSchema($directory = null) { $classPrefix = 'Default_Model_'; if ($directory !== null) { $models = Doctrine_Core::filterInvalidModels(Doctrine_Core::loadModels($directory, NULL, $classPrefix)); } else { $models = Doctrine_Core::getLoadedModels(); } $this->exportClasses($models); } but this resulted in translation (I18n) tables generated as such content default__model__content__translation
        Hide
        Jonathan H. Wage added a comment -

        The prefix won't allow you to work with things like you did before, without the prefix The prefix is only for generation. You must still type the full name everywhere in your code. Make sure you are doing the following too:

        $manager = Doctrine_Manager::getInstance();
        $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);
        
        Doctrine_Core::setModelsDirectory('models');
        
        Show
        Jonathan H. Wage added a comment - The prefix won't allow you to work with things like you did before, without the prefix The prefix is only for generation. You must still type the full name everywhere in your code. Make sure you are doing the following too: $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR); Doctrine_Core::setModelsDirectory('models');

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Lukas Kahwe
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: