Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » How does one delete a previous created ModelAdmin class?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 768 Views
  • sergieboy
    Avatar
    Community Member
    33 Posts

    How does one delete a previous created ModelAdmin class? Link to this post

    I'v created a ProductModelAdmin, to manage two dataobjects with one-to-many relationship.
    After some experimenting, I want to delete (destroy, vanish) the ProductModelAdmin.php file.
    I delete it in my code. SS begins to flip and admin won't start up anymore.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    Once you delete your code you will need to run a site.com/dev/build?flush=1 to remove it from your database and then reload the admin.

  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    Wish it was that simple.
    Doesn't work. Each time it blocks, I copy mysite data, remove the installation
    and reinstall (just 2 mins of work , no big deal, but yet impractical). So I can work along.
    I have a screenshot of the error. How to upload this ?

    I experiment alot with SS , and in particular the management of the DataObject.
    I hope to use SS within 2 months for my employer (big governemental department)
    My future clients (the managers of several subdepartments) will use the backend
    to manipulate the data in the datamodel. But I want this backend to be as
    simple and evident as possible. Matching my complex datamodel
    on the possiblilities of the DOM and ComplexTableField in order to get
    the max result is not that evident. It implies a lot of experiment.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    I have a screenshot of the error. How to upload this ?

    It looks like uploads have been turned off in this forum, upload the image via skitch, twitpic or one of the other photosharing sites if you wish. Or just copy the content of the error message.

  • Corry
    Avatar
    Community Member
    17 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    I had the same issue. I was doing lots of experimentation with a Test Model admin which I wanted to delete since I've built the real thing. All the other temporary classes have been removed just fine but after removing the Test Model class, but dev/build was producing errors (see below).

    Adding the ?flush=1 to the end of the build URL seemed to resolve it for me, although we've been told we don't need to do that anymore! (Before I tried that, my temporary fix was to comment out everything inside the model admin class and make in an empty class that does nothing.)

    Warning: include_once(/.../mysite/code/TestModelAdmin.php) [function.include-once]: failed to open stream: No such file or directory in /.../sapphire/core/Core.php on line 213

    Warning: include_once() [function.include]: Failed opening '/home/.../mysite/code/TestModelAdmin.php' for inclusion (include_path='/.../sapphire:/.../sapphire/parsers:/.../sapphire/thirdparty:.:/usr/local/lib/php/PEAR:/usr/lib/php:/usr/local/lib/php') in /.../sapphire/core/Core.php on line 213

    Fatal error: Uncaught exception 'ReflectionException' with message 'Class TestModelAdmin does not exist' in /.../cms/code/CMSMenu.php:285 Stack trace: #0 /.../cms/code/CMSMenu.php(285): ReflectionClass->__construct('TestModelAdmin') #1 /.../cms/code/CMSMenu.php(41): CMSMenu::get_cms_classes() #2 /…/cms/_config.php(17): CMSMenu::add_director_rules() #3 /tmp/…/manifest-main(8548): require_once('/home/.../...') #4 /.../sapphire/core/ManifestBuilder.php(74): require_once('/tmp/silverstri...') #5 /.../sapphire/core/Core.php(232): ManifestBuilder::include_manifest() #6 /.../sapphire/main.php(61): require_once('/home/.../...') #7 {main} thrown in /.../cms/code/CMSMenu.php on line 285

  • martimiz
    Avatar
    Forum Moderator
    1078 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    @Corry:

    Adding the ?flush=1 to the end of the build URL seemed to resolve it for me, although we've been told we don't need to do that anymore!

    Just wondering where it says that you shouldn't do that anymore? In some cases you'll get away with it, like when you only add some database fields to existing code, but I think that flushing the cache is definitely the way to go after adding/removing codefiles... Luckily you can always do it afterwards

  • Corry
    Avatar
    Community Member
    17 Posts

    Re: How does one delete a previous created ModelAdmin class? Link to this post

    OK, thanks for that.

    Have just seen it written in lots of places that 'dev/build' only is needed for later versions of SilverStripe, so didn't realise there are times when flush should still be used.

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