diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 5430a6b..30f7197 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -115,7 +115,7 @@ function aggregator_menu() { $items['admin/config/services/aggregator/add/opml'] = array( 'title' => 'Import OPML', 'type' => MENU_LOCAL_ACTION, - 'route_name' => 'add_opml', + 'route_name' => 'aggregator_opml_add', ); $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array( 'title' => 'Remove items', diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index 809b377..b3a903e 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -11,9 +11,9 @@ aggregator_feed_items_delete: requirements: _permission: 'administer news feeds' -add_opml: +aggregator_opml_add: pattern: '/admin/config/services/aggregator/add/opml' defaults: - _content: '\Drupal\aggregator\Form\FeedAddOpml' + _form: '\Drupal\aggregator\Form\OpmlFeedAdd' requirements: _permission: 'administer news feeds' diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php similarity index 61% rename from core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.php rename to core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index f43f928..67d7a49 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedAddOpml.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\aggregator\Form\FeedAddOpml. + * Contains \Drupal\aggregator\Form\OpmlFeedAdd. */ namespace Drupal\aggregator\Form; @@ -15,7 +15,7 @@ /** * Imports feeds from OPML. */ -class FeedAddOpml implements ControllerInterface, FormInterface { +class OpmlFeedAdd implements ControllerInterface, FormInterface { /** * Database service object. @@ -47,7 +47,7 @@ public function __construct(Connection $database) { * {@inheritdoc} */ public function getFormID() { - return 'add_opml'; + return 'aggregator_opml_add'; } /** @@ -58,46 +58,46 @@ public function buildForm(array $form, array &$form_state) { 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); $form['upload'] = array( - '#type' => 'file', - '#title' => t('OPML File'), - '#description' => t('Upload an OPML file containing a list of feeds to be imported.'), - ); + '#type' => 'file', + '#title' => t('OPML File'), + '#description' => t('Upload an OPML file containing a list of feeds to be imported.'), + ); $form['remote'] = array( - '#type' => 'url', - '#title' => t('OPML Remote URL'), - '#maxlength' => 1024, - '#description' => t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'), - ); + '#type' => 'url', + '#title' => t('OPML Remote URL'), + '#maxlength' => 1024, + '#description' => t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'), + ); $form['refresh'] = array( - '#type' => 'select', - '#title' => t('Update interval'), - '#default_value' => 3600, - '#options' => $period, - '#description' => t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array('@cron' => url('admin/reports/status'))), - ); + '#type' => 'select', + '#title' => t('Update interval'), + '#default_value' => 3600, + '#options' => $period, + '#description' => t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array('@cron' => url('admin/reports/status'))), + ); $form['block'] = array( - '#type' => 'select', - '#title' => t('News items in block'), - '#default_value' => 5, - '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), - '#description' => t("Drupal can make a block with the most recent news items of a feed. You can configure blocks to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))), - ); + '#type' => 'select', + '#title' => t('News items in block'), + '#default_value' => 5, + '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)), + '#description' => t("Drupal can make a block with the most recent news items of a feed. You can configure blocks to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))), + ); // Handling of categories. $options = array_map('check_plain', $this->database->query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed()); if ($options) { $form['category'] = array( - '#type' => 'checkboxes', - '#title' => t('Categorize news items'), - '#options' => $options, - '#description' => t('New feed items are automatically filed in the checked categories.'), - ); + '#type' => 'checkboxes', + '#title' => t('Categorize news items'), + '#options' => $options, + '#description' => t('New feed items are automatically filed in the checked categories.'), + ); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Import'), - ); + '#type' => 'submit', + '#value' => t('Import'), + ); return $form; } @@ -145,7 +145,7 @@ public function submitForm(array &$form, array &$form_state) { } // Check for duplicate titles or URLs. - $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url'])); + $result = $this->database->query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url'])); foreach ($result as $old) { if (strcasecmp($old->title, $feed['title']) == 0) { drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning'); @@ -157,12 +157,14 @@ public function submitForm(array &$form, array &$form_state) { } } - $new_feed = entity_create('aggregator_feed', array( - 'title' => $feed['title'], - 'url' => $feed['url'], - 'refresh' => $form_state['values']['refresh'], - 'block' => $form_state['values']['block'], - )); + $new_feed = drupal_container()->get('plugin.manager.entity') + ->getStorageController('aggregator_feed') + ->create(array( + 'title' => $feed['title'], + 'url' => $feed['url'], + 'refresh' => $form_state['values']['refresh'], + 'block' => $form_state['values']['block'], + )); $new_feed->categories = $form_state['values']['category']; $new_feed->save(); }