Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Remove BasePeer::CLASS_DEFAULT constant. #291

Merged
merged 2 commits into from Mar 5, 2012

Conversation

Projects
None yet
2 participants
Member

fzaninotto commented Feb 13, 2012

This constant, generated by PHP5PeerBuilder::addConstantsAndAttribute(), is no longer in use
now that autoloading works for models. Besides, it creates problems (see #183) and complexity
in the code. Removing it is painless - all the tests are green.

Remove BasePeer::CLASS_DEFAULT constant.
This constant, generated by `PHP5PeerBuilder::addConstantsAndAttribute()`, is no longer in use
now that autoloading works for models. Besides, it creates problems (see #183) and complexity
in the code. Removing it is painless - all the tests are green.
Member

fzaninotto commented Feb 13, 2012

Ah, it seems sfPropelORMPlugin uses it (and there are lots of error messages reported on the Internet regarding this).

> ack CLASS_DEFAULT
lib/addon/sfPropelData.class.php
200:          $this->object_references[Propel::importClass(constant(constant($class.'::PEER').'::CLASS_DEFAULT')).'_'.$key] = $obj;

lib/generator/sfPropelFormFilterGenerator.class.php
87:      $packages = explode('.', constant(constant($table->getClassname().'::PEER').'::CLASS_DEFAULT'));
91:        throw new InvalidArgumentException(sprintf('Unable to find the model dir name (%s) in the package %s.', $this->params['model_dir_name'], constant(constant($table->getClassname().'::PEER').'::CLASS_DEFAULT')));

lib/generator/sfPropelFormGenerator.class.php
90:      $packages = explode('.', constant(constant($table->getClassname().'::PEER').'::CLASS_DEFAULT'));
94:        throw new InvalidArgumentException(sprintf('Unable to find the model dir name (%s) in the package %s.', $this->params['model_dir_name'], constant(constant($table->getClassname().'::PEER').'::CLASS_DEFAULT')));

Is it really necessary?

Member

fzaninotto commented Feb 13, 2012

I confirm, the sfPropelORMPlugin could work without this constant by using reflection (ReflectionClass::getFileName()).

Owner

willdurand commented Feb 13, 2012

So, we need to modify the plugin?

Member

fzaninotto commented Feb 13, 2012

yep

Owner

willdurand commented Mar 3, 2012

It seems you missed something:

generator/lib/builder/om/PHP5PeerBuilder.php
1238:                                  \$omClass = self::CLASS_DEFAULT;
Owner

willdurand commented Mar 3, 2012

Ok so, the constant is no more used in other projects, but you missed a line to remove.

Member

fzaninotto commented Mar 5, 2012

@willdurand Fixed, thanks.

willdurand added a commit that referenced this pull request Mar 5, 2012

Merge pull request #291 from fzaninotto/remove_class_default
Remove BasePeer::CLASS_DEFAULT constant.

@willdurand willdurand merged commit 2923a3b into propelorm:master Mar 5, 2012

Owner

willdurand commented Mar 5, 2012

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment