mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Added a a helper method to the runtime that merges env specific options with global ones
This commit is contained in:
		
							parent
							
								
									b7ecc97523
								
							
						
					
					
						commit
						dc48f19b26
					
				@ -229,6 +229,27 @@ class Runtime
 | 
				
			|||||||
        return $default;
 | 
					        return $default;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Shortcut to get the the configuration option for a specific environment and merge it with
 | 
				
			||||||
 | 
					     * the global one (environment specific overrides the global one if present).
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param      $key
 | 
				
			||||||
 | 
					     * @param null $defaultEnv
 | 
				
			||||||
 | 
					     * @param null $defaultConfig
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return array
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getMergedEnvAndConfigOption($key, $defaultEnv = null, $defaultConfig = null)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $userGlobalOptions = $this->getConfigOption($key, $defaultConfig);
 | 
				
			||||||
 | 
					        $userEnvOptions = $this->getEnvOption($key, $defaultEnv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return array_merge(
 | 
				
			||||||
 | 
					            (is_array($userGlobalOptions) ? $userGlobalOptions : []),
 | 
				
			||||||
 | 
					            (is_array($userEnvOptions) ? $userEnvOptions : [])
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Overwrites an Environment Configuration Option
 | 
					     * Overwrites an Environment Configuration Option
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -43,12 +43,9 @@ class AsseticDumpTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getOptions()
 | 
					    protected function getOptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
 | 
					 | 
				
			||||||
        $userEnvOptions = $this->runtime->getEnvOption('symfony', []);
 | 
					 | 
				
			||||||
        $options = array_merge(
 | 
					        $options = array_merge(
 | 
				
			||||||
            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
					            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
				
			||||||
            (is_array($userGlobalOptions) ? $userGlobalOptions : []),
 | 
					            $this->runtime->getMergedEnvAndConfigOption('symfony', [], []),
 | 
				
			||||||
            (is_array($userEnvOptions) ? $userEnvOptions : []),
 | 
					 | 
				
			||||||
            $this->options
 | 
					            $this->options
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -43,12 +43,9 @@ class AssetsInstallTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getOptions()
 | 
					    protected function getOptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
 | 
					 | 
				
			||||||
        $userEnvOptions = $this->runtime->getEnvOption('symfony', []);
 | 
					 | 
				
			||||||
        $options = array_merge(
 | 
					        $options = array_merge(
 | 
				
			||||||
            ['console' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
 | 
					            ['console' => 'bin/console', 'env' => 'dev', 'target' => 'web', 'flags' => '--symlink --relative'],
 | 
				
			||||||
            (is_array($userGlobalOptions) ? $userGlobalOptions : []),
 | 
					            $this->runtime->getMergedEnvAndConfigOption('symfony', [], []),
 | 
				
			||||||
            (is_array($userEnvOptions) ? $userEnvOptions : []),
 | 
					 | 
				
			||||||
            $this->options
 | 
					            $this->options
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -43,12 +43,9 @@ class CacheClearTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getOptions()
 | 
					    protected function getOptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
 | 
					 | 
				
			||||||
        $userEnvOptions = $this->runtime->getEnvOption('symfony', []);
 | 
					 | 
				
			||||||
        $options = array_merge(
 | 
					        $options = array_merge(
 | 
				
			||||||
            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
					            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
				
			||||||
            (is_array($userGlobalOptions) ? $userGlobalOptions : []),
 | 
					            $this->runtime->getMergedEnvAndConfigOption('symfony', [], []),
 | 
				
			||||||
            (is_array($userEnvOptions) ? $userEnvOptions : []),
 | 
					 | 
				
			||||||
            $this->options
 | 
					            $this->options
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -43,12 +43,9 @@ class CacheWarmupTask extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected function getOptions()
 | 
					    protected function getOptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $userGlobalOptions = $this->runtime->getConfigOption('symfony', []);
 | 
					 | 
				
			||||||
        $userEnvOptions = $this->runtime->getEnvOption('symfony', []);
 | 
					 | 
				
			||||||
        $options = array_merge(
 | 
					        $options = array_merge(
 | 
				
			||||||
            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
					            ['console' => 'bin/console', 'env' => 'dev', 'flags' => ''],
 | 
				
			||||||
            (is_array($userGlobalOptions) ? $userGlobalOptions : []),
 | 
					            $this->runtime->getMergedEnvAndConfigOption('symfony', [], []),
 | 
				
			||||||
            (is_array($userEnvOptions) ? $userEnvOptions : []),
 | 
					 | 
				
			||||||
            $this->options
 | 
					            $this->options
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user