public FutureNhsContentService(IPublishedContentQuery publishedContent, Lazy <IFutureNhsContentResolver> contentResolver, IContentService contentService, ILogger <FutureNhsContentService> logger) { _publishedContent = publishedContent ?? throw new ArgumentNullException(nameof(publishedContent)); _contentResolver = contentResolver ?? throw new ArgumentNullException(nameof(contentResolver)); _contentService = contentService ?? throw new ArgumentNullException(nameof(contentService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
internal static int?GetCurrentNotFoundPageId( ContentErrorPage[] error404Collection, IEntityService entityService, IPublishedContentQuery publishedContentQuery, string errorCulture, int?domainContentId) { if (error404Collection.Length > 1) { // test if a 404 page exists with current culture thread ContentErrorPage cultureErr = error404Collection.FirstOrDefault(x => x.Culture.InvariantEquals(errorCulture)) ?? error404Collection.FirstOrDefault(x => x.Culture == "default"); // there should be a default one! if (cultureErr != null) { return(GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery, domainContentId)); } } else if (error404Collection.Length == 1) { return(GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery, domainContentId)); } return(null); }
public void Can_Lookup_Content() { var publishedSnapshot = new Mock <IPublishedSnapshot>(); publishedSnapshot.Setup(x => x.Members).Returns(Mock.Of <IPublishedMemberCache>()); var content = new Mock <IPublishedContent>(); content.Setup(x => x.Id).Returns(2); IBackOfficeSecurityAccessor backofficeSecurityAccessor = Mock.Of <IBackOfficeSecurityAccessor>(); Mock.Get(backofficeSecurityAccessor).Setup(x => x.BackOfficeSecurity).Returns(Mock.Of <IBackOfficeSecurity>()); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); IHostingEnvironment hostingEnvironment = Mock.Of <IHostingEnvironment>(); var globalSettings = new GlobalSettings(); var umbracoContextFactory = TestUmbracoContextFactory.Create(globalSettings, _umbracoContextAccessor); UmbracoContextReference umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(); IUmbracoContext umbracoContext = umbracoContextReference.UmbracoContext; var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext); IPublishedContentQuery publishedContentQuery = Mock.Of <IPublishedContentQuery>(query => query.Content(2) == content.Object); var ctrl = new TestSurfaceController(umbracoContextAccessor, publishedContentQuery, Mock.Of <IPublishedUrlProvider>()); var result = ctrl.GetContent(2) as PublishedContentResult; Assert.IsNotNull(result); Assert.IsNotNull(result.Content); Assert.AreEqual(2, result.Content.Id); }
/// <summary> /// Initializes a new instance of <see cref="UmbracoHelper"/>. /// </summary> /// <param name="currentPage">The <see cref="IPublishedContent"/> item assigned to the helper.</param> /// <param name="cultureDictionary"></param> /// <param name="componentRenderer"></param> /// <param name="publishedContentQuery"></param> /// <remarks>Sets the current page to the context's published content request's content item.</remarks> public UmbracoHelper(ICultureDictionaryFactory cultureDictionary, IUmbracoComponentRenderer componentRenderer, IPublishedContentQuery publishedContentQuery) { _cultureDictionaryFactory = cultureDictionary ?? throw new ArgumentNullException(nameof(cultureDictionary)); _componentRenderer = componentRenderer ?? throw new ArgumentNullException(nameof(componentRenderer)); _publishedContentQuery = publishedContentQuery ?? throw new ArgumentNullException(nameof(publishedContentQuery)); }
/// <summary> /// Returns the content id based on the configured ContentErrorPage section. /// </summary> internal static int?GetContentIdFromErrorPageConfig( ContentErrorPage errorPage, IEntityService entityService, IPublishedContentQuery publishedContentQuery, int?domainContentId) { if (errorPage.HasContentId) { return(errorPage.ContentId); } if (errorPage.HasContentKey) { // need to get the Id for the GUID // TODO: When we start storing GUIDs into the IPublishedContent, then we won't have to look this up // but until then we need to look it up in the db. For now we've implemented a cached service for // converting Int -> Guid and vice versa. Attempt <int> found = entityService.GetId(errorPage.ContentKey, UmbracoObjectTypes.Document); if (found) { return(found.Result); } return(null); } if (errorPage.ContentXPath.IsNullOrWhiteSpace() == false) { try { // we have an xpath statement to execute var xpathResult = UmbracoXPathPathSyntaxParser.ParseXPathQuery( xpathExpression: errorPage.ContentXPath, nodeContextId: domainContentId, getPath: nodeid => { IEntitySlim ent = entityService.Get(nodeid); return(ent.Path.Split(',').Reverse()); }, publishedContentExists: i => publishedContentQuery.Content(i) != null); // now we'll try to execute the expression IPublishedContent nodeResult = publishedContentQuery.ContentSingleAtXPath(xpathResult); if (nodeResult != null) { return(nodeResult.Id); } } catch (Exception ex) { StaticApplicationLogging.Logger.LogError(ex, "Could not parse xpath expression: {ContentXPath}", errorPage.ContentXPath); return(null); } } return(null); }
/// <summary> /// Returns the Umbraco page id to use as the Not Found page based on the configured 404 pages and the current request /// </summary> /// <param name="error404Collection"></param> /// <param name="requestServerName"> /// The server name attached to the request, normally would be the source of HttpContext.Current.Request.ServerVariables["SERVER_NAME"] /// </param> /// <param name="entityService"></param> /// <param name="publishedContentQuery"></param> /// <param name="domainService"></param> /// <returns></returns> internal static int?GetCurrentNotFoundPageId( IContentErrorPage[] error404Collection, string requestServerName, IEntityService entityService, IPublishedContentQuery publishedContentQuery, IDomainService domainService) { throw new NotImplementedException(); }
public UmbracoHelper GetUmbracoHelper( IPublishedContentQuery publishedContentQuery = null, ICultureDictionaryFactory cultureDictionaryFactory = null, MembershipHelper membershipHelper = null) { return(new UmbracoHelper( Mock.Of <IPublishedContent>(), Mock.Of <ITagQuery>(), cultureDictionaryFactory ?? CultureDictionaryFactory().Object, Mock.Of <IUmbracoComponentRenderer>(), publishedContentQuery ?? PublishedContentQuerying.Object, SetupMembership())); }
/// <summary> /// Initializes a new instance of <see cref="UmbracoHelper"/>. /// </summary> /// <param name="currentPage">The <see cref="IPublishedContent"/> item assigned to the helper.</param> /// <param name="tagQuery"></param> /// <param name="cultureDictionary"></param> /// <param name="componentRenderer"></param> /// <param name="publishedContentQuery"></param> /// <param name="membershipHelper"></param> /// <remarks>Sets the current page to the context's published content request's content item.</remarks> public UmbracoHelper(IPublishedContent currentPage, ITagQuery tagQuery, ICultureDictionaryFactory cultureDictionary, IUmbracoComponentRenderer componentRenderer, IPublishedContentQuery publishedContentQuery, MembershipHelper membershipHelper) { _tagQuery = tagQuery ?? throw new ArgumentNullException(nameof(tagQuery)); _cultureDictionaryFactory = cultureDictionary ?? throw new ArgumentNullException(nameof(cultureDictionary)); _componentRenderer = componentRenderer ?? throw new ArgumentNullException(nameof(componentRenderer)); _membershipHelper = membershipHelper ?? throw new ArgumentNullException(nameof(membershipHelper)); _publishedContentQuery = publishedContentQuery ?? throw new ArgumentNullException(nameof(publishedContentQuery)); _currentPage = currentPage; }
public TemplateQueryController( IVariationContextAccessor variationContextAccessor, IPublishedContentQuery publishedContentQuery, ILocalizedTextService localizedTextService, IPublishedValueFallback publishedValueFallback, IContentTypeService contentTypeService) { _variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor)); _publishedContentQuery = publishedContentQuery ?? throw new ArgumentNullException(nameof(publishedContentQuery)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); _publishedValueFallback = publishedValueFallback ?? throw new ArgumentNullException(nameof(publishedValueFallback)); _contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService)); }
public CheeryQueryController( //IPublishedContentCache cache /// causes an error UmbracoHelper helper, IPublishedContentQuery publishedContentQuery, IContentService contentService, IUmbracoContextFactory umbracoContextFactory) { _helper = helper; _publishedContentQuery = publishedContentQuery; _contentService = contentService; _umbracoContextFactory = umbracoContextFactory; var page = helper.Content(2141); var otherPage = publishedContentQuery.Content(2141); IPublishedContent anotherPage = null; using (var cref = umbracoContextFactory.EnsureUmbracoContext()) { var cache = cref.UmbracoContext.Content; anotherPage = cache.GetById(2141); } }
internal static int?GetCurrentNotFoundPageId( IContentErrorPage[] error404Collection, IEntityService entityService, IPublishedContentQuery publishedContentQuery, CultureInfo errorCulture) { if (error404Collection.Length > 1) { // test if a 404 page exists with current culture thread var cultureErr = error404Collection.FirstOrDefault(x => x.Culture == errorCulture.Name) ?? error404Collection.FirstOrDefault(x => x.Culture == "default"); // there should be a default one! if (cultureErr != null) { return(GetContentIdFromErrorPageConfig(cultureErr, entityService, publishedContentQuery)); } } else { return(GetContentIdFromErrorPageConfig(error404Collection.First(), entityService, publishedContentQuery)); } return(null); }
public DocTypeGridEditorApiController(IUmbracoContextAccessor umbracoContext, IContentTypeService contentTypeService, IContentService contentService, IDataTypeService dataTypeService, IShortStringHelper shortStringHelper, IPublishedContentQuery contentQuery, IPublishedRouter router, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, PropertyEditorCollection propertyEditorCollection, DocTypeGridEditorHelper dtgeHelper) { _umbracoContext = umbracoContext; _contentTypeService = contentTypeService; _contentService = contentService; _dataTypeService = dataTypeService; _shortStringHelper = shortStringHelper; _contentQuery = contentQuery; _router = router; _dtgeHelper = dtgeHelper; _serviceContext = serviceContext; _publishedContentTypeFactory = publishedContentTypeFactory; _propertyEditorCollection = propertyEditorCollection; }
public ContentApiController( Lazy <IContentResolver> contentResolver, IPublishedContentQuery publishedContent) { _contentResolver = contentResolver; _publishedContent = publishedContent; }
public LinkConvertor(IPublishedContentQuery contentQuery) { this.contentQuery = contentQuery; }
/// <summary> /// Initializes a new instance of the <see cref="TagQuery"/> class. /// </summary> public TagQuery(ITagService tagService, IPublishedContentQuery contentQuery, IUmbracoMapper mapper) { _tagService = tagService ?? throw new ArgumentNullException(nameof(tagService)); _contentQuery = contentQuery ?? throw new ArgumentNullException(nameof(contentQuery)); _mapper = mapper; }
/// <summary> /// Initializes a new instance of the <see cref="TagQuery"/> class. /// </summary> public TagQuery(ITagService tagService, IPublishedContentQuery contentQuery) { _tagService = tagService ?? throw new ArgumentNullException(nameof(tagService)); _contentQuery = contentQuery ?? throw new ArgumentNullException(nameof(contentQuery)); }
public TeacherProfilesService(IMapper mapper, IPublishedContentQuery contentService) { this.mapper = mapper; }
public TestSurfaceController( IUmbracoContextAccessor umbracoContextAccessor, IPublishedContentQuery publishedContentQuery, IPublishedUrlProvider publishedUrlProvider) : base(umbracoContextAccessor, null, ServiceContext.CreatePartial(), AppCaches.Disabled, null, publishedUrlProvider) =>
public SiteNavNavSectionsMemberResolver(IMapper mapper, IPublishedContentQuery contentQuery) { this.mapper = mapper; this.contentQuery = contentQuery; }
public SpeakersController(IPublishedContentQuery content) { _content = content; }