Loading reader.api.php +15 −2 Changes for reader.api.php: 15 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Url; /** * Returns channels * Returns channels. * * @see \Drupal\reader\ReaderInterface::getChannels() * Loading @@ -18,6 +18,19 @@ function hook_reader_channels() { return []; } /** * Returns a sources page. * * @see \Drupal\reader\ReaderInterface::getSourcesPage() * * @param $op * * @return array */ function hook_reader_sources($op) { return []; } /** * Returns the timeline. * Loading Loading @@ -91,7 +104,7 @@ function hook_reader_post_actions($id, $item) { * @return void */ function hook_reader_do_post_action($action, $id, array $items) { // Do something // Do something. } /** Loading reader.module +13 −2 Changes for reader.module: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -54,6 +54,10 @@ function reader_theme() { 'template' => 'reader-channels-list', 'variables' => ['channels' => NULL], ], 'reader_sources_list' => [ 'template' => 'reader-sources-list', 'variables' => ['sources' => NULL], ], ]; } Loading @@ -61,7 +65,7 @@ function reader_theme() { * Implements hook_entity_type_alter(). */ function reader_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ if (isset($entity_types['node'])) { $entity_types['node']->setFormClass('reader-add', '\Drupal\reader\Form\ReaderNodeForm'); $entity_types['node']->setFormClass('reader-edit', '\Drupal\reader\Form\ReaderNodeForm'); Loading @@ -80,7 +84,7 @@ function reader_entity_type_alter(array &$entity_types) { function reader_form_node_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $form_state->getFormObject()->getEntity(); // TODO move the check, we always need to go in for the redirect // @todo move the check, we always need to go in for the redirect if ($entity && \Drupal::config('reader.settings')->get('alter_node_form')) { \Drupal::service('reader.form_alter')->alterNodeForm($form, $form_state, $entity); } Loading Loading @@ -185,3 +189,10 @@ function reader_reader_channels() { function reader_reader_timeline($id, $search = NULL) { return \Drupal::service('reader.reader')->getTimeline($id, $search); } /** * Implements hook_reader_sources(). */ function reader_reader_sources($op) { return \Drupal::service('reader.reader')->getSourcesPage($op); } reader.routing.yml +12 −0 Changes for reader.routing.yml: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -51,6 +51,18 @@ reader.search: requirements: _permission: 'access reader' reader.sources: path: '/reader/sources/{module}/{op}' options: _reader_theme: 'reader_theme' defaults: _controller: '\Drupal\reader\Controller\ReaderController::sources' _title: 'Manage sources' module: '_reader_sources_list_' op: 'list' requirements: _permission: 'access reader' reader.content: path: '/reader/content' options: Loading reader.services.yml +1 −1 Changes for reader.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ services: - { name: event_subscriber } reader.reader: class: Drupal\reader\Services\Reader arguments: ['@entity_type.manager', '@module_handler', '@date.formatter', '@pager.manager', '@request_stack', '@current_user'] arguments: ['@entity_type.manager', '@entity.form_builder', '@module_handler', '@date.formatter', '@pager.manager', '@request_stack', '@current_user'] reader.route_subscriber: class: Drupal\reader\Routing\ReaderRouteSubscriber arguments: ['@module_handler'] Loading src/Controller/ReaderController.php +62 −5 Changes for src/Controller/ReaderController.php: 62 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; /** * */ class ReaderController extends ControllerBase { /** Loading @@ -40,7 +43,7 @@ class ReaderController extends ControllerBase { protected $userData; /** * ReaderController constructor * ReaderController constructor. * * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * The date formatter. Loading @@ -65,6 +68,7 @@ class ReaderController extends ControllerBase { $container->get('user.data') ); } /** * Returns the manifest. * Loading Loading @@ -115,6 +119,56 @@ class ReaderController extends ControllerBase { return $build; } /** * Perform a sources action. * * @param $module * @param $op * * @return array */ public function sources($module, $op) { $build = []; if ($op == 'list' && $module == '_reader_sources_list_') { $sources = []; foreach ($this->moduleHandler()->getImplementations('reader_channels') as $module) { $function = $module . '_reader_channels'; if (function_exists($function)) { $data = $function(); if (!empty($data['channels'])) { $sources[] = Link::fromTextAndUrl($data['label'], Url::fromRoute('reader.sources', [ 'module' => strtr($module, '_', '-'), 'op' => 'list', ], ['attributes' => ['class' => ['column-link']]]))->toString(); } } } return [ '#theme' => 'reader_sources_list', '#sources' => $sources, '#title' => $this->t('Manage sources'), '#cache' => ['max-age' => 0], ]; } else { // Replace dashes with underscores. $module = strtr($module, '-', '_'); $function = $module . '_reader_sources'; if (function_exists($function)) { $build = $function($op); $build['#prefix'] = '<div class="reader-sources-container">'; $build['#suffix'] = '</div>'; $build['#cache']['max-age'] = 0; } } return $build; } /** * Returns the timeline. * Loading Loading @@ -287,7 +341,7 @@ class ReaderController extends ControllerBase { $content = $summary; } // Main audio & video // Main audio & video. if (!empty($item->audio)) { $audio = $item->audio[0]; } Loading Loading @@ -358,7 +412,7 @@ class ReaderController extends ControllerBase { $build['#attached']['drupalSettings']['reader']['readMoreHeight'] = $this->config('reader.settings')->get('read_more_height'); } // Infinite scroll // Infinite scroll. if ($this->config('reader.settings')->get('use_infinite_scroll')) { $build['#attached']['library'][] = 'reader_theme/infinite-scroll'; } Loading Loading @@ -439,7 +493,7 @@ class ReaderController extends ControllerBase { public function content() { $build = $rows = []; // Overwrite via ?content= // Overwrite via ?content=. if (!empty($_GET['content']) && in_array($_GET['content'], ['content', 'comment'])) { $_SESSION['reader_content_type'] = $_GET['content']; } Loading Loading @@ -474,7 +528,7 @@ class ReaderController extends ControllerBase { $rows[] = [ $entity->label(), $this->dateFormatter->format($entity->getCreatedTime(), 'custom', 'd/m/Y H:i'), Link::fromTextAndUrl($this->t('Edit'), Url::fromRoute('reader.' . $entity_type_id . '.edit', [$entity_type_id => $entity->id()], $options)) Link::fromTextAndUrl($this->t('Edit'), Url::fromRoute('reader.' . $entity_type_id . '.edit', [$entity_type_id => $entity->id()], $options)), ]; } Loading Loading @@ -626,12 +680,15 @@ class ReaderController extends ControllerBase { case 'reply': $label = $this->t('Reply'); break; case 'repost': $label = $this->t('Repost'); break; case 'bookmark': $label = $this->t('Bookmark'); break; case 'like': $label = $this->t('Like'); break; Loading Loading
reader.api.php +15 −2 Changes for reader.api.php: 15 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ use Drupal\Core\Url; /** * Returns channels * Returns channels. * * @see \Drupal\reader\ReaderInterface::getChannels() * Loading @@ -18,6 +18,19 @@ function hook_reader_channels() { return []; } /** * Returns a sources page. * * @see \Drupal\reader\ReaderInterface::getSourcesPage() * * @param $op * * @return array */ function hook_reader_sources($op) { return []; } /** * Returns the timeline. * Loading Loading @@ -91,7 +104,7 @@ function hook_reader_post_actions($id, $item) { * @return void */ function hook_reader_do_post_action($action, $id, array $items) { // Do something // Do something. } /** Loading
reader.module +13 −2 Changes for reader.module: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -54,6 +54,10 @@ function reader_theme() { 'template' => 'reader-channels-list', 'variables' => ['channels' => NULL], ], 'reader_sources_list' => [ 'template' => 'reader-sources-list', 'variables' => ['sources' => NULL], ], ]; } Loading @@ -61,7 +65,7 @@ function reader_theme() { * Implements hook_entity_type_alter(). */ function reader_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */ if (isset($entity_types['node'])) { $entity_types['node']->setFormClass('reader-add', '\Drupal\reader\Form\ReaderNodeForm'); $entity_types['node']->setFormClass('reader-edit', '\Drupal\reader\Form\ReaderNodeForm'); Loading @@ -80,7 +84,7 @@ function reader_entity_type_alter(array &$entity_types) { function reader_form_node_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $form_state->getFormObject()->getEntity(); // TODO move the check, we always need to go in for the redirect // @todo move the check, we always need to go in for the redirect if ($entity && \Drupal::config('reader.settings')->get('alter_node_form')) { \Drupal::service('reader.form_alter')->alterNodeForm($form, $form_state, $entity); } Loading Loading @@ -185,3 +189,10 @@ function reader_reader_channels() { function reader_reader_timeline($id, $search = NULL) { return \Drupal::service('reader.reader')->getTimeline($id, $search); } /** * Implements hook_reader_sources(). */ function reader_reader_sources($op) { return \Drupal::service('reader.reader')->getSourcesPage($op); }
reader.routing.yml +12 −0 Changes for reader.routing.yml: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -51,6 +51,18 @@ reader.search: requirements: _permission: 'access reader' reader.sources: path: '/reader/sources/{module}/{op}' options: _reader_theme: 'reader_theme' defaults: _controller: '\Drupal\reader\Controller\ReaderController::sources' _title: 'Manage sources' module: '_reader_sources_list_' op: 'list' requirements: _permission: 'access reader' reader.content: path: '/reader/content' options: Loading
reader.services.yml +1 −1 Changes for reader.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ services: - { name: event_subscriber } reader.reader: class: Drupal\reader\Services\Reader arguments: ['@entity_type.manager', '@module_handler', '@date.formatter', '@pager.manager', '@request_stack', '@current_user'] arguments: ['@entity_type.manager', '@entity.form_builder', '@module_handler', '@date.formatter', '@pager.manager', '@request_stack', '@current_user'] reader.route_subscriber: class: Drupal\reader\Routing\ReaderRouteSubscriber arguments: ['@module_handler'] Loading
src/Controller/ReaderController.php +62 −5 Changes for src/Controller/ReaderController.php: 62 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; /** * */ class ReaderController extends ControllerBase { /** Loading @@ -40,7 +43,7 @@ class ReaderController extends ControllerBase { protected $userData; /** * ReaderController constructor * ReaderController constructor. * * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * The date formatter. Loading @@ -65,6 +68,7 @@ class ReaderController extends ControllerBase { $container->get('user.data') ); } /** * Returns the manifest. * Loading Loading @@ -115,6 +119,56 @@ class ReaderController extends ControllerBase { return $build; } /** * Perform a sources action. * * @param $module * @param $op * * @return array */ public function sources($module, $op) { $build = []; if ($op == 'list' && $module == '_reader_sources_list_') { $sources = []; foreach ($this->moduleHandler()->getImplementations('reader_channels') as $module) { $function = $module . '_reader_channels'; if (function_exists($function)) { $data = $function(); if (!empty($data['channels'])) { $sources[] = Link::fromTextAndUrl($data['label'], Url::fromRoute('reader.sources', [ 'module' => strtr($module, '_', '-'), 'op' => 'list', ], ['attributes' => ['class' => ['column-link']]]))->toString(); } } } return [ '#theme' => 'reader_sources_list', '#sources' => $sources, '#title' => $this->t('Manage sources'), '#cache' => ['max-age' => 0], ]; } else { // Replace dashes with underscores. $module = strtr($module, '-', '_'); $function = $module . '_reader_sources'; if (function_exists($function)) { $build = $function($op); $build['#prefix'] = '<div class="reader-sources-container">'; $build['#suffix'] = '</div>'; $build['#cache']['max-age'] = 0; } } return $build; } /** * Returns the timeline. * Loading Loading @@ -287,7 +341,7 @@ class ReaderController extends ControllerBase { $content = $summary; } // Main audio & video // Main audio & video. if (!empty($item->audio)) { $audio = $item->audio[0]; } Loading Loading @@ -358,7 +412,7 @@ class ReaderController extends ControllerBase { $build['#attached']['drupalSettings']['reader']['readMoreHeight'] = $this->config('reader.settings')->get('read_more_height'); } // Infinite scroll // Infinite scroll. if ($this->config('reader.settings')->get('use_infinite_scroll')) { $build['#attached']['library'][] = 'reader_theme/infinite-scroll'; } Loading Loading @@ -439,7 +493,7 @@ class ReaderController extends ControllerBase { public function content() { $build = $rows = []; // Overwrite via ?content= // Overwrite via ?content=. if (!empty($_GET['content']) && in_array($_GET['content'], ['content', 'comment'])) { $_SESSION['reader_content_type'] = $_GET['content']; } Loading Loading @@ -474,7 +528,7 @@ class ReaderController extends ControllerBase { $rows[] = [ $entity->label(), $this->dateFormatter->format($entity->getCreatedTime(), 'custom', 'd/m/Y H:i'), Link::fromTextAndUrl($this->t('Edit'), Url::fromRoute('reader.' . $entity_type_id . '.edit', [$entity_type_id => $entity->id()], $options)) Link::fromTextAndUrl($this->t('Edit'), Url::fromRoute('reader.' . $entity_type_id . '.edit', [$entity_type_id => $entity->id()], $options)), ]; } Loading Loading @@ -626,12 +680,15 @@ class ReaderController extends ControllerBase { case 'reply': $label = $this->t('Reply'); break; case 'repost': $label = $this->t('Repost'); break; case 'bookmark': $label = $this->t('Bookmark'); break; case 'like': $label = $this->t('Like'); break; Loading