我的symfony2路由上的前缀需要一个变量,以便我可以在主路由文件中执行以下操作:
//app/config/routing.yml
god:
resource: "@Acme/DemoBundle/Resources/config/routing.yml"
prefix: /god/{religion}
Run Code Online (Sandbox Code Playgroud)
然后在捆绑路由文件中这样的事情:
gods_route_to_heaven:
path: /path_to_heaven
defaults: { _controller: AcmeBlogBundle:God:show }
Run Code Online (Sandbox Code Playgroud)
这样我就可以访问这样的路径了:
/god/Christianity/path_to_heaven
/god/Islam/path_to_heaven
/god/Hinduism/path_to_heaven
Run Code Online (Sandbox Code Playgroud)
等等.
如果我app/console route:debug | grep api
在控制台上键入,我会得到正确的路由/god/{religion}/path_to_heaven
,因此正确生成路由.
但是当我尝试通过将它作为输入放在动作函数中来获取控制器中的参数时,如下所示:
public function showAction($religion)
Run Code Online (Sandbox Code Playgroud)
路径被破坏并转储路径我看到它重复: /god/{religion}/path_to_heaven/{religion}
那么我如何从控制器内部获取$ religion变量?
我花了几个小时尝试在iOS 8上使用自定义字体作为导航栏标题.这在iOS 7上运行正常:
UIFont *font = [UIFont fontWithName:@"Gotham-Bold" size:12];
NSDictionary *textAttributes = @{ NSFontAttributeName: font };
self.navigationController.navigationBar.titleTextAttributes = textAttributes;
Run Code Online (Sandbox Code Playgroud)
但在iOS 8上,文本消失了.更改颜色或系统字体大小可以很好地工作,但尝试使用自定义字体根本不起作用.有人对此有任何想法吗?
谢谢!
编辑
我创建了一个小项目,你可以自己试试:https: //github.com/noquepoaqui/customHeaderFont
这些代码行位于第30行的MasterViewController上.
有没有一种简单的方法可以使用Symfony上的FOSOAuthServerBundle在控制器上获取当前客户端?
我在客户端实体上有一些属性,想在控制器中读取它们,但是我找不到获取当前客户端的方法。
我只找到了获取当前用户($this->container->get('security.context')->getToken()->getUser();
)的方法,但没有找到当前客户端的方法。
编辑:我现在已经找到了获取客户端的方法,但是它没有向我显示我添加到我的客户端实体的属性的值。如下代码:
$token = $this->container->get('security.context')->getToken()->getToken();
$accessToken = $this->container->get('fos_oauth_server.access_token_manager.default')->findTokenBy(array('token' => $token));
$client = $accessToken->getClient();
\Doctrine\Common\Util\Debug::dump($client);
Run Code Online (Sandbox Code Playgroud)
正在倾销:
object(stdClass)[1180]
public '__CLASS__' => string 'CC\APIBundle\Entity\Client' (length=26)
public '__IS_PROXY__' => boolean true
public '__PROXY_INITIALIZED__' => boolean false
public 'id' => int 6
public 'name' => null
public 'city' => null
public 'randomId' => null
public 'secret' => null
public 'redirectUris' =>
array (size=0)
empty
public 'allowedGrantTypes' => null
Run Code Online (Sandbox Code Playgroud)
所以我的客户在db上的名称和城市没有显示...我也认为有很多对db的调用可以用非常优雅的方式避免...
有任何想法吗?