@@ -30,21 +30,29 @@ public function entityAliasExists(EntityInterface $entity) {
30
30
return $ this ->fetchExistingAlias ($ entity ) != NULL ;
31
31
}
32
32
33
- public function createAlias (EntityInterface $ entity ) {
34
- foreach ($ this ->sluggers as $ slugger ) {
35
- if ($ slugger ->applies ($ entity )) {
36
- $ langcode = $ entity ->language ()->getId ();
37
- $ alias = $ slugger ->build ($ entity );
38
- $ alias = $ this ->ensureAliasUnique ($ alias , $ langcode );
39
- $ cache_key = '/ ' . $ entity ->urlInfo ()->getInternalPath ();
40
- $ this ->aliasStorage ->save ($ cache_key , $ alias , $ langcode );
41
- return TRUE ;
33
+ public function createAlias (EntityInterface $ entity , $ force = FALSE ) {
34
+ if (!$ this ->entityAliasExists ($ entity ) || $ force ) {
35
+ foreach ($ this ->sluggers as $ slugger ) {
36
+ if ($ slugger ->applies ($ entity )) {
37
+ $ langcode = $ entity ->language ()->getId ();
38
+ $ alias = $ slugger ->build ($ entity );
39
+ $ alias = $ this ->ensureAliasUnique ($ alias , $ langcode );
40
+ $ cache_key = '/ ' . $ entity ->urlInfo ()->getInternalPath ();
41
+ $ this ->aliasStorage ->save ($ cache_key , $ alias , $ langcode );
42
+ return TRUE ;
43
+ }
42
44
}
43
45
}
44
46
45
47
return FALSE ;
46
48
}
47
49
50
+ public function createAllAliases (EntityInterface $ entity ) {
51
+ foreach ($ entity ->getTranslationLanguages () as $ language ) {
52
+ $ this ->createAlias ($ entity ->getTranslation ($ language ->getId ()));
53
+ }
54
+ }
55
+
48
56
public function ensureAliasUnique ($ base , $ langcode ) {
49
57
$ alias = $ base ;
50
58
for ($ i = 1 ; $ this ->aliasStorage ->lookupPathSource ($ alias , $ langcode ); $ i ++) {
0 commit comments