本文整理汇总了PHP中Pimple\Container::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::path方法的具体用法?PHP Container::path怎么用?PHP Container::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple\Container
的用法示例。
在下文中一共展示了Container::path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(Container $container)
{
$container['cms.get_post_url_attributes'] = $container->protect(function (Post $post) {
return ['date' => $post->getCreated()->format('Y/m/d'), 'slug' => $post->getSlug()];
});
$container['cms'] = function () use($container) {
$cms = new CMS($container['em']);
$postCmsEntity = new CMSEntity(Post::class, PostType::class);
$postCmsEntity->addColumn('title', function (Post $post) use($container) {
$href = $container->path('post', $container['cms.get_post_url_attributes']($post));
return '<a href="' . $href . '">' . $post->getTitle() . '</a>';
});
$postCmsEntity->addColumn('slug', 'slug');
$cms->addCMSEntity($postCmsEntity);
$pageCmsEntity = new CMSEntity(Page::class, PageType::class);
$pageCmsEntity->addColumn('title', 'title');
$pageCmsEntity->addColumn('slug', 'slug');
$cms->addCMSEntity($pageCmsEntity);
$menuCMSEntity = new CMSEntity(Menu::class, MenuType::class);
$menuCMSEntity->addColumn('name', 'name');
$cms->addCMSEntity($menuCMSEntity);
$categoryCmsEntity = new CMSEntity(Category::class, CategoryType::class);
$categoryCmsEntity->addColumn('Name', 'name');
$cms->addCMSEntity($categoryCmsEntity);
return $cms;
};
}