Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Class 'SilverStripe\UserForms\Model\Page' not found in silverstripe\userforms\code\Model\UserDefinedForm.php on line 11 #825

Closed
torleif opened this issue Oct 29, 2018 · 3 comments

Comments

@torleif
Copy link
Contributor

torleif commented Oct 29, 2018

If you have your page class name spaced, the userforms module won't be able to pick up on it and will return an error.

it probably should rely on SiteTree, or use some extension magic to allow the user to specify the page type using a yml file.

@robbieaverill
Copy link
Contributor

Hi @torleif, SilverStripe 4 doesn't support namespacing of Page at this time. You can follow more on this topic here: silverstripe/silverstripe-framework#5844

We'd welcome decoupling from Page in this module if you'd like to submit a pull request, but I'm going to close for now. Thanks for raising the issue though =)

@NightJar
Copy link
Contributor

For reference here @torleif the work here is mostly done (abstracting this module from Page) - in order to circumvent your problem for now I see two solutions:

  1. class_alias your namespaced Page class. Similar to how SS3 does for Object to be PHP 7.2 compatible
  2. Make a PR to exit early if (!class_exists('Page'))

You can create a custom userform class simply by applying the traist, as is what happens with the problematic class in discussion:

class UserDefinedForm extends Page
{
use UserForm;

@torleif
Copy link
Contributor Author

torleif commented Oct 30, 2018

thanks @robbieaverill and @NightJar , I used the bootstrap alias as described in issue. My bootstrap.php autoloader looks like the following:

require('app/src/Page.php');


use OP\PageController as NamespacedPageController;
use OP\Page as NamespacedPage;

class Page extends NamespacedPage
{
    private static $hide_ancestor = NamespacedPage::class;
    private static $table_name = 'SilverStripe_Page';
}

class PageController extends NamespacedPageController
{
}

which allows the module to pick up on the Page class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants