From 6557f4d7b004815a0c0d8c3f24f02a522b9c582e Mon Sep 17 00:00:00 2001
From: Frederic Bauer <57102171+northernseacharting@users.noreply.github.com>
Date: Thu, 7 Jan 2021 16:46:59 +0100
Subject: [PATCH] Commit to 2.x version of the bundle based on the equivalent
commits to the 3.x version:
Commit concerns issues #5 and #6 ,#8 and #9
PHP:
- ConfigLocationOutputCommand.php: Added Symfony console command to display the configuration paths (as determined by the bundle) of the parameters.
- ProcessedConfigOutputCommand.php: Added styling to the command output to provide more information and feedback to the user and updated its documentation.
- ConfigProcessController.php: Removed unnecessary comments from the controller.
- CJWConfigProcessorExtension.php: Modified config so that the environmental variables are turned on by default.
- CustomParamProcessor.php: Small documentation fix.
Config:
- services.yml: Added new console command as Symfony service.
And the other commit:
PHP:
- ProcessedConfigOutputCommand.php: Added this new console command to enable the processed config to also be accessed via the console and not only the frontend of the bundle
- ConfigProcessController.php: Added the environmental parameters view route and controller action and fixed bug with the bundle config not working properly, when the favourites feature was turned off
- CJWConfigProcessorExtension.php and Configuration.php: Added new configuration for the environmental variable display
- LeftSideBarMenuBuilder.php: Added new left sidebar button to access the dedicated env view
- CustomParamProcessor.php: Added setter for the active site accesses to filter for to allow more dynamic work with the processor
Config:
- routing.yaml and services.yml: Added the env view as route and the console command as a service
Documentation:
Updates to the documentation across the board for more readability and more detailed information. Also added documentation for the new view
CSS:
- parameter_display.css: Small tweak for better display of inline values
Twig:
- param_view_environment.html.twig: Added dedicated template for env parameters view
---
Command/ConfigLocationOutputCommand.php | 122 ++++++++++++
Command/ProcessedConfigOutputCommand.php | 177 ++++++++++++++++++
Controller/ConfigProcessController.php | 31 ++-
.../CJWConfigProcessorExtension.php | 6 +
DependencyInjection/Configuration.php | 15 +-
EventSubscriber/LeftSideBarMenuBuilder.php | 16 +-
Resources/config/routing.yaml | 6 +
Resources/config/services.yml | 13 ++
Resources/doc/changelogs/CHANGELOG-2.x.md | 17 ++
Resources/doc/help/bundle_configuration.en.md | 46 ++++-
.../param_view_env_variables_overview.en.md | 113 +++++++++++
Resources/doc/index.md | 5 +-
.../doc/installation/2.x-Installation.en.md | 12 +-
.../doc/installation/3.x-Installation.en.md | 11 +-
.../public/assets/css/parameter_display.css | 1 +
.../full/param_view_environment.html.twig | 64 +++++++
.../CustomParamProcessor.php | 24 ++-
17 files changed, 655 insertions(+), 24 deletions(-)
create mode 100644 Command/ConfigLocationOutputCommand.php
create mode 100644 Command/ProcessedConfigOutputCommand.php
create mode 100644 Resources/doc/help/param_view_env_variables_overview.en.md
create mode 100644 Resources/views/full/param_view_environment.html.twig
diff --git a/Command/ConfigLocationOutputCommand.php b/Command/ConfigLocationOutputCommand.php
new file mode 100644
index 0000000..3bb3a8b
--- /dev/null
+++ b/Command/ConfigLocationOutputCommand.php
@@ -0,0 +1,122 @@
+setName(self::$defaultName)
+ ->setDescription("Displays the determined config paths (parameter origins) for the Symfony application.")
+ ->setHelp(<<<'EOD'
+This console command allows a user to access the a list of all paths (leading to files where config parameters have
+either been set or overwritten) for the configuration of the Symfony application the bundle was able to determine.
+The following options can be set for the command, but these are purely optional:
+--paramname or -p: If a specific parameter name is given (i.e. "ezsettings.default.api_keys"), only paths for that
+ specific parameter are displayed (excluding every other parametername). The name does have to be
+ exact and if the option is omitted, then every found path is displayed.
+To better read and format the output it is advised to pipe the output of this command to "LESS", if you are using an
+ubuntu operating system.
+Example: "php bin/console cjw:output-locations | less"
+Then you can scroll more easily through the output and the output is present in an other context that can be quitted
+with "q", so that the console is not spammed with the command output. Then you can also search something by typing "/"
+and then the search word + enter key.
+EOD
+ )
+ ->addOption(
+ "paramname",
+ "p",
+ InputOption::VALUE_OPTIONAL,
+ "Giving a parametername will filter the list for that specific parameter and only display paths belonging to that parameter",
+ false
+ );
+
+ }
+
+ /**
+ * @override
+ * Controls the command execution.
+ *
+ * @param InputInterface $input The input the user can provide to the command.
+ * @param OutputInterface $output Controls the output that is supposed to be written out to the user.
+ *
+ * @return int Returns the execution status code.
+ */
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $ioStyler = new SymfonyStyle($input, $output);
+ $filterParameters = $input->getOption("paramname");
+
+ if ($filterParameters) {
+ $parametersAndPaths = LocationRetrievalCoordinator::getParameterLocations($filterParameters);
+ } else {
+ $parametersAndPaths = LocationRetrievalCoordinator::getParametersAndLocations();
+ }
+
+ $ioStyler->note([
+ "This command will now run with the following options:",
+ "Parameter Filter: " . $filterParameters ?? "none",
+ ]);
+
+ if ($parametersAndPaths && $this->outputArray($output, $parametersAndPaths)) {
+ $ioStyler->newLine();
+ $ioStyler->success("Command ran successfully.");
+ } else {
+ $ioStyler->error("No parameters could be found for this option.");
+ }
+
+ return 0;
+ }
+
+ /**
+ * Builds the string output for the command. Handles hierarchical, multi dimensional arrays.
+ *
+ * @param OutputInterface $output The interface used to output the contents of the array.
+ * @param array $parameters The array to be output.
+ * @param int $indents The number of indents to be added in front of the output lines.
+ *
+ * @return bool Returns boolean stating whether parameters could successfully be found and output or not.
+ */
+ private function outputArray(OutputInterface $output, array $parameters, int $indents = 0): bool
+ {
+ if (count($parameters) === 0) {
+ return false;
+ }
+
+ foreach ($parameters as $key => $parameter) {
+ $key = str_pad($key, $indents + strlen($key), " ", STR_PAD_LEFT);
+
+ $output->write($key . ": ");
+ if (is_array($parameter)) {
+ if (count($parameter) > 0) {
+ $output->write(str_repeat(" ", $indents) . "\n");
+ $this->outputArray($output, $parameter, $indents + 4);
+ $output->write(str_repeat(" ", $indents) . "\n");
+ } else {
+ $output->writeln(" ");
+ }
+ } else {
+ $output->writeln($parameter);
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/Command/ProcessedConfigOutputCommand.php b/Command/ProcessedConfigOutputCommand.php
new file mode 100644
index 0000000..43c7105
--- /dev/null
+++ b/Command/ProcessedConfigOutputCommand.php
@@ -0,0 +1,177 @@
+customParameterProcessor = new CustomParamProcessor($symContainer);
+
+ parent::__construct();
+ }
+
+ /**
+ * @override
+ *
+ * Used to configure the command.
+ */
+ protected function configure()
+ {
+ $this
+ ->setName(self::$defaultName)
+ ->setDescription("Displays the processed config of the symfony application.")
+ ->setHelp(<<<'EOD'
+ This console command allows outputting the configuration made by the bundle to the console with a few options
+ that can be used to customize the output. The following options can be set, but they are purely optional:
+
+ --paramname or -p: If a specific parameter name or segment is given (i.e. "ezpublish" or "ezpublish.default.siteaccess"),
+ only the corresponding section of the processed configuration will be displayed. To input a specific
+ parameter name, simply add it after the option with a "=".
+ (i.e. "php bin/console cjw:output-config --paramname=param_name").
+
+ --siteaccess-context or -s:
+ To specify a specific site access context under which to view the parameter, simply add the context after
+ the option itself (i.e. "-s admin")
+
+ If the site access and the parameter name option are given at the same time, the filtered and narrowed list will be
+ viewed under site access context (not the complete list).
+
+ To better read and format the output it is advised to pipe the output of this command to "LESS", if you are using an
+ ubuntu operating system.
+
+ Example: "php bin/console cjw:output-config | less"
+
+ Then you can scroll more easily through the output and the output is present in an other context that can be quitted
+ with "q", so that the console is not spammed with the command output. Then you can also search something by typing "/"
+ and then the search word + enter key.
+ EOD
+ )
+ // TODO: Turn paramname into an array, so that multiple branches can be filtered for.
+ ->addOption(
+ "paramname",
+ "p",
+ InputOption::VALUE_OPTIONAL,
+ "Narrow the list down to a specific branch or parameter. Simply state the parameter key or segment to filter for.",
+ false,
+ )
+ ->addOption(
+ "siteaccess-context",
+ "s",
+ InputOption::VALUE_OPTIONAL,
+ "Define the site access context under which the config should be displayed.",
+ false,
+ );
+ }
+
+ /**
+ * @override
+ * Controls the commands execution.
+ *
+ * @param InputInterface $input The input the user can provide to the command.
+ * @param OutputInterface $output Controls the output that is supposed to be written out to the user.
+ *
+ * @return int Returns the execution status code.
+ *
+ * @throws InvalidArgumentException
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $ioStyler = new SymfonyStyle($input, $output);
+ $siteAccessContext = $input->getOption("siteaccess-context");
+ $filterParameters = $input->getOption("paramname");
+
+ $processedParameters = ConfigProcessCoordinator::getProcessedParameters();
+
+ if ($filterParameters) {
+ $processedParameters = $this->customParameterProcessor->getCustomParameters([$filterParameters], $processedParameters);
+ }
+
+ if ($siteAccessContext) {
+ $siteAccess = $siteAccessContext;
+
+ if (!$filterParameters) {
+ $processedParameters = ConfigProcessCoordinator::getParametersForSiteAccess($siteAccess);
+ } else {
+ $siteAccess = ConfigProcessCoordinator::getSiteAccessListForController($siteAccess);
+ $this->customParameterProcessor->setSiteAccessList($siteAccess);
+ $processedParameters = $this->customParameterProcessor->scanAndEditForSiteAccessDependency($processedParameters);
+ }
+ }
+
+ $ioStyler->note([
+ "The command will run with the following options:",
+ "SiteAccess: ". $siteAccessContext,
+ "Parameter filter: ". $filterParameters,
+ ]);
+
+ if ($processedParameters && $this->outputArray($output,$processedParameters)) {
+ $ioStyler->success("Command ran successfully.");
+ } else {
+ $ioStyler->error("No parameters could be found for these options.");
+ }
+
+ return 0;
+ }
+
+ /**
+ * Builds the string output for the command. Handles hierarchical, multi dimensional arrays.
+ *
+ * @param OutputInterface $output The interface used to output the contents of the array.
+ * @param array $parameters The array to be output.
+ * @param int $indents The number of indents to be added in front of the output lines.
+ *
+ * @return bool Returns boolean stating whether parameters could successfully be found and output or not.
+ */
+ private function outputArray(OutputInterface $output, array $parameters, $indents = 0)
+ {
+ if (count($parameters) === 0) {
+ return false;
+ }
+
+ foreach ($parameters as $key => $parameter) {
+ $key = str_pad($key,$indents+strlen($key), " ", STR_PAD_LEFT);
+
+ $output->write($key.": ");
+ if (is_array($parameter)) {
+ if ( count($parameter) > 0) {
+ $output->write(str_repeat(" ", $indents)."\n");
+ $this->outputArray($output,$parameter, $indents+4);
+ $output->write(str_repeat(" ", $indents)."\n");
+ } else {
+ $output->writeln(" ");
+ }
+ } else {
+ $output->writeln($parameter);
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/Controller/ConfigProcessController.php b/Controller/ConfigProcessController.php
index 81874e4..0928a7f 100644
--- a/Controller/ConfigProcessController.php
+++ b/Controller/ConfigProcessController.php
@@ -45,13 +45,7 @@ public function __construct (ContainerInterface $symContainer, ConfigResolverInt
{
$this->container = $symContainer;
ConfigProcessCoordinator::initializeCoordinator($symContainer,$ezConfigResolver,$symRequestStack);
-
- if (
- $this->container->getParameter("cjw.favourite_parameters.allow") === true ||
- $this->container->getParameter("cjw.custom_site_access_parameters.active") === true
- ) {
- FavouritesParamCoordinator::initialize($this->container);
- }
+ FavouritesParamCoordinator::initialize($this->container);
$this->showFavouritesOutsideDedicatedView =
$this->container->getParameter("cjw.favourite_parameters.display_everywhere");
@@ -372,6 +366,29 @@ public function downloadParameterListAsTextFile($downloadDescriptor): BinaryFile
return $response;
}
+ public function getEnvironmentalVariables ()
+ {
+ try {
+ $lastUpdated = ConfigProcessCoordinator::getTimeOfLastUpdate();
+
+ $envVar = [];
+
+ if ($this->container->getParameter("cjw.env_variables.allow") === true) {
+ $envVar = $_ENV;
+ }
+
+ return $this->render(
+ "@CJWConfigProcessor/full/param_view_environment.html.twig",
+ [
+ "parameterList" => $envVar,
+ "lastUpdated" => $lastUpdated,
+ ]
+ );
+ } catch (Exception $error) {
+ throw new HttpException(500, "Something went wrong while trying to gather the required parameters.");
+ }
+ }
+
/**
* Helper function to determine the specific parameters for both given site access contexts at the same time.
* It returns the found parameters in an array in which the first entry marks all the parameters for the first
diff --git a/DependencyInjection/CJWConfigProcessorExtension.php b/DependencyInjection/CJWConfigProcessorExtension.php
index 3e8c9cc..97e3996 100644
--- a/DependencyInjection/CJWConfigProcessorExtension.php
+++ b/DependencyInjection/CJWConfigProcessorExtension.php
@@ -32,6 +32,12 @@ public function load(array $configs, ContainerBuilder $container)
$this->handleCustomParamConfig($config, $container);
$this->handleFavouriteParamConfig($config, $container);
+
+ if (isset($config["env_variables"]["allow"])) {
+ $container->setParameter("cjw.env_variables.allow",$config["env_variables"]["allow"]);
+ } else {
+ $container->setParameter("cjw.env_variables.allow", true);
+ }
}
/**
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 3ba3db3..9cdc68e 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -21,8 +21,10 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->arrayNode("custom_site_access_parameters")
+ ->info("For configuring the custom parameters to be added to the site access view")
->children()
->booleanNode("allow")
+ ->info("Describes whether custom parameters are allowed and active in the bundle or not.")
->defaultFalse()
->end()
->booleanNode("scan_parameters")
@@ -41,11 +43,11 @@ public function getConfigTreeBuilder()
->info("Handles all things regarding favourite parameters.")
->children()
->booleanNode("allow")
- ->info("Are favourite parameters allowed or shouldn't there be any mechanisms for it.")
+ ->info("Configures whether favourite parameters are allowed at all.")
->defaultFalse()
->end()
->booleanNode("display_everywhere")
- ->info("Should the favourites be displayed outside of the dedicated view too or not.")
+ ->info("Describes whether the favourites should be displayed outside of their dedicated view, currently of no use.")
->defaultFalse()
->end()
->booleanNode("scan_parameters")
@@ -61,6 +63,15 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
+ ->arrayNode("env_variables")
+ ->info("For configuring the environment variable display")
+ ->children()
+ ->booleanNode("allow")
+ ->info("Determines whether the feature is enabled in the bundle or not.")
+ ->defaultTrue()
+ ->end()
+ ->end()
+ ->end()
->end();
return $treeBuilder;
diff --git a/EventSubscriber/LeftSideBarMenuBuilder.php b/EventSubscriber/LeftSideBarMenuBuilder.php
index 8adbf58..3c492dc 100644
--- a/EventSubscriber/LeftSideBarMenuBuilder.php
+++ b/EventSubscriber/LeftSideBarMenuBuilder.php
@@ -21,9 +21,10 @@ class LeftSideBarMenuBuilder extends AbstractBuilder implements TranslationConta
{
/* Menu items */
- const ITEM__PARAMETERLIST = 'All Parameters';
+ const ITEM__PARAMETER_LIST = 'All Parameters';
const ITEM__PARAMETER_LIST_SITE_ACCESS = 'Site Access Parameters';
const ITEM__PARAMETER_LIST_FAVOURITES = 'Favourite Parameters';
+ const ITEM__PARAMETER_LIST_ENV = "Environmental Parameters";
public function __construct(MenuItemFactory $factory, EventDispatcherInterface $eventDispatcher)
{
@@ -57,8 +58,8 @@ protected function createStructure(array $options): ItemInterface
"extras" => ["icon" => "view-list"],
]
),
- self::ITEM__PARAMETERLIST => $this->createMenuItem(
- self::ITEM__PARAMETERLIST,
+ self::ITEM__PARAMETER_LIST => $this->createMenuItem(
+ self::ITEM__PARAMETER_LIST,
[
"route" => "cjw_config_processing.param_list",
"extras" => ["icon" => "list"],
@@ -71,6 +72,13 @@ protected function createStructure(array $options): ItemInterface
"extras" => ["icon" => "bookmark-manager"],
]
),
+ self::ITEM__PARAMETER_LIST_ENV => $this->createMenuItem(
+ self::ITEM__PARAMETER_LIST_ENV,
+ [
+ "route" => "cjw_config_processing.param_list_environmental",
+ "extras" => ["icon" => "contentlist"],
+ ]
+ ),
];
$menu->setChildren($menuItems);
@@ -85,7 +93,7 @@ protected function createStructure(array $options): ItemInterface
public static function getTranslationMessages()
{
return [
- (new Message(self::ITEM__PARAMETERLIST,"menu"))->setDesc("Parameter List"),
+ (new Message(self::ITEM__PARAMETER_LIST,"menu"))->setDesc("Parameter List"),
(new Message(self::ITEM__PARAMETER_LIST_SITE_ACCESS, "menu"))->setDesc("Parameter List Site Access")
];
}
diff --git a/Resources/config/routing.yaml b/Resources/config/routing.yaml
index 1d29efe..6f2aab9 100644
--- a/Resources/config/routing.yaml
+++ b/Resources/config/routing.yaml
@@ -55,6 +55,12 @@ cjw_config_processing.download_parameters:
_controller: cjw_config_processor.controller:downloadParameterListAsTextFile
_methods: [GET]
+cjw_config_processing.param_list_environmental:
+ path: /cjw/config-processing/parameter_list/environmental
+ defaults:
+ _controller: cjw_config_processor.controller:getEnvironmentalVariables
+ _methods: [GET]
+
# Location Retrieval from different controller:
cjw_config_processing.location_retrieval:
path: /cjw/config-processing/parameter_locations/{parameter}/{withSiteAccess}
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index 63666e1..8c303db 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -48,3 +48,16 @@ services:
public: true
tags:
- { name: knp_menu.menu_builder, method: build, alias: cjw_config_processing.menu.site_access_comparison.sidebar_right }
+
+ # console commands
+ cjw_config_processing.command.output_config:
+ class: CJW\CJWConfigProcessor\Command\ProcessedConfigOutputCommand
+ arguments :
+ [ "@service_container", "@ezpublish.config.resolver", "@request_stack" ]
+ tags:
+ - { name: console.command }
+
+ cjw_config_processing.command.output_locations :
+ class : CJW\CJWConfigProcessor\Command\ConfigLocationOutputCommand
+ tags :
+ - { name : console.command }
diff --git a/Resources/doc/changelogs/CHANGELOG-2.x.md b/Resources/doc/changelogs/CHANGELOG-2.x.md
index 4e5dff7..8f9e6c0 100644
--- a/Resources/doc/changelogs/CHANGELOG-2.x.md
+++ b/Resources/doc/changelogs/CHANGELOG-2.x.md
@@ -1,5 +1,22 @@
# CJW-Network ConfigProcessor Bundle 2.x changelog
+## 2.1.0 (xx.01.2020)
+
+* Added Symfony console command to display the processed configuration in the console. This command
+ also allows the user to specify site access context and / or filter the parameters for specific
+ subtrees to customize the command execution and output.
+
+* Fixed error, where when turning off the favourite feature, an error would be thrown in the bundle.
+
+* Updated documentation.
+
+* Added display of environmental parameters, and their values in a dedicated view.
+
+* Added additional configuration for the new feature.
+
+* Updated CustomParamProcessor to allow more dynamic setting of the site access to filter for with the
+ custom parameters.
+
## 2.0.1 (xx.12.2020)
* Adapted the custom kernel boot process to make the location retrieval functionality
diff --git a/Resources/doc/help/bundle_configuration.en.md b/Resources/doc/help/bundle_configuration.en.md
index 03bbcda..918d520 100644
--- a/Resources/doc/help/bundle_configuration.en.md
+++ b/Resources/doc/help/bundle_configuration.en.md
@@ -3,12 +3,14 @@
This file is supposed to deliver a detailed look at how to configure the bundle via
yaml settings.
+-----
## Purpose of the config
As with many bundles for the Symfony framework, it is possible to configure a few
behaviours of the bundle to your liking via specific configuration made in a yaml file
in the config directory of your installation.
+-----
## Configuration Overview
```yaml
@@ -30,6 +32,9 @@ cjw_config_processor:
- "parameter2.broader"
- "parameter3"
- "parameter2.others"
+
+ env_variables:
+ allow: true
```
The above settings are the complete set of possible settings for the bundle. It is
@@ -43,6 +48,7 @@ cjw_config_processor:
This first line however does not require more in depth discussion as it simply serves as
the identifier for Symfony to signal that the following lines should be given to the bundle.
+-----
### The "Custom Site Access Parameters"
The purpose of the custom site access parameters is to allow the potential user of the bundle
@@ -96,7 +102,7 @@ them in addition to the specific site access parameters.
parameters:
- "parameter1"
- "parameter2.with.more.parts"
- - "parameter3.parts"
+ - "parameter3.parts"
```
This option marks the actual heart of the feature: Everything listed under this key
@@ -113,7 +119,7 @@ them in addition to the specific site access parameters.
```yaml
parameters:
- - "ezdesign"
+ - "ezdesign"
# This is the top most level of the parameter tree, as a result the entire "ezdesign" tree will be added
```
@@ -143,6 +149,7 @@ them in addition to the specific site access parameters.
**If the user adds paths or keys that don't exist in the configuration of your Symfony
application, then they will be ignored. So make sure to provide valid and correct paths.**
+-----
### "Favourite Parameters"
The purpose of this option is to allow the user of the bundle to **filter the list of parameters**
@@ -220,7 +227,7 @@ context.
```yaml
parameters:
- - "ezdesign"
+ - "ezdesign"
# This is the top most level of the parameter tree, as a result the entire "ezdesign" tree will be added
```
@@ -249,3 +256,36 @@ context.
**If the user adds paths or keys that don't exist in the configuration of your Symfony
application, then they will be ignored. So make sure to provide valid and correct paths.**
+
+-----
+### "Environmental Variables"
+
+The purpose of this view is to display the environmental parameters, which are typically "hidden" in
+a standard Symfony in a more convenient way, since they often feature configuration for the application.
+
+Since this configuration might contain sensitive information, or the user simply does not require it
+to be visible, the bundle offers a way to disable that information.
+
+* env variables:
+
+ ```yaml
+ env_variables:
+ ```
+
+ This line simply signals that the configuration following it, will concern the environment
+ variables display feature of the bundle. The rest of the following configuration must follow
+ that upper key.
+
+* allow:
+
+ ```yaml
+ allow: true
+ ```
+
+ This option is used to turn the feature on or off. As a result, it can be set to either `true`
+ or `false`.
+
+ * `True` - Setting the option to true will enable the feature, and the variables will be visible #
+ in their dedicated view. This is the standard value of the option.
+ * `False` - Setting the option to false will turn the feature off and although the dedicated view
+ will still be accessible, it will remain empty.
diff --git a/Resources/doc/help/param_view_env_variables_overview.en.md b/Resources/doc/help/param_view_env_variables_overview.en.md
new file mode 100644
index 0000000..a62a67f
--- /dev/null
+++ b/Resources/doc/help/param_view_env_variables_overview.en.md
@@ -0,0 +1,113 @@
+# Help Pages: Environmental Variable Display
+
+This file is supposed to provide an overview over the
+`Environmental Parameters` - view.
+
+## Use of the ENV parameters
+
+In Symfony there is the option to actively employ environmental parameters in yaml
+files by wrapping them in `%` and writing the name of the parameter in lower case.
+
+Example:
+
+```yaml
+# This retrieves the environmental "CACHE_POOL" for the yaml file
+test:
+ cache_pool: %cache_pool%
+```
+
+The parameters cannot always be called one to one by their `ENV`-name. Sometimes their
+name is shortened by removing a part of the original name. Symfony does provide proper help
+in error messages, should the name not be entirely correct.
+
+## Page Overview
+
+Since there is not a lot of functionality on this page, and it serves a very limited purpose,
+there will only be a verbal description of the page.
+
+The page contains:
+* (1) The typical header of the page, with its info texts, breadcrumbs and
+ help teaser lines.
+
+* (2) The left side menu with its buttons leading to other views.
+
+* (3) The param list header with a heading, the searchbar and the "global open subtree"-button
+
+* (4) The actual list of parameters
+
+## Elements:
+
+The parameters in this view differ from the ones in other views of the bundle frontend
+in that they do not typically feature nesting values, which eliminates a lot of the typical
+functionality in these views. On top of that, they do not posses a path origin in the bundle's
+list, since they are not typical container parameters of Symfony, and they cannot be favoured,
+since they are not like the other parameters.
+
+1. **The View-Header**:
+ The View-Header is the uppermost, changing element on the page. It contains 3
+ important items (from top to bottom):
+
+ 1. **The path**: The topmost element contains a rough overview of where you are
+ in the frontend of the bundle (here: `Admin > CJW Config Processing > Environmental Parameterlist`)
+
+ 2. **The headline**: It is the biggest element in the header, and it states what view
+ or tab you are looking at in the bundle
+
+ 3. **Last update**: This element shows you when the displayed parameters have last been updated,
+ meaning, if you updated the config, but the additions do not show up, it could be
+ due to you looking at an outdated version of the page (refresh the page in that case)
+
+ 4. **Help Teaser**:
+ This is a short introductory sentence, meant to provide a quick overview over what
+ the current view is for. At the right end of the teaser, the `show help` - button
+ resides, which, when clicked, opens this help file in an overlay.
+
+2. **The Left Sidebar Menu**:
+ 1. **Site Access Parameters**:
+ This is a button on the left sidebar menu. If clicked, the user will be taken to the
+ parameter view for the site access specific parameters.
+
+ 2. **All Parameters**:
+ Another button on the left sidebar menu, which, when clicked, brings the user to a view
+ of all parameters of the symfony application (without site access limitations).
+
+ 3. **Favourite Parameters**:
+ Is a button on the left sidebar menu, which, when clicked, takes the user to the
+ view dedicated to the parameters marked as favourites by the user and is the view discussed in
+ this help. (This view only contains parameters, when the feature is enabled (check the bundle config)).
+
+ 4. **Environmental Parameters**:
+ Is a button, which, when clicked, takes the user to an overview of all environmental variables
+ and their value, as they are known to the server. This is also the current view.
+
+3. **List-Header**:
+ The list-header may vary depending on the view, but it typically contains a headline,
+ which describes the beginning of the actual parameter-list and also global utility buttons.
+
+ 1. **Searchbar**:
+ The searchbar allows a user to search for specific keys (or values, depending on the current
+ `searchmode`). Simply enter text into the search-field and wait a short moment, as
+ there is a small delay between your input, and the search starting, and then you
+ should start seeing the results of your search.
+
+ 1. Next to the search-field itself, there is a button on the far right within the bar,
+ clicking the button, will switch the search mode from key search to value search and vice
+ versa.
+ 2. Another button will appear, when input is entered into the searchbar: An `X`. Clicking
+ this button will clear the search input and reset the search.
+ 3. `search-mode`: The search mode dictates how the input search text is being handled:
+ If the key search is active (default mode, indicated by a blue outline around the searchbar when in focus),
+ only keys are searched, which fit the given search text. If the value search is active
+ (indicated by a green outline around the bar), only values will be searched which match the
+ given search input.
+
+ 2. **Global Open Subtree Button**:
+ This button does not really serve any purpose in this view at the moment.
+
+4. **List of Parameters**:
+ The Parameterlist is simply a list of parameters (in this case only environmental variables and their values).
+
+ 1. Example of a **Parameter (inline value)**:
+ Similar to the parameter keys generally, this example includes the visual representation of a parameter key, but
+ contrary to that, there is also a value (green colour) on the same line. Due to the key
+ featuring a value right afterwards, it provides no `utility buttons` in this list.
diff --git a/Resources/doc/index.md b/Resources/doc/index.md
index e386d30..5cfd4e1 100644
--- a/Resources/doc/index.md
+++ b/Resources/doc/index.md
@@ -13,7 +13,7 @@ English versions:
* [Configure the ConfigProcessor](../help/bundle_configuration.en.md)
-## Bundle View - Overview Pages:
+## Bundle View – Overview Pages:
English versions:
@@ -21,8 +21,9 @@ English versions:
* [Favourite Parameters View](./help/param_view_favourites_overview.en.md)
* [Site Access Parameters View](./help/param_view_siteaccess_overview.en.md)
* [Site Access Comparison View](./help/param_view_siteaccess_compare_overview.en.md)
+* [Environmental Variables View](./help/param_view_env_variables_overview.en.md)
-## Bundle View - In Depth Pages:
+## Bundle View – In Depth Pages:
English versions:
diff --git a/Resources/doc/installation/2.x-Installation.en.md b/Resources/doc/installation/2.x-Installation.en.md
index 2c25657..3558ecc 100644
--- a/Resources/doc/installation/2.x-Installation.en.md
+++ b/Resources/doc/installation/2.x-Installation.en.md
@@ -1,5 +1,6 @@
# Installing CJW ConfigProcessor Bundle for Ibexa Platform 2.x
+-----
## Versions
The bundle loosely follows the eZ / Ibexa platform version number to signify
@@ -36,6 +37,7 @@ The Symfony Kernel of your installation must not be final, since a substantial p
location retrieval process builds upon that kernel and extends it. That means, that the `app/AppKernel.php`
class must be publicly available.
+-----
## Routing
Afterwards, you need to add the following content to your `app/config/routing.yaml` file:
@@ -44,11 +46,11 @@ Afterwards, you need to add the following content to your `app/config/routing.ya
# app/config/routing.yml
#...
cjw_config_processor_bundle:
- resource: "@CJWConfigProcessorBundle/Resources/config/routing.yaml"
+ resource: "@CJWConfigProcessorBundle/Resources/config/routing.yaml"
```
-## Required Bundle Config
-
+-----
+## Optional Bundle Config
**For more info on how to configure and customize the behaviour of the bundle check:
[Configure the ConfigProcessor](../help/bundle_configuration.en.md)**
@@ -72,6 +74,9 @@ cjw_config_processor:
scan_parameters: true
parameters:
- "user.defined.parameters"
+
+ env_variables:
+ allow: true
```
If you did create a new file, name the file however you like, for example `cjw_config_processor.yaml`.
@@ -83,6 +88,7 @@ import:
- { resource: } # If you named it "cjw_config_processor.yaml", then write that name there
```
+-----
## Assets
Since it may happen, that composer does not automatically install the assets of this bundle after
diff --git a/Resources/doc/installation/3.x-Installation.en.md b/Resources/doc/installation/3.x-Installation.en.md
index 4b2e361..497eae8 100644
--- a/Resources/doc/installation/3.x-Installation.en.md
+++ b/Resources/doc/installation/3.x-Installation.en.md
@@ -1,11 +1,13 @@
# Installing CJW ConfigProcessor Bundle for Ibexa Platform 3.x
+-----
## Versions
The bundle loosely follows the eZ / Ibexa platform version number to signify
compatibility. This means, that version 3.x of the bundle is going to be compatible
with version 3.x of the platform, version 2.x of the bundle with platform 2.x etc.
+-----
## Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
@@ -14,6 +16,7 @@ Open a command console, enter your project directory and execute:
$ composer require cjw-network/cjw-config-processor:3.*
```
+-----
## Applications that don't use Symfony Flex
### Step 1: Download the Bundle
@@ -52,6 +55,7 @@ The Symfony Kernel of your installation must not be final, since a substantial p
location retrieval process builds upon that kernel and extends it. That means, that the `src/Kernel.php`
class must be publicly available.
+-----
## Routing
Afterwards, you need to add a yaml file to your `config/routes` directory.
@@ -60,9 +64,10 @@ the following content:
```yaml
cjw_config_processor_bundle:
- resource: "@CJWConfigProcessorBundle/Resources/config/routing.yaml"
+ resource: "@CJWConfigProcessorBundle/Resources/config/routing.yaml"
```
+-----
## Additional Bundle Config
**For more info on how to configure and customize the behaviour of the bundle check:
@@ -88,8 +93,12 @@ cjw_config_processor:
scan_parameters: true
parameters:
- "user.defined.parameters"
+
+ env_variables:
+ allow: true
```
+-----
## Assets
Since it may happen, that composer does not automatically install the assets of this bundle after
diff --git a/Resources/public/assets/css/parameter_display.css b/Resources/public/assets/css/parameter_display.css
index d5a6b6b..db96890 100644
--- a/Resources/public/assets/css/parameter_display.css
+++ b/Resources/public/assets/css/parameter_display.css
@@ -39,6 +39,7 @@
margin-bottom: 4px;
text-indent: 20px;
color: green;
+ word-break: break-word;
}
.param_list_values:not(.inline_value):hover {
diff --git a/Resources/views/full/param_view_environment.html.twig b/Resources/views/full/param_view_environment.html.twig
new file mode 100644
index 0000000..cb9ef79
--- /dev/null
+++ b/Resources/views/full/param_view_environment.html.twig
@@ -0,0 +1,64 @@
+{% extends "@CJWConfigProcessor/pagelayout.html.twig" %}
+
+{% block line_template_stylesheets %}
+
+{% endblock %}
+
+{% block child_help_text %}
+ {% set locale = app.request.getLocale() %}
+ {% set context = "param_view_env_variables_overview" %}
+ {{ getHelpText(context, locale)|raw }}
+{% endblock %}
+
+{% block param_breadcrumbs %}
+
+{% endblock %}
+
+{% block help_teaser %}
+
+ Shows env-variables of the server. Can be used in yaml with for example: %cache_pool%.
+ {{ parent() }}
+
+{% endblock %}
+
+{% block param_content %}
+
+
+ {% include '@CJWConfigProcessor/line/recursive_param_resolution/_recursive_param_resolver.html.twig' ignore missing with {"parameters" : parameterList} only %}
+
+{% endblock %}
+
+{% block line_template_javascripts %}
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/src/ConfigProcessorBundle/CustomParamProcessor.php b/src/ConfigProcessorBundle/CustomParamProcessor.php
index ec486b2..34553c8 100644
--- a/src/ConfigProcessorBundle/CustomParamProcessor.php
+++ b/src/ConfigProcessorBundle/CustomParamProcessor.php
@@ -4,6 +4,7 @@
namespace CJW\CJWConfigProcessor\src\ConfigProcessorBundle;
+use Exception;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -38,6 +39,19 @@ public function __construct(ContainerInterface $symContainer = null, array $site
}
}
+ /**
+ * Allows the site access list for which to potentially filter the parameters to be set after constructing the
+ * class.
+ *
+ * @param array $siteAccessList The list of site accesses to filter to be set as filters.
+ */
+ public function setSiteAccessList (array $siteAccessList)
+ {
+ if (count($siteAccessList) > 0) {
+ $this->currentActiveSiteAccessList = $siteAccessList;
+ }
+ }
+
/**
* Build and returns a list of custom parameters (in the format the rest of the processed parameters is in) based
* on the given list of parameter keys.
@@ -74,7 +88,7 @@ public function getCustomParameters (array $customParameterKeys, array $processe
/**
* Takes a list of parameter keys (as strings) and checks them for any potential site access segments within the
- * keys. If such segments are found, then the parameter and that segment will be redone for every possible
+ * keys. If such segments are found, then the parameter and that segment will be recreated for every possible
* site access of the installation and added to the original list of keys.
*
* @param array $keysToBeProcessed Array of (string) keys of parameters.
@@ -119,14 +133,20 @@ public function replacePotentialSiteAccessParts (array $keysToBeProcessed)
*
* Example: When searching for test.admin.parameter, there might not be a value for site access admin, then it could
* be set under default, global, admin_group or any other site access from that hierarchy and so the value of
- * the highest site access in that hierarchy is determined (global before any other, then the group and lasty default)
+ * the highest site access in that hierarchy is determined (global before any other, then the group and lastly default)
*
* @param array $parametersToBeProcessed Associative, hierarchical array of parameter keys for which to determine the values.
*
* @return array Returns the resulting parameter array after the separate site access processing operation.
+ *
+ * @throws Exception Throws an exception, when trying to filter without any site accesses to filter for.
*/
public function scanAndEditForSiteAccessDependency (array $parametersToBeProcessed)
{
+ if (count($this->currentActiveSiteAccessList) === 0) {
+ throw new Exception("Cannot filter parameter list for site accesses, because no site accesses to filter for have been given.");
+ }
+
// First determine which of the given parameters might be site access dependent and store them in a separate array.
$possiblySiteAccessDependentParameters =
$this->getAllPossiblySiteAccessDependentParameters($parametersToBeProcessed);