@@ -21,33 +21,46 @@ public function convertRequest()
2121 {
2222 $ this ->fields = [];
2323
24- if ($ this ->config ->getAllowedFields ($ this ->contentType )) {
25- $ allowedFields = $ this ->config ->getAllowedFields ($ this ->contentType );
24+ if (! isset ($ this ->contentType )) {
25+ $ allContentTypes = array_keys ($ this ->config ->getContentTypes ());
26+ foreach ($ allContentTypes as $ contentType ) {
27+ $ this ->getFieldsForContentType ($ contentType );
28+ }
2629 } else {
27- $ allowedFields = array_keys ($ this ->getAllFieldNames () );
30+ $ this -> getFieldsForContentType ($ this ->contentType );
2831 }
2932
30- if (isset ($ this ->values [$ this ->contentType ])) {
31- $ values = explode (', ' , $ this ->values [$ this ->contentType ]);
33+ return $ this ;
34+ }
35+
36+ protected function getFieldsForContentType ($ contentType )
37+ {
38+ if ($ this ->config ->getAllowedFields ($ contentType )) {
39+ $ allowedFields = $ this ->config ->getAllowedFields ($ contentType );
40+ } else {
41+ $ allowedFields = array_keys ($ this ->getAllFieldNames ($ contentType ));
42+ }
43+
44+ if (isset ($ this ->values [$ contentType ])) {
45+ $ values = explode (', ' , $ this ->values [$ contentType ]);
3246 foreach ($ values as $ v ) {
3347 if (in_array ($ v , $ allowedFields )) {
34- $ this ->fields [] = $ v ;
48+ $ this ->fields [$ contentType ] = $ v ;
3549 }
3650 }
3751 }
3852
3953 // Default on the default/fallback fields defined in the config.
40- if (empty ($ this ->fields )) {
41- $ this ->fields = $ allowedFields ;
42- if ($ this ->config ->getListFields ($ this -> contentType )) {
43- $ this ->fields = $ this ->config ->getListFields (( $ this -> contentType ) );
54+ if (empty ($ this ->fields [ $ contentType ] )) {
55+ $ this ->fields [ $ contentType ] = $ allowedFields ;
56+ if ($ this ->config ->getListFields ($ contentType )) {
57+ $ this ->fields [ $ contentType ] = $ this ->config ->getListFields ($ contentType );
4458 // todo: do we need to filter these through 'allowed-fields'?
4559 }
4660 }
47-
48- return $ this ;
4961 }
5062
63+
5164 public function findConfigValues ()
5265 {
5366 }
@@ -63,9 +76,13 @@ public function getParameter()
6376 /**
6477 * @return array
6578 */
66- public function getFields ()
79+ public function getFields ($ contentType = null )
6780 {
68- return $ this ->fields ;
81+ if (! $ contentType ) {
82+ return $ this ->fields [$ this ->contentType ];
83+ }
84+
85+ return $ this ->fields [$ contentType ];
6986 }
7087
7188 /**
0 commit comments