1
我目前使用FOSCommentBundle獲得REST API的最佳實踐的Symfony:私人服務 - 利用休息-API
在這個包的樣品例如有使用分揀機(或排序)服務使用不同的選項提供更改選項,與日遞增和日期倒序排序,但這個服務不是由「頁碼」或「日期」範圍排序提供商陣列(排序類服務中)在奧得河頁面的方式這
重用注入
parameters:
# The sorting factory class
cms_content.sorting_factory.class: CMS\Bundle\ContentBundle\Sorting\SortingFactory
# Provide to sort by date
cms_content.sorter.date.class: CMS\Bundle\ContentBundle\Sorting\DateSorting
# Provide to sort by page number
cms_content.sorter.page_nb.class: CMS\Bundle\ContentBundle\Sorting\PageNbSorting
#
sorter_sevices_aliases:
- 'cms_content.sorter.page_nb_desc'
- 'cms_content.sorter.page_nb_asc'
- 'cms_content.sorter.date_desc'
- 'cms_content.sorter.date_asc'
services:
# sort by page nb asc
cms_content.sorter.page_nb_asc:
class: '%cms_content.sorter.page_nb.class%'
public: false
tags:
- { name: cms_content.sorter, alias: page_nb_asc }
arguments: [ASC]
# sort by page nb dsc
cms_content.sorter.page_nb_desc:
class: '%cms_content.sorter.page_nb.class%'
public: false
tags:
- { name: cms_content.sorter, alias: page_nb_desc }
arguments: [DESC]
# sort by date asc
cms_content.sorter.date_asc:
class: '%cms_content.sorter.date.class%'
public: false
tags:
- { name: cms_content.sorter, alias: date_asc }
arguments: [ASC]
# sort by date desc
cms_content.sorter.date_desc:
class: '%cms_content.sorter.date.class%'
public: false
tags:
- { name: cms_content.sorter, alias: date_desc }
arguments: [DESC]
# the sorting factory (may be construct with empty array)
cms_content.sorting_factory:
class: '%cms_content.sorting_factory.class%'
arguments: ['%sorter_sevices_aliases%', '%cms_content.sorting_factory.default_sorter%']
我哈哈已經有些麻煩使用聲明爲private服務分揀工廠內儘可能選機供應商的陣列