Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Model Must be abstract or implement method: getCollectionName #1

Closed
autoferrit opened this issue Nov 29, 2010 · 3 comments
Closed

Model Must be abstract or implement method: getCollectionName #1

autoferrit opened this issue Nov 29, 2010 · 3 comments

Comments

@autoferrit
Copy link

In my IDE, in my user class I get this following warning:

Class must be declared abstract or implement method 'getCollectionName'

Which refers to the

abstract protected function getCollectionName();

in EMongoRecord. This means that your model has to have a 'getCollectionName' method because the superclass (EMongoRecord) has it declared as abstract. Renaming 'getCollectionName' to collectionName fixes this error, as well as renaming collectionName to getCollectionName in my user model. This way they are both the same name and the user model subclass properly has its own copy of that method.

I could possibly be wrong on this, but the change and what the IDE makes sense to me and an abstract method is supposed to be used in a subclass that extends it.

@canni
Copy link
Owner

canni commented Nov 29, 2010

I do not understand You on this, You have to write (cover) getCollectionName() method for every of yours records, because in superclass i cannot know witch collection to use; see the first example in readme file

@autoferrit
Copy link
Author

That is what I mean. In the Readme, it says that In my User.php model I need collectionName() but my User.php model needs getCollectionName() because that is what the superclass has. This is because getCollectionName() it is abstract in EMongoRecord.

So, when i use getCollectionName() in my User.php model, i have no errors. This means that the readme should say to enter getCollectionName(), and not collectionName(). I would want to use getCollectionName() to use the getter method properly and not call collectionName() directly. I hope I explained this properly.

@canni
Copy link
Owner

canni commented Nov 29, 2010

oh my bad thx for clarification, it should stay as getCollectionName() because then you can just use $model->collectionName; as a read-only property, i'll fix readme, thx :)

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants