Skip to content

Commit f56ede2

Browse files
First development release
1 parent cbe6fc8 commit f56ede2

File tree

10 files changed

+226
-0
lines changed

10 files changed

+226
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/bin
2+
/vendor
3+
composer.lock

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: php
2+
3+
php:
4+
- '7.0'
5+
- '7.1'
6+
- '7.2'
7+
- nightly
8+
9+
matrix:
10+
fast_finish: true
11+
allow_failures:
12+
- php: nightly
13+
14+
before_script:
15+
- composer install --dev
16+
17+
script: vendor/bin/simple-phpunit

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GrabzitBundle
2+
3+
The `GrabzitBundle` integrates the [GrabzIt](https://github.com/GrabzIt/grabzit-php) PHP library with Symfony.
4+
5+
## License
6+
7+
This package is available under the [MIT license](LICENSE).

composer.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "tlamedia/grabzit-bundle",
3+
"type": "symfony-bundle",
4+
"description": "The GrabzitBundle integrates the GrabzIt PHP library with Symfony, allowing you to interact with the GrabzIt API in your Symfony projects.",
5+
"keywords": ["grabzit", "bundle", "symfony"],
6+
"homepage": "https://github.com/tlamedia",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Torben Lundsgaard",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"require": {
15+
"php": "^7.0",
16+
"grabzit/grabzit": "^3.3.0",
17+
"symfony/config": "^3.4 || ^4.0",
18+
"symfony/dependency-injection": "^3.4 || ^4.0",
19+
"symfony/http-kernel": "^3.4 || ^4.0"
20+
},
21+
"require-dev": {
22+
"symfony/phpunit-bridge": "^4.1"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Tla\\GrabzitBundle\\": "src/"
27+
}
28+
},
29+
"autoload-dev": {
30+
"psr-4": {
31+
"Tla\\GrabzitBundle\\Tests\\": "tests/"
32+
}
33+
}
34+
}

phpunit.xml.dist

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
6+
backupGlobals="false"
7+
colors="true"
8+
bootstrap="vendor/autoload.php"
9+
>
10+
<php>
11+
<env name="APP_ENV" value="test"/>
12+
</php>
13+
14+
<testsuites>
15+
<testsuite name="Project Test Suite">
16+
<directory>tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
</phpunit>
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the TLA Media GrabzitBundle.
5+
*
6+
* (c) TLA Media <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace Tla\GrabzitBundle\DependencyInjection;
12+
13+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
14+
use Symfony\Component\Config\Definition\ConfigurationInterface;
15+
16+
/**
17+
* This is the class that validates and merges configuration from your app/config files.
18+
*/
19+
final class Configuration implements ConfigurationInterface
20+
{
21+
22+
/**
23+
*
24+
* {@inheritdoc}
25+
*
26+
*/
27+
public function getConfigTreeBuilder()
28+
{
29+
$treeBuilder = new TreeBuilder();
30+
$rootNode = $treeBuilder->root('tla_grabzit');
31+
32+
$rootNode
33+
->children()
34+
->scalarNode('key')->defaultNull()->end()
35+
->scalarNode('secret')->defaultNull()->end()
36+
->end()
37+
;
38+
39+
return $treeBuilder;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the TLA Media GrabzitBundle.
5+
*
6+
* (c) TLA Media <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace Tla\GrabzitBundle\DependencyInjection;
12+
13+
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16+
use Symfony\Component\DependencyInjection\Loader;
17+
18+
/**
19+
* This is the class that loads and manages your bundle configuration.
20+
*/
21+
final class TlaGrabzitExtension extends Extension
22+
{
23+
24+
/**
25+
*
26+
* {@inheritdoc}
27+
*
28+
*/
29+
public function load(array $configs, ContainerBuilder $container)
30+
{
31+
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
32+
$loader->load('services.xml');
33+
34+
$configuration = new Configuration();
35+
$config = $this->processConfiguration($configuration, $configs);
36+
37+
$container->setParameter('tla_grabzit.key', $config['key']);
38+
39+
$def = $container->getDefinition('tla_grabzit.client');
40+
$def->replaceArgument(0, $config['key']);
41+
$def->replaceArgument(1, $config['secret']);
42+
}
43+
}

src/Resources/config/services.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6+
7+
<services>
8+
<service id="tla_grabzit.options" class="GrabzIt\GrabzItImageOptions" public="true" />
9+
<service id="tla_grabzit.client" class="GrabzIt\GrabzItClient" public="true">
10+
<argument></argument>
11+
<argument></argument>
12+
</service>
13+
</services>
14+
15+
</container>

src/TlaGrabzitBundle.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the TLA Media GrabzitBundle.
5+
*
6+
* (c) TLA Media <[email protected]>
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 Tla\GrabzitBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
final class TlaGrabzitBundle extends Bundle
17+
{
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the TLA Media GrabzitBundle.
5+
*
6+
* (c) TLA Media <[email protected]>
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 Tla\GrabzitBundle\Tests\DependencyInjection;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Tla\GrabzitBundle\DependencyInjection\TlaGrabzitExtension;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
18+
class TlaGrabzitExtensionTest extends TestCase
19+
{
20+
public function testLoad()
21+
{
22+
$container = new ContainerBuilder();
23+
$extension = new TlaGrabzitExtension();
24+
$extension->load([], $container);
25+
$this->assertTrue($container->hasDefinition('tla_grabzit.client'));
26+
$this->assertTrue($container->hasDefinition('tla_grabzit.options'));
27+
}
28+
}

0 commit comments

Comments
 (0)