Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Reflection Error...a solution


Go to End


6 Posts   1275 Views

Avatar
biapar

Forum Moderator, 435 Posts

26 December 2009 at 11:55pm

Hi,

Today I had a reflection error.
All class are ok and until yesterday, I don't have any type of error.

I create a new Page B class into mysite with a class B1 that extend Image class.
Into Product Class, I just have a class with another name B2 that extend Image class.

In Admin panel when I upload image file, I have everytime reflection error that B2 class don't exist ( when I was on Page B ) or B1 don't exist ( when I was on Product ).

I resolved putting B1 and B2 into main Page class that extend SiteTree.

Bye

Avatar
tobych

Community Member, 97 Posts

27 December 2009 at 4:06pm

What exactly do you mean by "new Page B class ... with a class B1?" Do you mean that Page B has a B1 as in a one-to-one database relationship?

How all this will work for you will depend on the actual names of your classes. You need to do a ?flush=1 once you've added your classes, of course. You also need to make sure the autoloader, with the help of the manifest builder, is going to find your classes. I'm no expert on exactly what will and won't be found, but note this from the manifest builder documentation:

"If your class contains an underscore, for example, Page_Controller, then the filename is expected to be the stuff before the underscore. In this case, Page.php.''

Toby

Avatar
biapar

Forum Moderator, 435 Posts

27 December 2009 at 10:37pm

Hi, Tobych,

thank you for your reply.
With Page B class , I mean class SpecialDataPage extends Page and into the same file I specified B1 class extend Image and B2 class was putted before Product Class into the same php file.

All works before I created SpecialDataPage.

Do you think the problem was class name ( class Resize_Image extends Image & class Banner_Image extends Image )?

PS: I flush everytime at each update...

Avatar
tobych

Community Member, 97 Posts

28 December 2009 at 4:20pm

Yes, I think you should try moving B1 and B2 out into their own files (B1.php and B2.php).

Classes in MyFile.php should be just MyFile and MyFile_*.

And regarding your resolution:

"If you don't know why it works it probably doesn't -- you just don't know it yet"
- Steve McConnell, "Code Complete"

Toby

Avatar
biapar

Forum Moderator, 435 Posts

28 December 2009 at 10:17pm

I think that I rename "class Resize_Image extends Image & class Banner_Image extends Image" to ResizeImage and BannerImage...

Avatar
biapar

Forum Moderator, 435 Posts

30 December 2009 at 6:34am

I had resolved with your tip ...

class Product_ResizeImage extends Image into product.php file

and

class SpecialDataPage_BannerImage extends Image into SpecialDataPage.php file.

Thanks...