public NodeListBuilder::buildRow(EntityInterface $entity)
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- core/modules/node/src/NodeListBuilder.php, line 99
Class
- NodeListBuilder
- Defines a class to build a listing of node entities.
Namespace
Drupal\node
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function buildRow(EntityInterface $entity ) { /** @var \Drupal\node\NodeInterface $entity */ $mark = array ( '#theme' => 'mark' , '#mark_type' => node_mark( $entity ->id(), $entity ->getChangedTime()), ); $langcode = $entity ->language()->getId(); $uri = $entity ->urlInfo(); $options = $uri ->getOptions(); $options += ( $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset( $languages [ $langcode ]) ? array ( 'language' => $languages [ $langcode ]) : array ()); $uri ->setOptions( $options ); $row [ 'title' ][ 'data' ] = array ( '#type' => 'link' , '#title' => $entity ->label(), '#suffix' => ' ' . drupal_render( $mark ), '#url' => $uri , ); $row [ 'type' ] = node_get_type_label( $entity ); $row [ 'author' ][ 'data' ] = array ( '#theme' => 'username' , '#account' => $entity ->getOwner(), ); $row [ 'status' ] = $entity ->isPublished() ? $this ->t( 'published' ) : $this ->t( 'not published' ); $row [ 'changed' ] = $this ->dateFormatter->format( $entity ->getChangedTime(), 'short' ); $language_manager = \Drupal::languageManager(); if ( $language_manager ->isMultilingual()) { $row [ 'language_name' ] = $language_manager ->getLanguageName( $langcode ); } $row [ 'operations' ][ 'data' ] = $this ->buildOperations( $entity ); return $row + parent::buildRow( $entity ); } |
Please login to continue.