Example #1
0
        /// <summary>
        /// Return the Url for a Web Api service
        /// </summary>
        /// <param name="url"></param>
        /// <param name="umbracoApiControllerTypeCollection"></param>
        /// <param name="actionName"></param>
        /// <param name="apiControllerType"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string?GetUmbracoApiService(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, string actionName, Type apiControllerType, object?id = null)
        {
            if (actionName == null)
            {
                throw new ArgumentNullException(nameof(actionName));
            }
            if (string.IsNullOrWhiteSpace(actionName))
            {
                throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(actionName));
            }
            if (apiControllerType == null)
            {
                throw new ArgumentNullException(nameof(apiControllerType));
            }

            var area = "";

            var apiController = umbracoApiControllerTypeCollection.SingleOrDefault(x => x == apiControllerType);

            if (apiController == null)
            {
                throw new InvalidOperationException("Could not find the umbraco api controller of type " + apiControllerType.FullName);
            }
            var metaData = PluginController.GetMetadata(apiController);

            if (metaData.AreaName.IsNullOrWhiteSpace() == false)
            {
                //set the area to the plugin area
                area = metaData.AreaName;
            }
            return(url.GetUmbracoApiService(actionName, ControllerExtensions.GetControllerName(apiControllerType), area !, id));
        }
Example #2
0
 protected FileSystemTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEventAggregator eventAggregator
     )
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator) =>
Example #3
0
 public LanguageTreeController(
     ILocalizedTextService textService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IEventAggregator eventAggregator)
     : base(textService, umbracoApiControllerTypeCollection, eventAggregator)
 {
 }
        // internal for tests
        internal static void CreateRoutes(
            IUmbracoContextAccessor umbracoContextAccessor,
            IGlobalSettings globalSettings,
            SurfaceControllerTypeCollection surfaceControllerTypes,
            UmbracoApiControllerTypeCollection apiControllerTypes)
        {
            var umbracoPath = globalSettings.GetUmbracoMvcArea();

            // create the front-end route
            var defaultRoute = RouteTable.Routes.MapRoute(
                "Umbraco_default",
                umbracoPath + "/RenderMvc/{action}/{id}",
                new { controller = "RenderMvc", action = "Index", id = UrlParameter.Optional }
                );

            defaultRoute.RouteHandler = new RenderRouteHandler(umbracoContextAccessor, ControllerBuilder.Current.GetControllerFactory());

            // register install routes
            RouteTable.Routes.RegisterArea <UmbracoInstallArea>();

            // register all back office routes
            RouteTable.Routes.RegisterArea(new BackOfficeArea(globalSettings));

            // plugin controllers must come first because the next route will catch many things
            RoutePluginControllers(globalSettings, surfaceControllerTypes, apiControllerTypes);
        }
 public StylesheetsTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     FileSystems fileSystems,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator) =>
Example #6
0
 /// <summary>
 ///     Return the Url for a Web Api service
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="url"></param>
 /// <param name="umbracoApiControllerTypeCollection"></param>
 /// <param name="actionName"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static string?GetUmbracoApiService <T>(
     this IUrlHelper url,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     string actionName,
     object?id = null)
     where T : UmbracoApiController =>
 url.GetUmbracoApiService(umbracoApiControllerTypeCollection, actionName, typeof(T), id);
Example #7
0
 /// <inheritdoc/>
 public uSyncTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
 }
 public WebFinalComponent(IUmbracoContextAccessor umbracoContextAccessor, SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes, IGlobalSettings globalSettings)
 {
     _umbracoContextAccessor = umbracoContextAccessor;
     _surfaceControllerTypes = surfaceControllerTypes;
     _apiControllerTypes     = apiControllerTypes;
     _globalSettings         = globalSettings;
 }
Example #9
0
 public StaticFilesTreeController(ILocalizedTextService localizedTextService,
                                  UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, IEventAggregator eventAggregator,
                                  IPhysicalFileSystem fileSystem) :
     base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _fileSystem = fileSystem;
 }
Example #10
0
 public DataTypeTreeController(ILocalizedTextService localizedTextService, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, UmbracoTreeSearcher treeSearcher, IMenuItemCollectionFactory menuItemCollectionFactory, IEntityService entityService, IDataTypeService dataTypeService, IEventAggregator eventAggregator) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _treeSearcher = treeSearcher;
     _menuItemCollectionFactory = menuItemCollectionFactory;
     _entityService             = entityService;
     _dataTypeService           = dataTypeService;
 }
 public ContentTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEntityService entityService,
     IBackOfficeSecurityAccessor backofficeSecurityAccessor,
     ILogger <ContentTreeController> logger,
     ActionCollection actionCollection,
     IUserService userService,
     IDataTypeService dataTypeService,
     UmbracoTreeSearcher treeSearcher,
     ActionCollection actions,
     IContentService contentService,
     IPublicAccessService publicAccessService,
     ILocalizationService localizationService,
     IEventAggregator eventAggregator,
     IEmailSender emailSender,
     AppCaches appCaches)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, entityService, backofficeSecurityAccessor, logger, actionCollection, userService, dataTypeService, eventAggregator, appCaches)
 {
     _treeSearcher = treeSearcher;
     _actions      = actions;
     _menuItemCollectionFactory  = menuItemCollectionFactory;
     _backofficeSecurityAccessor = backofficeSecurityAccessor;
     _contentService             = contentService;
     _entityService       = entityService;
     _publicAccessService = publicAccessService;
     _userService         = userService;
     _localizationService = localizationService;
     _emailSender         = emailSender;
     _appCaches           = appCaches;
 }
 public FilesTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IPhysicalFileSystem fileSystem,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator) =>
Example #13
0
 public MemberGroupTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IMemberGroupService memberGroupService,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
     => _memberGroupService = memberGroupService;
 protected MemberTypeAndGroupTreeControllerBase(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     MenuItemCollectionFactory = menuItemCollectionFactory;
 }
Example #15
0
 public PackagesTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _menuItemCollectionFactory = menuItemCollectionFactory;
 }
        public static string GetMenuUrl(this IUrlHelper urlHelper, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Type treeType, string nodeId, FormCollection?queryStrings)
        {
            var actionUrl = urlHelper.GetUmbracoApiService(umbracoApiControllerTypeCollection, "GetMenu", treeType)?
                            .EnsureEndsWith('?');

            //now we need to append the query strings
            actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings?.ToQueryString("id");
            return(actionUrl);
        }
Example #17
0
 public LanguageTreeController(
     ILocalizedTextService textService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IEventAggregator eventAggregator,
     IMenuItemCollectionFactory menuItemCollectionFactory)
     : base(textService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _menuItemCollectionFactory = menuItemCollectionFactory;
 }
Example #18
0
 public PartialViewsTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     FileSystems fileSystems,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator)
 {
     FileSystem = fileSystems.PartialViewsFileSystem;
 }
 public RelationTypeTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IRelationService relationService,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _menuItemCollectionFactory = menuItemCollectionFactory;
     _relationService           = relationService;
 }
Example #20
0
        public static string?GetUmbracoApiServiceBaseUrl <T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Expression <Func <T, object> > methodSelector)
            where T : UmbracoApiController
        {
            var method = ExpressionHelper.GetMethodInfo(methodSelector);

            if (method == null)
            {
                throw new MissingMethodException("Could not find the method " + methodSelector + " on type " + typeof(T) + " or the result ");
            }
            return(url.GetUmbracoApiService <T>(umbracoApiControllerTypeCollection, method.Name)?.TrimEnd(method.Name));
        }
Example #21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FrontEndRoutes" /> class.
 /// </summary>
 public FrontEndRoutes(
     IOptions <GlobalSettings> globalSettings,
     IHostingEnvironment hostingEnvironment,
     IRuntimeState runtimeState,
     SurfaceControllerTypeCollection surfaceControllerTypeCollection,
     UmbracoApiControllerTypeCollection apiControllers)
 {
     _runtimeState = runtimeState;
     _surfaceControllerTypeCollection = surfaceControllerTypeCollection;
     _apiControllers     = apiControllers;
     _umbracoPathSegment = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);
 }
        public static string GetTreeUrl(this IUrlHelper urlHelper, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Type treeType, string nodeId, FormCollection?queryStrings)
        {
            var actionUrl = urlHelper.GetUmbracoApiService(umbracoApiControllerTypeCollection, "GetNodes", treeType)?
                            .EnsureEndsWith('?');

            //now we need to append the query strings
            actionUrl += "id=" + nodeId.EnsureEndsWith('&') + queryStrings?.ToQueryString("id",
                                                                                          //Always ignore the custom start node id when generating URLs for tree nodes since this is a custom once-only parameter
                                                                                          // that should only ever be used when requesting a tree to render (root), not a tree node
                                                                                          TreeQueryStringParameters.StartNodeId);
            return(actionUrl);
        }
Example #23
0
        //private readonly IUrlHelper _urlHelper;

        public ReviewsTreeNodesNotification(
            UmbracoApiControllerTypeCollection apiControllers,
            IUrlHelperFactory urlHelperFactory,
            IActionContextAccessor actionContextAccessor
            //IUrlHelper urlHelper
            )
        {
            _apiControllers        = apiControllers;
            _urlHelperFactory      = urlHelperFactory;
            _actionContextAccessor = actionContextAccessor;
            //_urlHelper = urlHelper;
        }
Example #24
0
 public MemberTypeTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     UmbracoTreeSearcher treeSearcher,
     IMemberTypeService memberTypeService,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, eventAggregator, memberTypeService)
 {
     _treeSearcher      = treeSearcher;
     _memberTypeService = memberTypeService;
 }
Example #25
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="BackOfficeAreaRoutes" /> class.
 /// </summary>
 public BackOfficeAreaRoutes(
     IOptions <GlobalSettings> globalSettings,
     IHostingEnvironment hostingEnvironment,
     IRuntimeState runtimeState,
     UmbracoApiControllerTypeCollection apiControllers)
 {
     _globalSettings     = globalSettings.Value;
     _hostingEnvironment = hostingEnvironment;
     _runtimeState       = runtimeState;
     _apiControllers     = apiControllers;
     _umbracoPathSegment = _globalSettings.GetUmbracoMvcArea(_hostingEnvironment);
 }
 protected MemberTypeAndGroupTreeControllerBase(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IEventAggregator eventAggregator)
     : this(
         localizedTextService,
         umbracoApiControllerTypeCollection,
         menuItemCollectionFactory,
         eventAggregator,
         StaticServiceProvider.Instance.GetRequiredService <IMemberTypeService>())
 {
 }
 public TemplatesTreeController(
     UmbracoTreeSearcher treeSearcher,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IFileService fileService,
     IEventAggregator eventAggregator
     ) : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _treeSearcher = treeSearcher;
     _menuItemCollectionFactory = menuItemCollectionFactory;
     _fileService = fileService;
 }
 public ContentBlueprintTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IContentService contentService,
     IContentTypeService contentTypeService,
     IEntityService entityService,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory));
     _contentService            = contentService ?? throw new ArgumentNullException(nameof(contentService));
     _contentTypeService        = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
     _entityService             = entityService ?? throw new ArgumentNullException(nameof(entityService));
 }
 public MemberTreeController(
     ILocalizedTextService localizedTextService,
     UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
     UmbracoTreeSearcher treeSearcher,
     IMenuItemCollectionFactory menuItemCollectionFactory,
     IMemberService memberService,
     IMemberTypeService memberTypeService,
     IBackOfficeSecurityAccessor backofficeSecurityAccessor,
     IEventAggregator eventAggregator)
     : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
 {
     _treeSearcher = treeSearcher;
     _menuItemCollectionFactory = menuItemCollectionFactory;
     _memberService = memberService;
     _memberTypeService = memberTypeService;
     _backofficeSecurityAccessor = backofficeSecurityAccessor;
 }
Example #30
0
        public static string?GetUmbracoApiService <T>(this IUrlHelper url, UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection, Expression <Func <T, object> > methodSelector)
            where T : UmbracoApiController
        {
            var method       = ExpressionHelper.GetMethodInfo(methodSelector);
            var methodParams = ExpressionHelper.GetMethodParams(methodSelector);

            if (method == null)
            {
                throw new MissingMethodException("Could not find the method " + methodSelector + " on type " + typeof(T) + " or the result ");
            }

            if (methodParams?.Any() == false)
            {
                return(url.GetUmbracoApiService <T>(umbracoApiControllerTypeCollection, method.Name));
            }
            return(url.GetUmbracoApiService <T>(umbracoApiControllerTypeCollection, method.Name, methodParams?.Values.First()));
        }