/** * Tests that term data is exposed on term page. */ protected function doTermRdfaTests() { // Feed the HTML into the parser. $graph = $this->getRdfGraph($this->term->urlInfo()); // Term type. $this->assertEqual($graph->type($this->termUri), 'schema:Thing', "Term type was found (schema:Thing) on term page."); // Term name. $expected_value = array('type' => 'literal', 'value' => $this->term->getName(), 'lang' => 'en'); $this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "Term name was found (schema:name) on term page."); // @todo Add test for term description once it is a field: // https://www.drupal.org/node/569434. }
/** * Generate a menu link plugin definition for a taxonomy term. * * @param \Drupal\taxonomy\TermInterface $term * The taxonomy term for which to build a menu link render array. * @param $base_plugin_definition * The base plugin definition to merge the link with. * * @return array */ protected function buildMenuDefinition(TermInterface $term, $base_plugin_definition) { $term_id = $term->id(); $term_url = $term->urlInfo(); $taxonomy_menu_id = $this->id(); $menu_id = $this->getMenu(); // Determine parent link. // TODO: Evaluate use case of multiple parents (should we make many menu items?) $menu_parent_id = NULL; /** @var $termStorage \Drupal\taxonomy\TermStorageInterface */ $termStorage = $this->entityManager()->getStorage('taxonomy_term'); $parents = $termStorage->loadParents($term_id); $parents = array_values($parents); if (is_array($parents) && count($parents) && !is_null($parents[0]) && $parents[0] != '0') { $menu_parent_id = $this->buildMenuPluginId($parents[0]); } // TODO: Consider implementing a forced weight based on taxonomy tree. // Generate link. $arguments = ['taxonomy_term' => $term_id]; $link = $base_plugin_definition; $link += array('id' => $this->buildMenuPluginId($term), 'title' => $term->label(), 'description' => $term->getDescription(), 'menu_name' => $menu_id, 'metadata' => array('taxonomy_menu_id' => $taxonomy_menu_id, 'taxonomy_term_id' => $term_id), 'route_name' => $term_url->getRouteName(), 'route_parameters' => $term_url->getRouteParameters(), 'load arguments' => $arguments, 'parent' => $menu_parent_id, 'provider' => 'taxonomy_menu', 'class' => 'Drupal\\taxonomy_menu\\Plugin\\Menu\\TaxonomyMenuMenuLink'); return $link; }