Skip to content

Commit 3f4281a

Browse files
committed
Added test structure for this project
1 parent dad30cd commit 3f4281a

4 files changed

Lines changed: 90 additions & 0 deletions

File tree

src/ApiTrackerBundle.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the ApiTrackerBundle package.
5+
*
6+
* (c) Goatform
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Goatform\ApiTracker\Bundle;
13+
14+
use Goatform\ApiTracker\Bundle\DependencyInjection\ApiTrackerBundleExtension;
15+
16+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
17+
use Symfony\Component\HttpKernel\Bundle\Bundle;
18+
19+
class ApiTrackerBundle extends Bundle
20+
{
21+
public function getContainerExtension(): ExtensionInterface
22+
{
23+
return new ApiTrackerBundleExtension();
24+
}
25+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Goatform\ApiTracker\Bundle\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\DependencyInjection\Extension\Extension;
7+
8+
use Symfony\Component\Config\FileLocator;
9+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
10+
11+
class ApiTrackerBundleExtension extends Extension
12+
{
13+
public function load(array $configs, ContainerBuilder $container)
14+
{
15+
$configuration = $this->getConfiguration($configs, $container);
16+
$config = $this->processConfiguration($configuration, $configs);
17+
18+
$loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config'));
19+
$loader->load('goatform_api_tracker_bundle.yaml');
20+
21+
$container->setParameter('goatform_api_tracker_bundle.api_url', $config['api_url']);
22+
}
23+
24+
public function getAlias(): string
25+
{
26+
return 'goatform_api_tracker';
27+
}
28+
29+
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
30+
{
31+
return new Configuration($this->getAlias());
32+
}
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Goatform\ApiTracker\Bundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
class Configuration implements ConfigurationInterface
9+
{
10+
private string $name;
11+
12+
public function __construct(string $name)
13+
{
14+
$this->name = $name;
15+
}
16+
17+
public function getConfigTreeBuilder()
18+
{
19+
$builder = new TreeBuilder($this->name);
20+
21+
$builder->getRootNode()
22+
->children()
23+
->scalarNode('api_url')
24+
->defaultValue('')
25+
->end()
26+
->end();
27+
28+
return $builder;
29+
}
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
goatform_api_tracker_bundle:
2+
api_url: "https://api.publicapis.org/entries"

0 commit comments

Comments
 (0)