{"id":26234886,"url":"https://github.com/flowpack/neos-dimensionresolver","last_synced_at":"2025-04-22T14:52:29.459Z","repository":{"id":27671544,"uuid":"114769305","full_name":"Flowpack/neos-dimensionresolver","owner":"Flowpack","description":"A support package for Neos CMS that allows for arbitrary content dimension resolution.","archived":false,"fork":false,"pushed_at":"2024-07-03T07:01:58.000Z","size":85,"stargazers_count":7,"open_issues_count":2,"forks_count":9,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-09T09:04:03.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flowpack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-19T13:37:52.000Z","updated_at":"2024-07-03T06:45:45.000Z","dependencies_parsed_at":"2025-04-09T09:04:06.854Z","dependency_job_id":"c708e61c-8910-4afe-8677-750831567f4d","html_url":"https://github.com/Flowpack/neos-dimensionresolver","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowpack%2Fneos-dimensionresolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowpack%2Fneos-dimensionresolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowpack%2Fneos-dimensionresolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowpack%2Fneos-dimensionresolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flowpack","download_url":"https://codeload.github.com/Flowpack/neos-dimensionresolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250263570,"owners_count":21401914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-13T02:29:49.497Z","updated_at":"2025-04-22T14:52:29.452Z","avatar_url":"https://github.com/Flowpack.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flowpack Neos Content Dimension Resolver\n\n## Introduction\n\nFor a general overview over content dimension, please refer to the respective sections in the Neos manual.\n\nThis package enhances the default capabilities of detecting and linking to dimension presets by providing both new\nfeatures and extension points.\n\n### Installation\n\n```bash\ncomposer require flowpack/neos-dimensionresolver\n```\n\n### Dimension Configuration\n\nThe available dimensions and presets can be configured via settings:\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n\n      # Content dimension \"language\" serves for translation of content into different languages. Its value specifies\n      # the language or language variant by means of a locale.\n      'language':\n        # The default dimension that is applied when creating nodes without specifying a dimension\n        default: 'mul_ZZ'\n        # The default preset to use if no URI segment was given when resolving languages in the router\n        defaultPreset: 'all'\n        label: 'Language'\n        icon: 'icon-language'\n        presets:\n          'all':\n            label: 'All languages'\n            values: ['mul_ZZ']\n            resolutionValue: 'all'\n          # Example for additional languages:\n\n          'en_GB':\n            label: 'English (Great Britain)'\n            values: ['en_GB', 'en_ZZ', 'mul_ZZ']\n            resolutionValue: 'gb'\n          'de':\n            label: 'German (Germany)'\n            values: ['de_DE', 'de_ZZ', 'mul_ZZ']\n            resolutionValue: 'de'\n```\n\n**Note:**\nThe `uriSegment` configuration option provided by default via Neos is still supported but disencouraged.\n\n### Preset resolution\n\nUsing this package, content dimension presets can be resolved in different ways additional to the \"classic\" way of using an URI path segment.\nThus further configuration and implementation options have been added.\n\nThe dimension resolver comes with three basic `resolution modes` which can be combined arbitrarily and configured individually.\n\n### URI path segment based resolution\n\nThe default resolution mode is `uriPathSegment`. As by default in previous versions, it operates on an additional path segment,\ne.g. `https://domain.tld/{language}_{market}/home.html`. These are the configuration options available:\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n      'market':\n        resolution:\n          mode: 'uriPathSegment'\n          options:\n            # The offset defines the dimension's position in the path segment. Offset 1 means this is the second part.\n            # This allows for market being the second uriPath part although it's the primary dimension.\n            offset: 1\n      'language':\n        resolution:\n          mode: 'uriPathSegment'\n          options:\n            # Offset 0 means this is the first part.\n            offset: 0\nFlowpack:\n  Neos:\n    DimensionResolver:\n      contentDimensions:\n       resolution:\n         # Delimiter to separate values if multiple dimension are present\n         uriPathSegmentDelimiter: '-'\n```\n\nWith the given configuration, URIs will be resolved like `domain.tld/{language}-{market}/home.html`\n\n**Note:**\nAn arbitrary number of dimensions can be resolved via uriPathSegment.\nThe other way around, as long as no content dimensions resolved via uriPathSegment are defined, URIs will not contain any prefix.\n\nThe default preset can have an empty `resolutionValue` value. The following example will lead to URLs that do not contain\n`en` if the `en_US` preset is active, but will show the `resolutionValue` for other languages that are defined as well:\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n\n      'language':\n        label: 'Language'\n        icon: 'icon-language'\n        default: 'en_US'\n        defaultPreset: 'en_US'\n        resolution:\n          mode: 'uriPathSegment'\n        presets:\n          'en_US':\n            label: 'English (US)'\n            values: ['en_US']\n            resolutionValue: ''\n```\n\nThe only limitation is that all resolution values must be unique across all dimensions that are resolved via uriPathSegment.\nIf you need non-unique resolution values, you can switch support for non-empty dimensions off:\n\n```yaml\nNeos:\n  Neos:\n    routing:\n      supportEmptySegmentForDimensions: false\n```\n\n### Subdomain based resolution\n\nAnother resolution mode is ``subdomain``. This mode extracts information from the first part of the host and adds it respectively\nwhen generating URIs.\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n      'language':\n        default: 'en'\n        defaultPreset: 'en'\n        resolution:\n          mode: 'subdomain'\n          options:\n            # true means that if no preset can be detected, the default one will be used.\n            # Also when rendering new links, no subdomain will be added for the default preset\n            allowEmptyValue: true\n        presets:\n          'en_GB':\n            label: 'English'\n            values: ['en']\n            resolutionValue: 'en'\n          'de':\n            label: 'German (Germany)'\n            values: ['de_DE']\n            resolutionValue: 'de'\n```\n\nWith the given configuration, URIs will be resolved like `{language}.domain.tld/home.html`\n\n**Note:**\nOnly one dimension can be resolved via subdomain.\n\n### Top level domain based resolution\n\nThe final resolution mode is `topLevelDomain`. This modes extracts information from the last part of the host and adds it respectively\nwhen generating URIs.\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n      'market':\n        default: 'eu'\n        defaultPreset: 'eu'\n        resolution:\n          mode: 'topLevelDomain'\n        presets:\n          'EU':\n            label: 'European Union'\n            values: ['EU']\n            resolutionValue: 'eu'\n          'GB':\n            label: 'Great Britain'\n            values: ['GB']\n            resolutionValue: 'co.uk'\n          'DE':\n            label: 'Germany'\n            values: ['DE', 'EU']\n            resolutionValue: 'de'\n```\n\nWith the given configuration, URIs will be resolved like ``domain.{market}/home.html``\n\n**Note:**\nOnly one dimension can be resolved via top level domain.\n\n### Custom resolution\n\nThere are planned extension points in place to support custom implementations in case the basic ones do not suffice.\n\n#### Defining custom resolution components\n\nEach resolution mode is defined by two components: An implementation of `Neos\\Neos\\Http\\ContentDimensionDetection\\ContentDimensionPresetDetectorInterface`\nto extract the preset from an HTTP request and an implementation of `Neos\\Neos\\Http\\ContentDimensionLinking\\ContentDimensionPresetLinkProcessorInterface`\nfor post processing links matching the given dimension presets.\n\nThese can be implemented and configured individually per dimension:\n\n```yaml\nNeos:\n  ContentRepository:\n    contentDimensions:\n      weather:\n        detectionComponent:\n          implementationClassName: 'My\\Package\\Http\\ContentDimensionDetection\\WeatherDimensionPresetDetector'\n        linkProcessorComponent:\n          implementationClassName: 'My\\Package\\Http\\ContentDimensionLinking\\WeatherDimensionPresetLinkProcessor'\n```\n\nIf your custom preset resolution components do not affect the URI, you can use the ``Flowpack\\Neos\\DimensionResolver\\Http\\ContentDimensionLinking\\NullDimensionPresetLinkProcessor``\nimplementation as the link processor.\n\n**Note:**\n\nIf you want to replace implementations of one of the basic resolution modes, you can do it this way, too.\n\n#### Completely replacing resolution behaviour\n\nThe described configuration and extension points assume that all dimension presets can be resolved independently.\nThere may be more complex situations though, where the resolution of one dimension depends on the result of the resolution of another.\nAs an example, think of a subdomain (language) and top level domain (market) based scenario where you want to support ``domain.fr``,\n`domain.de`, `de.domain.ch`, `fr.domain.ch` and `it.domain.ch`. Although you can define the subdomain as optional,\nthe default language depends on the market: `domain.de` should be resolved to default language `de` and `domain.fr`\nshould be resolved to default language `fr`.\nThose complex scenarios are better served using individual implementations than complex configuration efforts.\n\nTo enable developers to deal with this in a nice way, there are predefined ways to deal with both detection and link processing.\n\nDetection is done via an HTTP middleware that can be replaced via configuration:\n\n```yaml\nNeos:\n  Flow:\n    http:\n      middlewares:\n        detectContentSubgraph:\n          middleware: Flowpack\\Neos\\DimensionResolver\\Http\\DetectContentSubgraphMiddleware\n```\n\nLink processing is done by the `Flowpack\\Neos\\DimensionResolver\\Http\\ContentSubgraphUriProcessorInterface`. To introduce your custom behaviour,\nimplement the interface and declare it in `Objects.yaml` as usual in Flow.\n\n**Note:**\nPlease refer to the default implementations for further hints and ideas on how to implement resolution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowpack%2Fneos-dimensionresolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflowpack%2Fneos-dimensionresolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflowpack%2Fneos-dimensionresolver/lists"}