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.

General Questions

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

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

Reflection Error...a solution


Reply

6 Posts   950 Views

Avatar
biapar

26 December 2009 at 11:55pm Forum Moderator, 435 Posts

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

27 December 2009 at 4:06pm Community Member, 97 Posts

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 [url=http://doc.silverstripe.org/doku.php?id=manifestbuilder]the manifest builder documentation[/url]:

"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

27 December 2009 at 10:37pm Forum Moderator, 435 Posts

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

28 December 2009 at 4:20pm Community Member, 97 Posts

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

28 December 2009 at 10:17pm Forum Moderator, 435 Posts

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

Avatar
biapar

30 December 2009 at 6:34am Forum Moderator, 435 Posts

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...