Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Routing 出现Silverstripe路由,因为找不到页面_Routing_Silverstripe - Fatal编程技术网

Routing 出现Silverstripe路由,因为找不到页面

Routing 出现Silverstripe路由,因为找不到页面,routing,silverstripe,Routing,Silverstripe,我正在研究两条路线。其中一个有效,另一个无效。UserEducation\u控制器路由工作正常,但UserEmployment\u控制器工作不正常。这是我的密码: 这是my routes.yml文件的内容: --- Name: userroutes After: framework/routes#coreroutes --- Director: rules: 'user/education' : 'UserEducation_Controller', '

我正在研究两条路线。其中一个有效,另一个无效。
UserEducation\u控制器
路由工作正常,但
UserEmployment\u控制器
工作不正常。这是我的密码:

这是my routes.yml文件的内容:

---
Name: userroutes
After: framework/routes#coreroutes
---
Director:
    rules:
        'user/education' : 'UserEducation_Controller',
        'user/employment' : 'UserEmployment_Controller',
        'user' : 'User_Controller'

---
Name: jobroutes
After: framework/routes#coreroutes
---
Director:
   rules:
      'job' : 'JobPosting_Controller'
这是我的
UserEducation.php
文件:

class UserEducation_Controller extends Page_Controller {

    private static $allowed_actions = array(
        'add', 
        'edit' => '->isOwner', 
        'remove' => '->isOwner', 
        'UserEducationForm', 
        'doAdd'
    );

    private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');

    // INSERT NEW EDUCATION ENTRY
    public function index()
    {
        $backUrl = $this->request->getVar('BackURL');

        // If register success
        if( $this->request->getVar('success') == 1 )
        {
            // Form submission was successful so redirect to BackURL
            return $this->redirect( $backUrl );
        }

        return $this->renderWith(array('UserEducation', 'Page'));
    }
}
class UserEmployment_Controller extends Page_Controller {

    private static $allowed_actions = array(
        'add', 
        'edit' => '->isOwner', 
        'remove' => '->isOwner', 
        'UserEmploymentForm', 
        'doAdd'
    );

    private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');

    // INSERT NEW EMPLOYMENT ENTRY
    public function index()
    {
        Requirements::css('themes/simple/datetimepicker/jquery.datetimepicker.css');

        $backUrl = $this->request->getVar('BackURL');

        // If register success
        if( $this->request->getVar('success') == 1 )
        {
            // Form submission was successful so redirect to BackURL
            return $this->redirect( $backUrl );
        }

        return $this->renderWith(array('UserEmployment', 'Page'));
    }
}
这是我的
UserEmployment.php
文件:

class UserEducation_Controller extends Page_Controller {

    private static $allowed_actions = array(
        'add', 
        'edit' => '->isOwner', 
        'remove' => '->isOwner', 
        'UserEducationForm', 
        'doAdd'
    );

    private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');

    // INSERT NEW EDUCATION ENTRY
    public function index()
    {
        $backUrl = $this->request->getVar('BackURL');

        // If register success
        if( $this->request->getVar('success') == 1 )
        {
            // Form submission was successful so redirect to BackURL
            return $this->redirect( $backUrl );
        }

        return $this->renderWith(array('UserEducation', 'Page'));
    }
}
class UserEmployment_Controller extends Page_Controller {

    private static $allowed_actions = array(
        'add', 
        'edit' => '->isOwner', 
        'remove' => '->isOwner', 
        'UserEmploymentForm', 
        'doAdd'
    );

    private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');

    // INSERT NEW EMPLOYMENT ENTRY
    public function index()
    {
        Requirements::css('themes/simple/datetimepicker/jquery.datetimepicker.css');

        $backUrl = $this->request->getVar('BackURL');

        // If register success
        if( $this->request->getVar('success') == 1 )
        {
            // Form submission was successful so redirect to BackURL
            return $this->redirect( $backUrl );
        }

        return $this->renderWith(array('UserEmployment', 'Page'));
    }
}
我试着改变路线的位置,这样就业优先,然后什么都没有改变。结果是一样的(教育有效,就业无效)。 我在工作中创建了一个公共函数
init()
方法,并在其中执行了一个
die()
语句,但该语句甚至没有命中,所以我猜它甚至没有命中控制器

有什么想法吗


谢谢。

我甚至尝试将useremployment替换为user/employment,以查看是否是嵌套导致了问题,但当我导航到mysite.com/useremployment/add时,它仍然无法工作。我对usereducation也做了同样的事情,但它仍然运作良好。。进行了刷新和dev/build。您可以直接使用其名称调用控制器。那么对mysite.com/UserEmployment\u Controller的调用至少能起作用吗?我注意到yml配置的缩进有4个空格,通常只需要2个空格,调用控制器不起作用。但是UserU控制器工作正常。。奇怪。。为什么它不能识别我的控制器?我做了一个类\u exists('UserEmployment\u Controller'),它返回true。。。所以它知道它在那里,但它不在那里。。它必须与控制器相同(可能没有控制器后缀)。否则SilverStripe的自动加载器找不到它。尝试在yml中重新排序项目,我看到了奇怪的结果