Commit 5c359697 authored by andrei.dincu's avatar andrei.dincu

Issue #2249723 by andrei.dincu: form_state is FormStateInterface now

parent c9a042b9
......@@ -9,6 +9,7 @@ namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
/**
* Builds the form to delete a sitemap.
......@@ -46,7 +47,7 @@ class XmlSitemapDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state) {
public function submit(array $form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message($this->t('Sitemap %label has been deleted.', array('%label' => $this->entity->label())));
$form_state['redirect'] = 'admin/config/search/xmlsitemap';
......
......@@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -59,7 +60,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('xmlsitemap.settings');
$entity_types = $this->entityManager->getDefinitions();
$labels = array();
......@@ -131,7 +132,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$bundles = $this->entityManager->getAllBundleInfo();
$entity_values = $form_state['values']['entity_types'];
$config = $this->config('xmlsitemap.settings');
......
......@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Form\FormStateInterface;
class XmlSitemapForm extends EntityForm {
......@@ -24,7 +25,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, array &$form_state) {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
if ($this->entity->getContext() == NULL) {
$this->entity->context = array();
......@@ -57,7 +58,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function save(array $form, array &$form_state) {
public function save(array $form, FormStateInterface $form_state) {
if (!isset($form_state['values']['context'])) {
$form_state['values']['context'] = xmlsitemap_get_current_context();
}
......@@ -92,7 +93,7 @@ class XmlSitemapForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function delete(array $form, array &$form_state) {
public function delete(array $form, FormStateInterface $form_state) {
$destination = array();
$request = $this->getRequest();
if ($request->query->has('destination')) {
......
......@@ -11,6 +11,7 @@ use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
......@@ -62,7 +63,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase implements Contain
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state, $entity = NULL, $bundle = NULL) {
public function buildForm(array $form, FormStateInterface $form_state, $entity = NULL, $bundle = NULL) {
$this->entity_type = $entity;
$this->bundle_type = $bundle;
$config = $this->config('xmlsitemap.settings');
......@@ -104,7 +105,7 @@ class XmlSitemapLinkBundleSettingsForm extends ConfigFormBase implements Contain
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $form['xmlsitemap']['#entity'];
$bundle = $form['xmlsitemap']['#bundle'];
......
......@@ -10,6 +10,7 @@ namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -56,7 +57,7 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
$request = $this->getRequest();
if (!$request->request && !$this->state->get('xmlsitemap_rebuild_needed')) {
if (!$this->state->get('xmlsitemap_regenerate_needed')) {
......@@ -92,7 +93,7 @@ class XmlSitemapRebuildForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
// Save any changes to the frontpage link.
$batch = xmlsitemap_rebuild_batch($form_state['values']['entities'], $form_state['values']['save_custom']);
batch_set($batch);
......
......@@ -13,8 +13,9 @@ use Drupal\Core\Render\Element;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\xmlsitemap\XmlSitemapLinkStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Configure xmlsitemap settings for this site.
......@@ -78,7 +79,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('xmlsitemap.settings');
$intervals = array(300, 900, 1800, 3600, 10800, 21600, 43200, 86400, 172800, 259200, 604800);
$form['minimum_lifetime'] = array(
......@@ -210,7 +211,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
// Check that the chunk size will not create more than 1000 chunks.
$chunk_size = $form_state['values']['chunk_size'];
if ($chunk_size != 'auto' && $chunk_size != 50000 && (xmlsitemap_get_link_count() / $chunk_size) > 1000) {
......@@ -229,7 +230,7 @@ class XmlSitemapSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
// Save any changes to the frontpage link.
$config = $this->config('xmlsitemap.settings');
$values = $form_state['values'];
......
......@@ -70,7 +70,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
*/
public function testDefaultSitemap() {
$this->drupalLogin($this->admin_user);
$context = array('language' => 'en');
$context = array();
$id = xmlsitemap_sitemap_get_context_hash($context);
$this->drupalGet('admin/config/search/xmlsitemap');
......@@ -89,7 +89,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
$this->drupalPostForm('admin/config/search/xmlsitemap/add', $edit, t('Save'));
$context = array('language' => 'en');
$id = xmlsitemap_sitemap_get_context_hash($context);
$this->assertText(t('There is another sitemap saved with the same context.'));
$this->assertText(t('Saved the English sitemap.'));
$this->assertText($id);
$edit = array(
......@@ -110,7 +110,7 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
'context[language]' => 'und'
);
$this->drupalPostForm('admin/config/search/xmlsitemap/add', $edit, t('Save'));
$this->assertText(t('Saved the Undefined sitemap.'));
$this->assertText(t('There is another sitemap saved with the same context.'));
$sitemaps = entity_load_multiple('xmlsitemap');
foreach ($sitemaps as $sitemap) {
......
......@@ -19,7 +19,7 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
*
* @var array
*/
public static $modules = array('node', 'xmlsitemap', 'menu_link', 'menu_ui');
public static $modules = array('node', 'xmlsitemap','menu_link_content', 'menu_ui');
public static function getInfo() {
return array(
......
......@@ -20,6 +20,7 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
......@@ -1073,7 +1074,7 @@ function xmlsitemap_calculate_changefreq($timestamps) {
* This function needs to be called before system_settings_form_submit() or any
* calls to variable_set().
*/
function xmlsitemap_form_submit_flag_regenerate($form, $form_state) {
function xmlsitemap_form_submit_flag_regenerate(array $form, FormStateInterface $form_state) {
foreach ($form_state['values'] as $variable => $value) {
if (\Drupal::config('xmlsitemap.settings')->get($variable) == NULL) {
$stored_value = 'not_a_variable';
......@@ -1230,7 +1231,7 @@ function xmlsitemap_add_form_link_options(array &$form, $entity, $bundle, $id) {
/**
* Submit callback for the entity form to save.
*/
function xmlsitemap_process_form_link_options($form, &$form_state) {
function xmlsitemap_process_form_link_options(array $form, FormStateInterface $form_state) {
$link = &$form_state['values']['xmlsitemap'];
$fields = array('status' => XMLSITEMAP_STATUS_DEFAULT, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT);
......@@ -1562,14 +1563,14 @@ function theme_xmlsitemap_content_settings_table($variables) {
* An instance of the entity form interface or FALSE if not an
* entity form.
*/
function xmlsitemap_form_controller(array $form_state) {
function xmlsitemap_form_controller(FormStateInterface $form_state) {
return isset($form_state['controller']) && $form_state['controller'] instanceof EntityForm ? $form_state['controller'] : FALSE;
}
/**
* Implements hook_form_alter().
*/
function xmlsitemap_form_alter(array &$form, array &$form_state, $form_id) {
function xmlsitemap_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
$form_controller = xmlsitemap_form_controller($form_state);
$entity = $form_controller ? $form_controller->getEntity() : NULL;
$entity_type = $entity ? $entity->getEntityTypeId() : NULL;
......@@ -1774,7 +1775,7 @@ function xmlsitemap_xmlsitemap_context_url_options(array $context) {
/**
* Implements hook_form_FORM_ID_alter().
*/
function xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter(&$form, $form_state) {
function xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter(&$form, FormStateInterface $form_state) {
if (!\Drupal::moduleHandler()->moduleExists('language')) {
return;
}
......@@ -1798,7 +1799,7 @@ function xmlsitemap_form_xmlsitemap_sitemap_edit_form_alter(&$form, $form_state)
*
* Set the regeneration needed flag if settings are changed.
*/
function xmlsitemap_form_language_admin_overview_form_alter(&$form, $form_state) {
function xmlsitemap_form_language_admin_overview_form_alter(&$form, FormStateInterface $form_state) {
if (!\Drupal::moduleHandler()->moduleExists('language')) {
return;
}
......@@ -2067,7 +2068,7 @@ function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info)
* @param string $bundle
* Bundle id.
*/
function xmlsitemap_add_link_bundle_settings(array &$form, array &$form_state, $entity, $bundle) {
function xmlsitemap_add_link_bundle_settings(array &$form, FormStateInterface $form_state, $entity, $bundle) {
$entity_info = xmlsitemap_get_link_info($entity);
$bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
......
......@@ -16,6 +16,7 @@ use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\xmlsitemap\XmlSitemapLinkStorageInterface;
/**
......@@ -92,7 +93,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
$query = db_select('xmlsitemap', 'x');
$query->addExpression('MAX(id)');
$id = $query->execute()->fetchField();
......@@ -169,7 +170,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
$link = &$form_state['values'];
// Make sure we trim and normalize the path first.
......@@ -200,7 +201,7 @@ class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$link = $form_state['values'];
$this->linkStorage->save($link);
drupal_set_message(t('The custom link for %loc was saved.', array('%loc' => $link['loc'])));
......
......@@ -10,6 +10,7 @@ namespace Drupal\xmlsitemap_custom\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Url;
use Drupal\xmlsitemap\XmlSitemapLinkStorage;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
......@@ -34,7 +35,7 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state, $link = '') {
public function buildForm(array $form, FormStateInterface $form_state, $link = '') {
$query = db_select('xmlsitemap');
$query->fields('xmlsitemap');
$query->condition('type', 'custom');
......@@ -75,7 +76,7 @@ class XmlSitemapCustomDeleteForm extends ConfirmFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
XmlSitemapLinkStorage::linkDelete('custom', $this->custom_link['id']);
drupal_set_message(t('The custom link for %loc has been deleted.', array('%loc' => $this->custom_link['loc'])));
watchdog('xmlsitemap', 'The custom link for %loc has been deleted.', array('%loc' => $this->custom_link['loc']), WATCHDOG_NOTICE);
......
......@@ -17,6 +17,7 @@ use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\xmlsitemap\XmlSitemapLinkStorageInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a form for editing a custom link.
......@@ -99,7 +100,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state, $link = '') {
public function buildForm(array $form, FormStateInterface $form_state, $link = '') {
$query = db_select('xmlsitemap');
$query->fields('xmlsitemap');
$query->condition('type', 'custom');
......@@ -188,7 +189,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
$link = &$form_state['values'];
$link['loc'] = trim($link['loc']);
$link['loc'] = $this->aliasManager->getPathByAlias($link['loc'], $link['language']);
......@@ -205,7 +206,7 @@ class XmlSitemapCustomEditForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$link = $form_state['values'];
$this->linkStorage->save($link);
drupal_set_message(t('The custom link for %loc was saved.', array('%loc' => $link['loc'])));
......
......@@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Configure xmlsitemap engines settings for this site.
......@@ -68,7 +69,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
public function buildForm(array $form, FormStateInterface $form_state) {
// Build the list of support engines for the checkboxes options.
$engines = xmlsitemap_engines_get_engine_info();
$engine_options = array();
......@@ -112,7 +113,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state) {
public function validateForm(array &$form, FormStateInterface $form_state) {
$custom_urls = preg_split('/[\r\n]+/', $form_state['values']['custom_urls'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($custom_urls as $custom_url) {
$url = xmlsitemap_engines_prepare_url($custom_url, '');
......@@ -127,7 +128,7 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$state_variables = xmlsitemap_engines_state_variables();
$config_variables = xmlsitemap_engines_config_variables();
$keys = array(
......
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