0

任何人都可以将我链接到一些 Symfony 资源,它们很难找到。我在理解如何正确使用它时遇到了一些麻烦。就像 CodeIgniter 使用安全助手一样,您可以这样做加载它:

$this->load->helper('security');

你会使用它的功能,你会做这样的事情:

$data = $this->input->xss_clean($data);

但是使用 Smyfony 将某人重定向到 404 页面,您需要使用 sfAction 类和 redirect404() api。那么任何人都可以解释或链接我一个很好的教程吗?

4

2 回答 2

0

http://www.symfony-project.org/book/1_2/06-Inside-the-Controller-Layer#chapter_06_sub_skipping_to_another_action (scroll down a few paragraphs)

Using

http://www.symfony-project.org/api/1_4/sfAction

You have access to a number of 404 redirection methods (redirect404, forward404, forward404If, forward404Unless) which are detailed on the link above. You have access to all of these methods from within your actions:

public function executeAction(sfWebRequest $request)
{
  $this->forward404();
}

I would recommend using forward404 instead of redirect404 as the latter will push the redirection back to the browser and show your user the 404 page's URL instead of the URL they attempted to access.

Configuring

You can configure the module and action that should be executed when a 404 is triggered in your application's config/settings.yml like this:

all:
  .actions:
    error_404_module:       my_module   # To be called when a 404 error is raised
    error_404_action:       my_action   # Or when the requested URL doesn't match any route

Update:

For general information on Symfony check out the three books they have available online: http://www.symfony-project.org/doc/1_4/, 'Practical Symfony' being a great place to get started. There is also a complete API reference available: http://www.symfony-project.org/api/1_4/.

于 2010-02-19T04:03:04.460 回答
0

我强烈建议你留出几个小时通读Practical Symfony教程。它贯穿了从项目开始到结束的所有基础知识。

Symfony 虽然是一个很棒的框架,但学习曲线却很陡峭。本教程确实可以帮助您了解它的工作原理,从基础到更高级的东西。

于 2010-02-18T17:20:28.647 回答