original_string: public function getFieldLayout(array $fieldLayoutDef): FieldLayout
      {
          $layoutFields = [];
          $requiredFields = [];
  
          if (array_key_exists('tabs', $fieldLayoutDef)) {
              foreach ($fieldLayoutDef['tabs'] as $tabName => $tabDef) {
                  $layoutTabFields = $this->getPrepareFieldLayout($tabDef);
                  $requiredFields = array_merge($requiredFields, $layoutTabFields['required']);
                  $layoutFields[$tabName] = $layoutTabFields['fields'];
              }
          } elseif (array_key_exists('fields', $fieldLayoutDef)) {
              $layoutTabFields = $this->getPrepareFieldLayout($fieldLayoutDef);
              $requiredFields = $layoutTabFields['required'];
              $layoutFields = $layoutTabFields['fields'];
          }
  
          $fieldLayout = Craft::$app->fields->assembleLayout($layoutFields, $requiredFields);
  
          if (array_key_exists('type', $fieldLayoutDef)) {
              $fieldLayout->type = $fieldLayoutDef['type'];
          } else {
              $fieldLayout->type = Entry::class;
          }
  
          return $fieldLayout;
      }
code: public function getFieldLayout(array $fieldLayoutDef): FieldLayout
      {
          $layoutFields = [];
          $requiredFields = [];
  
          if (array_key_exists('tabs', $fieldLayoutDef)) {
              foreach ($fieldLayoutDef['tabs'] as $tabName => $tabDef) {
                  $layoutTabFields = $this->getPrepareFieldLayout($tabDef);
                  $requiredFields = array_merge($requiredFields, $layoutTabFields['required']);
                  $layoutFields[$tabName] = $layoutTabFields['fields'];
              }
          } elseif (array_key_exists('fields', $fieldLayoutDef)) {
              $layoutTabFields = $this->getPrepareFieldLayout($fieldLayoutDef);
              $requiredFields = $layoutTabFields['required'];
              $layoutFields = $layoutTabFields['fields'];
          }
  
          $fieldLayout = Craft::$app->fields->assembleLayout($layoutFields, $requiredFields);
  
          if (array_key_exists('type', $fieldLayoutDef)) {
              $fieldLayout->type = $fieldLayoutDef['type'];
          } else {
              $fieldLayout->type = Entry::class;
          }
  
          return $fieldLayout;
      }
code_tokens: public function getFieldLayout ( array $ fieldLayoutDef ) : FieldLayout { $ layoutFields = [ ] ; $ requiredFields = [ ] ; if ( array_key_exists ( 'tabs' , $ fieldLayoutDef ) ) { foreach ( $ fieldLayoutDef [ 'tabs' ] as $ tabName => $ tabDef ) { $ layoutTabFields = $ this -> getPrepareFieldLayout ( $ tabDef ) ; $ requiredFields = array_merge ( $ requiredFields , $ layoutTabFields [ 'required' ] ) ; $ layoutFields [ $ tabName ] = $ layoutTabFields [ 'fields' ] ; } } elseif ( array_key_exists ( 'fields' , $ fieldLayoutDef ) ) { $ layoutTabFields = $ this -> getPrepareFieldLayout ( $ fieldLayoutDef ) ; $ requiredFields = $ layoutTabFields [ 'required' ] ; $ layoutFields = $ layoutTabFields [ 'fields' ] ; } $ fieldLayout = Craft :: $ app -> fields -> assembleLayout ( $ layoutFields , $ requiredFields ) ; if ( array_key_exists ( 'type' , $ fieldLayoutDef ) ) { $ fieldLayout -> type = $ fieldLayoutDef [ 'type' ] ; } else { $ fieldLayout -> type = Entry :: class ; } return $ fieldLayout ; }
docstring: Attempt to import a field layout.
  
  @param array $fieldLayoutDef
  
  @return FieldLayout
docstring_tokens: Attempt to import a field layout .