Created
June 20, 2017 16:11
-
-
Save labboy0276/8a42f23ac450fc6d9e07246e959fff69 to your computer and use it in GitHub Desktop.
Taxonomy Entity Patch Drupal 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/modules/taxonomy/src/Controller/TaxonomyController.php b/core/modules/taxonomy/src/Controller/TaxonomyController.php | |
index 843cdd7..d55dc50 100644 | |
--- a/core/modules/taxonomy/src/Controller/TaxonomyController.php | |
+++ b/core/modules/taxonomy/src/Controller/TaxonomyController.php | |
@@ -20,6 +20,9 @@ class TaxonomyController extends ControllerBase { | |
* | |
* @return array | |
* The taxonomy term add form. | |
+ * | |
+ * @deprecated in 8.2.x, will be removed in 9.x. Use | |
+ * '_entity_form: taxonomy_term.add' in route declarations instead. | |
*/ | |
public function addForm(VocabularyInterface $taxonomy_vocabulary) { | |
$term = $this->entityManager()->getStorage('taxonomy_term')->create(array('vid' => $taxonomy_vocabulary->id())); | |
diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php | |
index 2e41e2d..1e405bc 100644 | |
--- a/core/modules/taxonomy/src/Entity/Term.php | |
+++ b/core/modules/taxonomy/src/Entity/Term.php | |
@@ -23,10 +23,15 @@ | |
* "access" = "Drupal\taxonomy\TermAccessControlHandler", | |
* "views_data" = "Drupal\taxonomy\TermViewsData", | |
* "form" = { | |
+ * "add" = "Drupal\taxonomy\TermForm", | |
+ * "edit" = "Drupal\taxonomy\TermForm", | |
* "default" = "Drupal\taxonomy\TermForm", | |
* "delete" = "Drupal\taxonomy\Form\TermDeleteForm" | |
* }, | |
- * "translation" = "Drupal\taxonomy\TermTranslationHandler" | |
+ * "translation" = "Drupal\taxonomy\TermTranslationHandler", | |
+ * "route_provider" = { | |
+ * "html" = "Drupal\taxonomy\Entity\TermHtmlRouteProvider", | |
+ * }, | |
* }, | |
* base_table = "taxonomy_term_data", | |
* data_table = "taxonomy_term_field_data", | |
@@ -43,6 +48,7 @@ | |
* field_ui_base_route = "entity.taxonomy_vocabulary.overview_form", | |
* common_reference_target = TRUE, | |
* links = { | |
+ * "add-form" = "/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/add", | |
* "canonical" = "/taxonomy/term/{taxonomy_term}", | |
* "delete-form" = "/taxonomy/term/{taxonomy_term}/delete", | |
* "edit-form" = "/taxonomy/term/{taxonomy_term}/edit", | |
diff --git a/core/modules/taxonomy/src/Entity/TermHtmlRouteProvider.php b/core/modules/taxonomy/src/Entity/TermHtmlRouteProvider.php | |
new file mode 100644 | |
index 0000000..afb4fb8 | |
--- /dev/null | |
+++ b/core/modules/taxonomy/src/Entity/TermHtmlRouteProvider.php | |
@@ -0,0 +1,37 @@ | |
+<?php | |
+ | |
+namespace Drupal\taxonomy\Entity; | |
+ | |
+use Drupal\Core\Entity\EntityTypeInterface; | |
+use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; | |
+ | |
+/** | |
+ * Provides HTML routes for block contents. | |
+ */ | |
+class TermHtmlRouteProvider extends AdminHtmlRouteProvider { | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ protected function getAddFormRoute(EntityTypeInterface $entity_type) { | |
+ if ($route = parent::getAddFormRoute($entity_type)) { | |
+ $defaults = $route->getDefaults(); | |
+ unset($defaults['_title_callback']); | |
+ $defaults['_title'] = 'Add term'; | |
+ return $route->setDefaults($defaults); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ protected function getEditFormRoute(EntityTypeInterface $entity_type) { | |
+ if ($route = parent::getEditFormRoute($entity_type)) { | |
+ $defaults = $route->getDefaults(); | |
+ unset($defaults['_title_callback']); | |
+ $defaults['_title'] = 'Edit term'; | |
+ return $route->setDefaults($defaults); | |
+ } | |
+ } | |
+ | |
+} | |
diff --git a/core/modules/taxonomy/taxonomy.routing.yml b/core/modules/taxonomy/taxonomy.routing.yml | |
index 8a3bd1a..9377d92 100644 | |
--- a/core/modules/taxonomy/taxonomy.routing.yml | |
+++ b/core/modules/taxonomy/taxonomy.routing.yml | |
@@ -6,36 +6,6 @@ entity.taxonomy_vocabulary.collection: | |
requirements: | |
_permission: 'administer taxonomy' | |
-entity.taxonomy_term.add_form: | |
- path: '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/add' | |
- defaults: | |
- _controller: '\Drupal\taxonomy\Controller\TaxonomyController::addForm' | |
- _title: 'Add term' | |
- requirements: | |
- _entity_create_access: 'taxonomy_term:{taxonomy_vocabulary}' | |
- | |
-entity.taxonomy_term.edit_form: | |
- path: '/taxonomy/term/{taxonomy_term}/edit' | |
- defaults: | |
- _entity_form: 'taxonomy_term.default' | |
- _title: 'Edit term' | |
- options: | |
- _admin_route: TRUE | |
- requirements: | |
- _entity_access: 'taxonomy_term.update' | |
- taxonomy_term: \d+ | |
- | |
-entity.taxonomy_term.delete_form: | |
- path: '/taxonomy/term/{taxonomy_term}/delete' | |
- defaults: | |
- _entity_form: 'taxonomy_term.delete' | |
- _title: 'Delete term' | |
- options: | |
- _admin_route: TRUE | |
- requirements: | |
- _entity_access: 'taxonomy_term.delete' | |
- taxonomy_term: \d+ | |
- | |
entity.taxonomy_vocabulary.add_form: | |
path: '/admin/structure/taxonomy/add' | |
defaults: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment