小编Car*_*dos的帖子

类别树的路由

我正在使用Tree doctrine扩展来获取类别树,并且希望拥有以下路由:

/cat/subcat1/subcat2/subcat3
Run Code Online (Sandbox Code Playgroud)

我可以这样定义路线

/{cat}
/{cat}/{subcat}
/{cat}/{subcat}/{subcat2)
etc...
Run Code Online (Sandbox Code Playgroud)

但有没有更优雅和一般的方式来实现这一点?一个可以接受无限数量级别的系统?

php doctrine url-routing symfony

3
推荐指数
1
解决办法
1613
查看次数

如何使用Symfony中的FosUserBundle将用户管理器作为服务访问?

所以通常我可以通过执行以下操作来访问控制器中的用户管理器:

$this->get('fos_user.user_manager');
Run Code Online (Sandbox Code Playgroud)

但是我需要在服务中访问它.所以这就是我做的:

在我的config.yml文件中:

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Main\UserBundle\Entity\User



services:
    userbundle_service:
        class:        Main\UserBundle\Controller\UserBundleService
        arguments: [@fos_user]
Run Code Online (Sandbox Code Playgroud)

在我的UserBundleService.php中:"

<?php
namespace Main\UserBundle\Controller;

use FOS\UserBundle\Entity\User;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Bridge\Monolog\Logger;



class UserBundleService
{

     protected $securityContext;

    public function __construct(User $user)
    {
        $this->user = $user;
    }


    public function validateRequest(){    
   $userManager = $this->container->get('fos_user.user_manager');
  $this ->logger->warn("user is : ".$userManager);
  exit;

    }

}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

ServiceNotFoundException: The service "userbundle_service" has a dependency on a non-existent service "fos_user".
Run Code Online (Sandbox Code Playgroud)

所以我接下来要做的是将fos_user作为服务移到config.yml中:

services:
    userbundle_service:
        class:        Main\UserBundle\Controller\UserBundleService
        arguments: [@fos_user2]

    fos_user2:
        user_class: Main\UserBundle\Entity\User
Run Code Online (Sandbox Code Playgroud)

我收到错误:

RuntimeException: …
Run Code Online (Sandbox Code Playgroud)

php symfony fosuserbundle

2
推荐指数
1
解决办法
1万
查看次数

symfony2的肥皂网服务

我需要使用symfony2创建一个web服务我已经阅读了官方文章http://symfony.com/doc/current/cookbook/web_services/php_soap_extension.html ,在示例中它使用参数路由.wsdl文件创建了一个SoapServer 实例,这是什么文件?我没有在symfony中找到太多关于soap的文档.请帮帮忙吗?

public function indexAction()
{
    $server = new \SoapServer('/path/to/hello.wsdl');
    $server->setObject($this->get('hello_service'));

    $response = new Response();
    $response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');

    ob_start();
    $server->handle();
    $response->setContent(ob_get_clean());

    return $response;
}
Run Code Online (Sandbox Code Playgroud)

soap web-services soapserver symfony

1
推荐指数
1
解决办法
6157
查看次数

如何动态调用树枝过滤器

我需要使用特定于每种数据类型的过滤器呈现未知类型的数据:

渲染的结构看起来像:

array(
    "value"  => "value-to-render",
    "filter" => "filter-to-apply",
)

{% for item in items %}
    {{ item.value|item.filter|raw}}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:如何使用item.filter作为值的过滤器?

symfony twig

1
推荐指数
1
解决办法
4703
查看次数

getsymphony.com - 关于这个网站是什么?

我对http://getsymphony.comhttp://symfony.com/网站感到困惑.我正在寻找可以开始学习Symfony框架的地方,我不知道http://getsymphony.com网站是否有任何对Symfony框架的引用,或者这对于未知CMS来说只是一个棘手的名称.有人可以解释一下吗?

symfony

0
推荐指数
1
解决办法
208
查看次数