Пример #1
0
 /**
  * Create a list of fields types used in regular, template and virtual fields.
  *
  * @param array   $contenttype
  * @param Content $content
  * @param array   $has
  *
  * @return array
  */
 private function getUsedFieldtypes(array $contenttype, Content $content, array $has)
 {
     $fieldtypes = ['meta' => true];
     foreach ([$contenttype['fields'], $content->get('templatefields')->contenttype['fields'] ?: []] as $fields) {
         foreach ($fields as $field) {
             $fieldtypes[$field['type']] = true;
         }
     }
     if ($has['relations'] || $has['incoming_relations']) {
         $fieldtypes['relationship'] = true;
     }
     if ($has['taxonomy'] || is_array($contenttype['groups']) && in_array('taxonomy', $contenttype['groups'])) {
         $fieldtypes['taxonomy'] = true;
     }
     if ($has['templatefields'] || is_array($contenttype['groups']) && in_array('template', $contenttype['groups'])) {
         $fieldtypes['template'] = true;
     }
     return array_keys($fieldtypes);
 }