Commit 04fd8849 authored by alexpott's avatar alexpott

Issue #1972262 by ParisLiakos: Convert aggregator_feed_add() to a new style controller.

parent 2172cde3
......@@ -97,22 +97,6 @@ function aggregator_view() {
return $output;
}
/**
* Page callback: Presents the aggregator feed creation form.
*
* @return array
* A form array as expected by drupal_render().
*
* @see aggregator_menu()
*/
function aggregator_feed_add() {
$feed = entity_create('aggregator_feed', array(
'refresh' => 3600,
'block' => 5,
));
return entity_get_form($feed);
}
/**
* Form constructor for importing feeds from OPML.
*
......
......@@ -99,10 +99,8 @@ function aggregator_menu() {
);
$items['admin/config/services/aggregator/add/feed'] = array(
'title' => 'Add feed',
'page callback' => 'aggregator_feed_add',
'access arguments' => array('administer news feeds'),
'route_name' => 'aggregator_feed_add',
'type' => MENU_LOCAL_ACTION,
'file' => 'aggregator.admin.inc',
);
$items['admin/config/services/aggregator/add/category'] = array(
'title' => 'Add category',
......
......@@ -18,3 +18,10 @@ aggregator_feed_delete:
_form: '\Drupal\aggregator\Form\FeedDelete'
requirements:
_permission: 'administer news feeds'
aggregator_feed_add:
pattern: '/admin/config/services/aggregator/add/feed'
defaults:
_controller: '\Drupal\aggregator\Routing\AggregatorController::feedAdd'
requirements:
_permission: 'administer news feeds'
<?php
/**
* @file
* Contains \Drupal\aggregator\Routing\AggregatorController.
*/
namespace Drupal\aggregator\Routing;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\ControllerInterface;
use Drupal\Core\Entity\EntityManager;
/**
* Returns responses for aggregator module routes.
*/
class AggregatorController implements ControllerInterface {
/**
* Stores the Entity manager.
*
* @var \Drupal\Core\Entity\EntityManager
*/
protected $entityManager;
/**
* Constructs a \Drupal\aggregator\Routing\AggregatorController object.
*
* @param \Drupal\Core\Entity\EntityManager $entity_manager
* The Entity manager.
*/
public function __construct(EntityManager $entity_manager) {
$this->entityManager = $entity_manager;
}
/**
* {inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('plugin.manager.entity'));
}
/**
* Presents the aggregator feed creation form.
*
* @return array
* A form array as expected by drupal_render().
*/
public function feedAdd() {
$feed = $this->entityManager
->getStorageController('aggregator_feed')
->create(array(
'refresh' => 3600,
'block' => 5,
));
return entity_get_form($feed);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment