Initial commit
This commit is contained in:
18
src/Greeting.php
Normal file
18
src/Greeting.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\ExampleBundle;
|
||||
|
||||
final class Greeting
|
||||
{
|
||||
public function __construct(private string $name)
|
||||
{
|
||||
}
|
||||
|
||||
public function greetPerson(): string
|
||||
{
|
||||
return sprintf("Hello there %s! Hope you're well.", $this->name);
|
||||
}
|
||||
}
|
||||
|
||||
50
src/PcmExampleBundle.php
Normal file
50
src/PcmExampleBundle.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\ExampleBundle;
|
||||
|
||||
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
|
||||
|
||||
/**
|
||||
* This class represents the bundle.
|
||||
*/
|
||||
final class PcmExampleBundle extends AbstractBundle
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
|
||||
{
|
||||
/**
|
||||
* Load the services defined in services.yaml into the container.
|
||||
*/
|
||||
$container->import('../config/services.yaml');
|
||||
|
||||
/**
|
||||
* The "$config" variable contains an array representing the
|
||||
* configuration and it's values.
|
||||
*
|
||||
* We can use it to configure the service container, for example
|
||||
* by passing in arguments to any services we have defined.
|
||||
*
|
||||
* (see services.yaml)
|
||||
*/
|
||||
$container->services()
|
||||
->get('pcm_example.greeting')
|
||||
->arg('$name', $config['name'])
|
||||
;
|
||||
}
|
||||
|
||||
public function configure(DefinitionConfigurator $definition): void
|
||||
{
|
||||
/**
|
||||
* Import the config definition (see definition.php).
|
||||
*/
|
||||
$definition->import('../config/definition.php');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user