forked from JimmieOverby/MultipleSitesManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddSiteProcessor.cs
66 lines (60 loc) · 3.01 KB
/
AddSiteProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* *********************************************************************** *
* File : AddSiteProcessor.cs Part of Sitecore *
* Version: 2.1.0 www.sitecore.net *
* *
* *
* Purpose: Represents item:added event handler *
* *
* Bugs : None known. *
* *
* Status : Published. *
* *
* Copyright (C) 1999-2007 by Sitecore A/S. All rights reserved. *
* *
* This work is the property of: *
* *
* Sitecore A/S *
* Meldahlsgade 5, 4. *
* 1613 Copenhagen V. *
* Denmark *
* *
* This is a Sitecore published work under Sitecore's *
* shared source license. *
* *
* *********************************************************************** */
namespace Sitecore.Sites
{
using System;
using System.Collections.Generic;
using Configuration;
using Data;
using Sitecore.Data.Items;
using Sitecore.Data.Managers;
using Sitecore.Events;
using Sitecore.Shell.Framework;
/// <summary>
/// Defines the add site processor class.
/// </summary>
public class AddSiteProcessor
{
/// <summary>
/// Called when the site has added.
/// </summary>
/// <param name="obj">The object.</param>
/// <param name="eventArgs">The <see cref="System.EventArgs"/> instance containing the event data.</param>
public void OnSiteAdded(object obj, EventArgs eventArgs)
{
var item = Event.ExtractParameter(eventArgs, 0) as Item;
if (item == null || item.Parent == null || item.Parent.Name != "Sites")
{
return;
}
if (item.TemplateName != MultiSitesManager.SiteDefinitionTemplateName && item.TemplateName != MultiSitesManager.SiteReferenceTemplateName)
{
return;
}
Items.MoveLast(new[] { item });
MultiSitesManager.ArrangeSitesContext();
}
}
}