【问题标题】:Phalcon\Mvc\View\Simple::render() in mailer causing WSOD邮件程序中的 Phalcon\Mvc\View\Simple::render() 导致 WSOD
【发布时间】:2015-04-13 23:40:43
【问题描述】:

我有一个简单的控制器操作,它创建一个Guest 记录并呈现一个模板。

// First bind the form to our Guest:
$form->bind( $_POST, $guest );

// Validate and save, or show error messages
if( $form->isValid($_POST, $guest) ) {
    if( $guest->save($_POST) ) {
        $this->view->setMainView( 'confirm' );
    }
}

在我添加任何邮件程序之前,这可以正常工作。但是,当我在 Guest 模型中添加一个恰好呈现模板的事件处理程序时,控制器会呈现死亡白屏而不是我的确认模板。

Guest 模型中:

public function afterCreate() {
    return GuestMailer::sendEmailConfirmation( $this );
}

GuestMailer类中:

public static function sendEmailConfirmation( $guest ) {
    // create/configure $email message

    $view = $guest->getDI()->get('simpleView');
    $view->render(                 // Works without this call...
        'confirmation_email',
        array( 'guest' => $guest )
    );
    $content = $view->getContent();
    $email->content( $content );

    return $email->send();
}

请注意,当我删除上述对render() 的调用时,确认模板已成功呈现。

我认为 Phalcon 中的组件应该是高度解耦的?为什么渲染完全不同的模板会导致我的控制器视图混乱?我怎样才能避免这种情况?

【问题讨论】:

    标签: phalcon


    【解决方案1】:

    我认为这个问题是由模板服务的特殊配置引起的,在正常的工作流程中它不会导致问题,当您需要“手动”呈现模板时会出现问题,您可以参考这个 PhalconPHP 论坛讨论链接,特别是链接锚引用的答案: http://forum.phalconphp.com/discussion/109/manually-render-separate-file-template-#C12015

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 2021-03-22
      • 2015-03-13
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多