Jump to:

22976 Posts in 11493 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Reflection Error...a solution

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

Page: 1
Go to End
Author Topic: 882 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Reflection Error...a solution Link to this post

    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

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Reflection Error...a solution Link to this post

    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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Reflection Error...a solution Link to this post

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

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Reflection Error...a solution Link to this post

    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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Reflection Error...a solution Link to this post

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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Reflection Error...a solution Link to this post

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

    882 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.