How to add config in service symfony?

Viewed 779

I'm trying to study on how to create my own config and implement it in my services. I have this config.

sample_helper:
  admin:
    key: '45912565'
    secret: '2e6b9cd8a8cfe01418cassda3reseebafef9caaad0a7'

I successfully created this in my dependency injection using the cofiguration

private function addSampleConfiguration(ArrayNodeDefinition $node){
        $node->children()

            ->arrayNode("admin")
                ->children()
                    ->scalarNode('key')->end()
                    ->scalarNode('secret')->end()
                ->end()
            ->end()
         ->end();
    }

but in my services I want to get the key value and secret value.

class SampleService
{

    public function generateSample(){
       $key = ''; // key here from config
       $secret = ''; //secret from config;
    }
}

I try to read the documentation. but honestly I'm confuse on how to do it. I don't have any clue to begin.

1 Answers
Related