Loading src/LinkGeneratorInterface.php +19 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,23 @@ use Drupal\Component\Plugin\PluginInspectionInterface; interface LinkGeneratorInterface extends PluginInspectionInterface { /** * Get metadata about the entities that the link generator is providing. * * @return array * An array of information about the link generator. */ public function getInfo(); /** * Get a non-executed query for entities of a specific bundle type. * * @param string $bundle * The bundle to query for. * * @return \Drupal\Core\Database\Query\SelectInterface * A query ready for execution. */ public function getQuery($bundle); } src/Plugin/LinkGenerator/Menu.php +13 −10 Original line number Diff line number Diff line Loading @@ -23,15 +23,8 @@ class Menu extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('menu_tree', 'm') ->fields('m', array('mlid', 'route_name', 'route_parameters', 'options')) ->condition('menu_name', $bundle) ->condition('enabled', 1) ->condition('route_name', '', '!='); $info = array( function getInfo() { return array( 'field_info' => array( 'entity_id' => 'mlid', 'route_name' => 'route_name', Loading @@ -40,6 +33,16 @@ class Menu extends LinkGeneratorBase { ), 'path_info' => array() ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('menu_tree', 'm') ->fields('m', array('mlid', 'route_name', 'route_parameters', 'options')) ->condition('menu_name', $bundle) ->condition('enabled', 1) ->condition('route_name', '', '!='); } } src/Plugin/LinkGenerator/NodeType.php +13 −9 Original line number Diff line number Diff line Loading @@ -23,14 +23,8 @@ class NodeType extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('node_field_data', 'n') ->fields('n', array('nid', 'changed')) ->condition('type', $bundle) ->condition('status', 1); $info = array( public function getInfo() { return array( 'field_info' => array( 'entity_id' => 'nid', 'lastmod' => 'changed', Loading @@ -40,6 +34,16 @@ class NodeType extends LinkGeneratorBase { 'entity_type' => 'node', ) ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('node_field_data', 'n') ->fields('n', array('nid', 'changed')) ->condition('type', $bundle) ->condition('status', 1); } } src/Plugin/LinkGenerator/TaxonomyVocabulary.php +12 −8 Original line number Diff line number Diff line Loading @@ -23,13 +23,8 @@ class TaxonomyVocabulary extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('taxonomy_term_field_data', 't') ->fields('t', array('tid', 'changed')) ->condition('vid', $bundle); $info = array( public function getInfo() { return array( 'field_info' => array( 'entity_id' => 'tid', 'lastmod' => 'changed', Loading @@ -39,6 +34,15 @@ class TaxonomyVocabulary extends LinkGeneratorBase { 'entity_type' => 'taxonomy_term', ) ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('taxonomy_term_field_data', 't') ->fields('t', array('tid', 'changed')) ->condition('vid', $bundle); } } src/Plugin/LinkGenerator/User.php +14 −9 Original line number Diff line number Diff line Loading @@ -24,13 +24,8 @@ class User extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('users_field_data', 'u') ->fields('u', array('uid', 'changed')) ->condition('status', 1); $info = array( public function getInfo() { array( 'field_info' => array( 'entity_id' => 'uid', 'lastmod' => 'changed', Loading @@ -38,7 +33,17 @@ class User extends LinkGeneratorBase { 'path_info' => array( 'route_name' => 'entity.user.canonical', 'entity_type' => 'user', )); return array('query' => $query, 'info' => $info); ) ); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('users_field_data', 'u') ->fields('u', array('uid', 'changed')) ->condition('status', 1); } } Loading
src/LinkGeneratorInterface.php +19 −0 Original line number Diff line number Diff line Loading @@ -14,4 +14,23 @@ use Drupal\Component\Plugin\PluginInspectionInterface; interface LinkGeneratorInterface extends PluginInspectionInterface { /** * Get metadata about the entities that the link generator is providing. * * @return array * An array of information about the link generator. */ public function getInfo(); /** * Get a non-executed query for entities of a specific bundle type. * * @param string $bundle * The bundle to query for. * * @return \Drupal\Core\Database\Query\SelectInterface * A query ready for execution. */ public function getQuery($bundle); }
src/Plugin/LinkGenerator/Menu.php +13 −10 Original line number Diff line number Diff line Loading @@ -23,15 +23,8 @@ class Menu extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('menu_tree', 'm') ->fields('m', array('mlid', 'route_name', 'route_parameters', 'options')) ->condition('menu_name', $bundle) ->condition('enabled', 1) ->condition('route_name', '', '!='); $info = array( function getInfo() { return array( 'field_info' => array( 'entity_id' => 'mlid', 'route_name' => 'route_name', Loading @@ -40,6 +33,16 @@ class Menu extends LinkGeneratorBase { ), 'path_info' => array() ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('menu_tree', 'm') ->fields('m', array('mlid', 'route_name', 'route_parameters', 'options')) ->condition('menu_name', $bundle) ->condition('enabled', 1) ->condition('route_name', '', '!='); } }
src/Plugin/LinkGenerator/NodeType.php +13 −9 Original line number Diff line number Diff line Loading @@ -23,14 +23,8 @@ class NodeType extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('node_field_data', 'n') ->fields('n', array('nid', 'changed')) ->condition('type', $bundle) ->condition('status', 1); $info = array( public function getInfo() { return array( 'field_info' => array( 'entity_id' => 'nid', 'lastmod' => 'changed', Loading @@ -40,6 +34,16 @@ class NodeType extends LinkGeneratorBase { 'entity_type' => 'node', ) ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('node_field_data', 'n') ->fields('n', array('nid', 'changed')) ->condition('type', $bundle) ->condition('status', 1); } }
src/Plugin/LinkGenerator/TaxonomyVocabulary.php +12 −8 Original line number Diff line number Diff line Loading @@ -23,13 +23,8 @@ class TaxonomyVocabulary extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('taxonomy_term_field_data', 't') ->fields('t', array('tid', 'changed')) ->condition('vid', $bundle); $info = array( public function getInfo() { return array( 'field_info' => array( 'entity_id' => 'tid', 'lastmod' => 'changed', Loading @@ -39,6 +34,15 @@ class TaxonomyVocabulary extends LinkGeneratorBase { 'entity_type' => 'taxonomy_term', ) ); return array('query' => $query, 'info' => $info); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('taxonomy_term_field_data', 't') ->fields('t', array('tid', 'changed')) ->condition('vid', $bundle); } }
src/Plugin/LinkGenerator/User.php +14 −9 Original line number Diff line number Diff line Loading @@ -24,13 +24,8 @@ class User extends LinkGeneratorBase { /** * {@inheritdoc} */ function get_entities_of_bundle($bundle) { $query = \Drupal::database()->select('users_field_data', 'u') ->fields('u', array('uid', 'changed')) ->condition('status', 1); $info = array( public function getInfo() { array( 'field_info' => array( 'entity_id' => 'uid', 'lastmod' => 'changed', Loading @@ -38,7 +33,17 @@ class User extends LinkGeneratorBase { 'path_info' => array( 'route_name' => 'entity.user.canonical', 'entity_type' => 'user', )); return array('query' => $query, 'info' => $info); ) ); } /** * {@inheritdoc} */ public function getQuery($bundle) { return \Drupal::database()->select('users_field_data', 'u') ->fields('u', array('uid', 'changed')) ->condition('status', 1); } }