urlGenerator = $url_generator; } /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('url_generator'), $container->get('string_translation') ); } /** * {@inheritdoc} */ public function buildHeader() { $header['label'] = $this->t('Style name'); return $header + parent::buildHeader(); } /** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { $row['label'] = $entity->label(); return $row + parent::buildRow($entity); } /** * {@inheritdoc} */ public function getDefaultOperations(EntityInterface $entity) { $flush = array( 'title' => t('Flush'), 'weight' => 200, 'url' => $entity->urlInfo('flush-form'), ); return parent::getDefaultOperations($entity) + array( 'flush' => $flush, ); } /** * {@inheritdoc} */ public function render() { $build = parent::render(); $build['#empty'] = $this->t('There are currently no styles. Add a new one.', array( ':url' => $this->urlGenerator->generateFromRoute('image.style_add'), )); return $build; } }