diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index ab27c45..6231e0a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -24,7 +24,7 @@ class FeedFormController extends EntityFormControllerNG { * * @var \Drupal\Core\Entity\EntityStorageControllerInterface */ - protected $feedStorage; + protected $feedStorageController; /** * The category storage controller. @@ -42,7 +42,7 @@ class FeedFormController extends EntityFormControllerNG { * The category storage controller. */ public function __construct(EntityStorageControllerInterface $feed_storage, CategoryStorageControllerInterface $category_storage_controller) { - $this->feedStorage = $feed_storage; + $this->feedStorageController = $feed_storage; $this->categoryStorageController = $category_storage_controller; } @@ -125,7 +125,7 @@ public function form(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { $feed = $this->buildEntity($form, $form_state); // Check for duplicate titles. - $result = $this->feedStorage->getFeedDuplicates($feed); + $result = $this->feedStorageController->getFeedDuplicates($feed); foreach ($result as $item) { if (strcasecmp($item->title, $feed->label()) == 0) { form_set_error('title', $this->t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label()))); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php index 1ff529f..e0fc1a0 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php @@ -7,8 +7,8 @@ namespace Drupal\aggregator; +use Drupal\aggregator\FeedInterface; use Drupal\Core\Entity\DatabaseStorageControllerNG; -use Drupal\Core\Entity\EntityInterface; /** * Controller class for aggregator's feeds. @@ -38,7 +38,7 @@ public function loadCategories(array $feeds) { /** * {@inheritdoc} */ - public function saveCategories(EntityInterface $feed, array $categories) { + public function saveCategories(FeedInterface $feed, array $categories) { foreach ($categories as $cid => $value) { if ($value) { $this->database->insert('aggregator_category_feed') @@ -64,7 +64,7 @@ public function deleteCategories(array $feeds) { /** * {@inheritdoc} */ - public function getFeedDuplicates(EntityInterface $feed) { + public function getFeedDuplicates(FeedInterface $feed) { if ($feed->id()) { $query = $this->database->query("SELECT title, url FROM {aggregator_feed} WHERE (title = :title OR url = :url) AND fid <> :fid", array(':title' => $feed->label(), ':url' => $feed->url->value, ':fid' => $feed->id())); } @@ -72,7 +72,7 @@ public function getFeedDuplicates(EntityInterface $feed) { $query = $this->database->query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed->label(), ':url' => $feed->url->value)); } - return $query; + return $query->fetchAll(); } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php index cd8162c..ab33938 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php @@ -7,7 +7,7 @@ namespace Drupal\aggregator; -use Drupal\Core\Entity\EntityInterface; +use Drupal\aggregator\FeedInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; /** @@ -27,12 +27,12 @@ public function loadCategories(array $feeds); /** * Saves the categories of a feed. * - * @param \Drupal\Core\Entity\EntityInterface $feed + * @param \Drupal\aggregator\Entity\FeedInterface $feed * The feed entity. * @param array $categories * The array of categories. */ - public function saveCategories(EntityInterface $feed, array $categories); + public function saveCategories(FeedInterface $feed, array $categories); /** * Deletes the categories of a feed. @@ -45,8 +45,12 @@ public function deleteCategories(array $feeds); /** * Provides a list of duplicate feeds. * - * @param \Drupal\Core\Entity\EntityInterface $feed + * @param \Drupal\aggregator\Entity\FeedInterface $feed * The feed entity. + * + * @return + * An array with the list of duplicated feeds. */ - public function getFeedDuplicates(EntityInterface $feed); + public function getFeedDuplicates(FeedInterface $feed); + } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index 8eee427..e2cb778 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -10,7 +10,6 @@ use Drupal\aggregator\CategoryStorageControllerInterface; use Drupal\aggregator\FeedStorageControllerInterface; use Drupal\Component\Utility\Url; -use Drupal\Core\Database\Connection; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -24,13 +23,6 @@ class OpmlFeedAdd extends FormBase { /** - * The database connection object. - * - * @var \Drupal\Core\Database\Connection - */ - protected $database; - - /** * The entity query factory object. * * @var \Drupal\Core\Entity\Query\QueryFactory @@ -42,7 +34,7 @@ class OpmlFeedAdd extends FormBase { * * @var \Drupal\aggregator\FeedStorageControllerInterface */ - protected $feedStorage; + protected $feedStorageController; /** * The HTTP client to fetch the feed data with. @@ -61,8 +53,6 @@ class OpmlFeedAdd extends FormBase { /** * Constructs a database object. * - * @param \Drupal\Core\Database\Connection $database - * The database object. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query object. * @param \Drupal\aggregator\FeedStorageControllerInterface $feed_storage @@ -72,10 +62,9 @@ class OpmlFeedAdd extends FormBase { * @param \Drupal\aggregator\CategoryStorageControllerInterface $category_storage_controller * The category storage controller. */ - public function __construct(Connection $database, QueryFactory $query_factory, FeedStorageControllerInterface $feed_storage, ClientInterface $http_client, CategoryStorageControllerInterface $category_storage_controller) { - $this->database = $database; + public function __construct(QueryFactory $query_factory, FeedStorageControllerInterface $feed_storage, ClientInterface $http_client, CategoryStorageControllerInterface $category_storage_controller) { $this->queryFactory = $query_factory; - $this->feedStorage = $feed_storage; + $this->feedStorageController = $feed_storage; $this->httpClient = $http_client; $this->categoryStorageController = $category_storage_controller; } @@ -85,7 +74,6 @@ public function __construct(Connection $database, QueryFactory $query_factory, F */ public static function create(ContainerInterface $container) { return new static( - $container->get('database'), $container->get('entity.query'), $container->get('entity.manager')->getStorageController('aggregator_feed'), $container->get('http_default_client'), @@ -204,7 +192,7 @@ public function submitForm(array &$form, array &$form_state) { $ids = $query ->condition($condition) ->execute(); - $result = $this->feedStorage->loadMultiple($ids); + $result = $this->feedStorageController->loadMultiple($ids); foreach ($result as $old) { if (strcasecmp($old->label(), $feed['title']) == 0) { drupal_set_message($this->t('A feed named %title already exists.', array('%title' => $old->label())), 'warning'); @@ -216,7 +204,7 @@ public function submitForm(array &$form, array &$form_state) { } } - $new_feed = $this->feedStorage->create(array( + $new_feed = $this->feedStorageController->create(array( 'title' => $feed['title'], 'url' => $feed['url'], 'refresh' => $form_state['values']['refresh'],