Issue #2011116 by kgoel | DmitryDrozdik: Replace drupal_container() with Drupal::service() in the path module.
parent
369726993d
commit
b646366de9
|
@ -98,7 +98,7 @@ class PathAliasTest extends PathTestBase {
|
|||
$this->assertText($node1->label(), 'Changed alias works.');
|
||||
$this->assertResponse(200);
|
||||
|
||||
drupal_container()->get('path.alias_manager')->cacheClear();
|
||||
$this->container->get('path.alias_manager')->cacheClear();
|
||||
// Confirm that previous alias no longer works.
|
||||
$this->drupalGet($previous);
|
||||
$this->assertNoText($node1->label(), 'Previous alias no longer works.');
|
||||
|
|
|
@ -84,7 +84,7 @@ class PathLanguageTest extends PathTestBase {
|
|||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
// Clear the path lookup cache.
|
||||
drupal_container()->get('path.alias_manager')->cacheClear();
|
||||
$this->container->get('path.alias_manager')->cacheClear();
|
||||
|
||||
// Ensure the node was created.
|
||||
$french_node = $this->drupalGetNodeByTitle($edit["title"]);
|
||||
|
@ -149,18 +149,18 @@ class PathLanguageTest extends PathTestBase {
|
|||
|
||||
// The alias manager has an internal path lookup cache. Check to see that
|
||||
// it has the appropriate contents at this point.
|
||||
drupal_container()->get('path.alias_manager')->cacheClear();
|
||||
$french_node_path = drupal_container()->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode);
|
||||
$this->container->get('path.alias_manager')->cacheClear();
|
||||
$french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode);
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path works.');
|
||||
// Second call should return the same path.
|
||||
$french_node_path = drupal_container()->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode);
|
||||
$french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode);
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path is the same.');
|
||||
|
||||
// Confirm that the alias works.
|
||||
$french_node_alias = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode);
|
||||
$french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode);
|
||||
$this->assertEqual($french_node_alias, $french_alias, 'Alias works.');
|
||||
// Second call should return the same alias.
|
||||
$french_node_alias = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode);
|
||||
$french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode);
|
||||
$this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ function path_admin_overview($keys = NULL) {
|
|||
|
||||
// If the system path maps to a different URL alias, highlight this table
|
||||
// row to let the user know of old aliases.
|
||||
if ($data->alias != drupal_container()->get('path.alias_manager')->getPathAlias($data->source, $data->langcode)) {
|
||||
if ($data->alias != Drupal::service('path.alias_manager')->getPathAlias($data->source, $data->langcode)) {
|
||||
$row['class'] = array('warning');
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ function path_admin_form_delete_submit($form, &$form_state) {
|
|||
*/
|
||||
function path_admin_form_validate($form, &$form_state) {
|
||||
$source = &$form_state['values']['source'];
|
||||
$source = drupal_container()->get('path.alias_manager')->getSystemPath($source);
|
||||
$source = Drupal::service('path.alias_manager')->getSystemPath($source);
|
||||
$alias = $form_state['values']['alias'];
|
||||
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
|
||||
// Language is only set if language.module is enabled, otherwise save for all
|
||||
|
@ -254,13 +254,13 @@ function path_admin_form_submit($form, &$form_state) {
|
|||
|
||||
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
|
||||
$source = &$form_state['values']['source'];
|
||||
$source = drupal_container()->get('path.alias_manager')->getSystemPath($source);
|
||||
$source = Drupal::service('path.alias_manager')->getSystemPath($source);
|
||||
$alias = $form_state['values']['alias'];
|
||||
// Language is only set if language.module is enabled, otherwise save for all
|
||||
// languages.
|
||||
$langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
|
||||
|
||||
drupal_container()->get('path.crud')->save($source, $alias, $langcode, $pid);
|
||||
Drupal::service('path.crud')->save($source, $alias, $langcode, $pid);
|
||||
|
||||
drupal_set_message(t('The alias has been saved.'));
|
||||
$form_state['redirect'] = 'admin/config/search/path';
|
||||
|
|
|
@ -104,7 +104,7 @@ function path_form_node_form_alter(&$form, $form_state) {
|
|||
if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED) {
|
||||
$conditions['langcode'] = $node->langcode;
|
||||
}
|
||||
$path = drupal_container()->get('path.crud')->load($conditions);
|
||||
$path = Drupal::service('path.crud')->load($conditions);
|
||||
if ($path === FALSE) {
|
||||
$path = array();
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ function path_node_insert(EntityInterface $node) {
|
|||
// Ensure fields for programmatic executions.
|
||||
$source = 'node/' . $node->nid;
|
||||
$langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
|
||||
drupal_container()->get('path.crud')->save($source, $alias, $langcode);
|
||||
Drupal::service('path.crud')->save($source, $alias, $langcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,14 +206,14 @@ function path_node_update(EntityInterface $node) {
|
|||
$alias = trim($path['alias']);
|
||||
// Delete old alias if user erased it.
|
||||
if (!empty($path['pid']) && empty($path['alias'])) {
|
||||
drupal_container()->get('path.crud')->delete(array('pid' => $path['pid']));
|
||||
Drupal::service('path.crud')->delete(array('pid' => $path['pid']));
|
||||
}
|
||||
// Only save a non-empty alias.
|
||||
if (!empty($path['alias'])) {
|
||||
// Ensure fields for programmatic executions.
|
||||
$source = 'node/' . $node->nid;
|
||||
$langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
|
||||
drupal_container()->get('path.crud')->save($source, $alias, $langcode, $path['pid']);
|
||||
Drupal::service('path.crud')->save($source, $alias, $langcode, $path['pid']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ function path_node_update(EntityInterface $node) {
|
|||
*/
|
||||
function path_node_predelete(EntityInterface $node) {
|
||||
// Delete all aliases associated with this node.
|
||||
drupal_container()->get('path.crud')->delete(array('source' => 'node/' . $node->nid));
|
||||
Drupal::service('path.crud')->delete(array('source' => 'node/' . $node->nid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue