Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/aggregator/src/FeedViewBuilder.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\aggregator; | 3 namespace Drupal\aggregator; |
4 | 4 |
5 use Drupal\Core\Entity\EntityManagerInterface; | 5 use Drupal\Core\Entity\EntityDisplayRepositoryInterface; |
6 use Drupal\Core\Entity\EntityRepositoryInterface; | |
6 use Drupal\Core\Entity\EntityTypeInterface; | 7 use Drupal\Core\Entity\EntityTypeInterface; |
8 use Drupal\Core\Entity\EntityTypeManagerInterface; | |
7 use Drupal\Core\Entity\EntityViewBuilder; | 9 use Drupal\Core\Entity\EntityViewBuilder; |
8 use Drupal\Core\Config\Config; | 10 use Drupal\Core\Config\Config; |
9 use Drupal\Core\Language\LanguageManagerInterface; | 11 use Drupal\Core\Language\LanguageManagerInterface; |
12 use Drupal\Core\Theme\Registry; | |
10 use Drupal\Core\Url; | 13 use Drupal\Core\Url; |
11 use Symfony\Component\DependencyInjection\ContainerInterface; | 14 use Symfony\Component\DependencyInjection\ContainerInterface; |
12 | 15 |
13 /** | 16 /** |
14 * View builder handler for aggregator feeds. | 17 * View builder handler for aggregator feeds. |
15 */ | 18 */ |
16 class FeedViewBuilder extends EntityViewBuilder { | 19 class FeedViewBuilder extends EntityViewBuilder { |
17 | 20 |
18 /** | 21 /** |
22 * The 'aggregator.settings' config. | |
23 * | |
24 * @var \Drupal\Core\Config\Config | |
25 */ | |
26 protected $config; | |
27 | |
28 /** | |
29 * The entity type manager. | |
30 * | |
31 * @var \Drupal\Core\Entity\EntityTypeManagerInterface | |
32 */ | |
33 protected $entityTypeManager; | |
34 | |
35 /** | |
19 * Constructs a new FeedViewBuilder. | 36 * Constructs a new FeedViewBuilder. |
20 * | 37 * |
21 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type | 38 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type |
22 * The entity type definition. | 39 * The entity type definition. |
23 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager | 40 * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository |
24 * The entity manager service. | 41 * The entity repository service. |
25 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager | 42 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager |
26 * The language manager. | 43 * The language manager. |
27 * @param \Drupal\Core\Config\Config $config | 44 * @param \Drupal\Core\Config\Config $config |
28 * The 'aggregator.settings' config. | 45 * The 'aggregator.settings' config. |
46 * @param \Drupal\Core\Theme\Registry $theme_registry | |
47 * The theme registry. | |
48 * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository | |
49 * The entity display repository. | |
50 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager | |
51 * The entity type manager. | |
29 */ | 52 */ |
30 public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, Config $config) { | 53 public function __construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Config $config, Registry $theme_registry, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeManagerInterface $entity_type_manager) { |
31 parent::__construct($entity_type, $entity_manager, $language_manager); | 54 parent::__construct($entity_type, $entity_repository, $language_manager, $theme_registry, $entity_display_repository); |
32 $this->config = $config; | 55 $this->config = $config; |
56 $this->entityTypeManager = $entity_type_manager; | |
33 } | 57 } |
34 | 58 |
35 /** | 59 /** |
36 * {@inheritdoc} | 60 * {@inheritdoc} |
37 */ | 61 */ |
38 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { | 62 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { |
39 return new static( | 63 return new static( |
40 $entity_type, | 64 $entity_type, |
41 $container->get('entity.manager'), | 65 $container->get('entity.repository'), |
42 $container->get('language_manager'), | 66 $container->get('language_manager'), |
43 $container->get('config.factory')->get('aggregator.settings') | 67 $container->get('config.factory')->get('aggregator.settings'), |
68 $container->get('theme.registry'), | |
69 $container->get('entity_display.repository'), | |
70 $container->get('entity_type.manager') | |
44 ); | 71 ); |
45 } | 72 } |
46 | 73 |
47 /** | 74 /** |
48 * {@inheritdoc} | 75 * {@inheritdoc} |
56 | 83 |
57 if ($display->getComponent('items')) { | 84 if ($display->getComponent('items')) { |
58 // When in summary view mode, respect the list_max setting. | 85 // When in summary view mode, respect the list_max setting. |
59 $limit = $view_mode == 'summary' ? $this->config->get('source.list_max') : 20; | 86 $limit = $view_mode == 'summary' ? $this->config->get('source.list_max') : 20; |
60 // Retrieve the items attached to this feed. | 87 // Retrieve the items attached to this feed. |
61 $items = $this->entityManager | 88 $items = $this->entityTypeManager |
62 ->getStorage('aggregator_item') | 89 ->getStorage('aggregator_item') |
63 ->loadByFeed($entity->id(), $limit); | 90 ->loadByFeed($entity->id(), $limit); |
64 | 91 |
65 $build[$id]['items'] = $this->entityManager | 92 $build[$id]['items'] = $this->entityTypeManager |
66 ->getViewBuilder('aggregator_item') | 93 ->getViewBuilder('aggregator_item') |
67 ->viewMultiple($items, $view_mode, $entity->language()->getId()); | 94 ->viewMultiple($items, $view_mode, $entity->language()->getId()); |
68 | 95 |
69 if ($view_mode == 'full') { | 96 if ($view_mode == 'full') { |
70 // Also add the pager. | 97 // Also add the pager. |