X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Fsrc%2FCommand%2FDrupal_8%2FModule%2FContentEntity.php;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Fsrc%2FCommand%2FDrupal_8%2FModule%2FContentEntity.php;h=eea0580730e61be2713382da1b10a2d4dac35906;hp=8e54ca29d605f0aed9563ea496563f8e314dd67e;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Module/ContentEntity.php b/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Module/ContentEntity.php index 8e54ca29d..eea058073 100644 --- a/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Module/ContentEntity.php +++ b/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Module/ContentEntity.php @@ -45,6 +45,7 @@ class ContentEntity extends BaseGenerator { $questions['fieldable'] = new ConfirmationQuestion('Make the entity type fieldable?', TRUE); $questions['revisionable'] = new ConfirmationQuestion('Make the entity type revisionable?', FALSE); $questions['translatable'] = new ConfirmationQuestion('Make the entity type translatable?', FALSE); + $questions['bundle'] = new ConfirmationQuestion('The entity type has bundle?', FALSE); $questions['template'] = new ConfirmationQuestion('Create entity template?', TRUE); $questions['access_controller'] = new ConfirmationQuestion('Create CRUD permissions?', FALSE); $questions['title_base_field'] = new ConfirmationQuestion('Add "title" base field?', TRUE); @@ -65,9 +66,12 @@ class ContentEntity extends BaseGenerator { $vars['entity_base_path'] = '/' . $vars['entity_base_path']; } - if ($vars['fieldable']) { + if (($vars['fieldable_no_bundle'] = $vars['fieldable'] && !$vars['bundle'])) { $vars['configure'] = 'entity.' . $vars['entity_type_id'] . '.settings'; } + elseif ($vars['bundle']) { + $vars['configure'] = 'entity.' . $vars['entity_type_id'] . '_type.collection'; + } $vars['class_prefix'] = Utils::camelize($vars['entity_type_label']); @@ -77,14 +81,14 @@ class ContentEntity extends BaseGenerator { 'model.links.menu.yml.twig', 'model.links.task.yml.twig', 'model.permissions.yml.twig', - 'model.routing.yml.twig', 'src/Entity/Example.php.twig', 'src/ExampleInterface.php.twig', 'src/ExampleListBuilder.php.twig', 'src/Form/ExampleForm.php.twig', ]; - if ($vars['fieldable']) { + if ($vars['fieldable_no_bundle']) { + $templates[] = 'model.routing.yml.twig'; $templates[] = 'src/Form/ExampleSettingsForm.php.twig'; } @@ -104,6 +108,14 @@ class ContentEntity extends BaseGenerator { $templates[] = 'config/optional/rest.resource.entity.example.yml.twig'; } + if ($vars['bundle']) { + $templates[] = 'config/optional/views.view.example.yml.twig'; + $templates[] = 'config/schema/model.entity_type.schema.yml.twig'; + $templates[] = 'src/ExampleTypeListBuilder.php.twig'; + $templates[] = 'src/Entity/ExampleType.php.twig'; + $templates[] = 'src/Form/ExampleTypeForm.php.twig'; + } + $templates_path = 'd8/module/content-entity/'; $vars['template_name'] = str_replace('_', '-', $vars['entity_type_id']) . '.html.twig'; @@ -113,12 +125,14 @@ class ContentEntity extends BaseGenerator { 'model', 'Example', 'rest.resource.entity.example', + 'views.view.example', ]; $path_replacements = [ $vars['template_name'], $vars['machine_name'], $vars['class_prefix'], 'rest.resource.entity.' . $vars['entity_type_id'], + 'views.view.' . $vars['entity_type_id'], ]; foreach ($templates as $template) {