public FixedPropertyEditors(IUmbracoApplicationContext fakeUmbracoApplicationContext) { var fakeBackOfficeContext = new FakeBackOfficeRequestContext(fakeUmbracoApplicationContext); _propertyEditors = new PropertyEditor[] { new NonMandatoryPropertyEditor(Guid.Parse("D3DC1AC8-F83D-4D73-A13B-024E3100A600"), "rte", ""), new NonMandatoryPropertyEditor(Guid.Parse("781FA5A4-C26D-4BBB-9F58-6CBBE0A9D14A"), "cust", ""), new NonMandatoryPropertyEditor(Guid.Parse("3F5ED845-7018-4BDE-AB4E-C7106EE0992D"), "text", ""), new NonMandatoryPropertyEditor(Guid.Parse("9CCB7060-3550-11E0-8A80-074CDFD72085"), "swatch", ""), new NonMandatoryPropertyEditor(Guid.Parse("2B4DF3F1-C84E-4611-87EE-1D90ED437337"), "tags", ""), new NonMandatoryPropertyEditor(), new MandatoryPropertyEditor(), new RegexPropertyEditor(), new PreValueRegexPropertyEditor(), //ensure node name is there new NodeNameEditor(fakeBackOfficeContext.Application), new SelectedTemplateEditor(fakeBackOfficeContext), new UploadEditor(fakeBackOfficeContext), new LabelEditor(), new TrueFalseEditor(), new DateTimePickerEditor(), new NumericEditor(), new TreeNodePicker(Enumerable.Empty<Lazy<TreeController, TreeMetadata>>()), new ListPickerEditor(), new TestContentAwarePropertyEditor() }; }
protected EntitySchema CreateNewSchema(PropertyEditor propEditor = null, string alias = "test") { if (propEditor == null) propEditor = new MandatoryPropertyEditor(); var attributeType = HiveModelCreationHelper.CreateAttributeType("test", "test", "test"); attributeType.RenderTypeProvider = propEditor.Id.ToString(); UmbracoApplicationContext.AddPersistenceData(attributeType); var schema = HiveModelCreationHelper.MockEntitySchema(alias, alias); schema.TryAddAttributeDefinition(HiveModelCreationHelper.CreateAttributeDefinition("siteName", "Site Name", "", attributeType, null)); schema.TryAddAttributeDefinition(HiveModelCreationHelper.CreateAttributeDefinition("bodyText", "Body Text", "", attributeType, null)); //set all attribute defs to the attribute type schema.AttributeDefinitions.Where(x => !x.Alias.StartsWith("system-")).ForEach(x => x.AttributeType = attributeType); schema.RelationProxies.EnlistParent(new ContentRootSchema(), FixedRelationTypes.DefaultRelationType, 0); UmbracoApplicationContext.AddPersistenceData(schema); return schema; }
protected Revision<TypedEntity> CreateEntityRevision(PropertyEditor propEditor, Action<Revision<TypedEntity>> beforeCommit) { EntitySchema docTypeEntity = CreateNewSchema(propEditor); //create some content properties including node name var nodeName = HiveModelCreationHelper.CreateAttribute(docTypeEntity.AttributeDefinitions.Single(x => x.Alias == NodeNameAttributeDefinition.AliasValue), ""); var bodyText = HiveModelCreationHelper.CreateAttribute(docTypeEntity.AttributeDefinitions.Single(x => x.Alias == "bodyText"), "my-test-value1"); var siteName = HiveModelCreationHelper.CreateAttribute(docTypeEntity.AttributeDefinitions.Single(x => x.Alias == "siteName"), "my-test-value2"); var contentEntity = HiveModelCreationHelper.CreateVersionedTypedEntity(docTypeEntity, new[] { nodeName, bodyText, siteName }); contentEntity.MetaData = new RevisionData(FixedStatusTypes.Draft); if (beforeCommit != null) beforeCommit(contentEntity); UmbracoApplicationContext.AddPersistenceData(contentEntity); return contentEntity; }
/// <summary> /// helper method to create a content entity and assigns the same property editor to each of the attributes /// </summary> /// <param name="propEditor"></param> /// <returns></returns> protected Revision<TypedEntity> CreateEntityRevision(PropertyEditor propEditor) { return CreateEntityRevision(propEditor, null); }