Skip to content

Commit 23f0363

Browse files
committed
Init
0 parents  commit 23f0363

8 files changed

+171
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
phpunit.xml
3+
composer.lock
4+
vendor

DependencyInjection/Configuration.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Happyr\LinkedInBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
/**
9+
* @author Tobias Nyholm <[email protected]>
10+
*/
11+
class Configuration implements ConfigurationInterface
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public function getConfigTreeBuilder()
17+
{
18+
$treeBuilder = new TreeBuilder();
19+
$root = $treeBuilder->root('happyr_linkedin');
20+
21+
$root->children()
22+
->scalarNode('http_client')->info('A service id for a Httplug adapter')->end()
23+
->scalarNode('app_id')->isRequired()->end()
24+
->scalarNode('app_secret')->isRequired()->end()
25+
->scalarNode('request_format')->cannotBeEmpty()->defaultValue('json')->end()
26+
->scalarNode('response_format')->cannotBeEmpty()->defaultValue('array')->end()
27+
->end();
28+
29+
return $treeBuilder;
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Happyr\LinkedInBundle\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\DependencyInjection\Reference;
8+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9+
use Symfony\Component\DependencyInjection\Loader;
10+
11+
/**
12+
* @author Tobias Nyholm <[email protected]>
13+
*/
14+
class HappyrLinkedInExtension extends Extension
15+
{
16+
/**
17+
* @param array $configs
18+
* @param ContainerBuilder $container
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$configuration = new Configuration();
23+
$config = $this->processConfiguration($configuration, $configs);
24+
25+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26+
$loader->load('services.yml');
27+
28+
foreach ($config as $key => $value) {
29+
$container->setParameter('happyr.linkedin.'.$key, $value);
30+
}
31+
32+
if (!empty($config['http_client'])) {
33+
$def = $container->getDefinition('happyr.linkedin');
34+
$def->addMethodCall('setHttpClient', [new Reference($config['http_client'])]);
35+
}
36+
}
37+
38+
public function getAlias()
39+
{
40+
return 'happyr_linkedin';
41+
}
42+
}

HappyrLinkedInBundle.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Happyr\LinkedInBundle;
4+
5+
use Happyr\LinkedInBundle\DependencyInjection\HappyrLinkedInExtension;
6+
use Symfony\Component\HttpKernel\Bundle\Bundle;
7+
8+
/**
9+
* @author Tobias Nyholm <[email protected]>
10+
*/
11+
class HappyrLinkedInBundle extends Bundle
12+
{
13+
public function getContainerExtension()
14+
{
15+
return new HappyrLinkedInExtension();
16+
}
17+
}

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Happyr
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Happyr LinkedIn bundle
2+
3+
This is a very small bundle that registers a service for the [LinkedIn client](https://github.com/Happyr/LinkedIn-API-client).
4+
Usage:
5+
6+
```yaml
7+
happyr_linkedin:
8+
app_id: 'xxx'
9+
app_secret: 'yyy'
10+
```
11+
12+
```php
13+
$linkedin = $this->get('happyr.linkedin');
14+
$user = $linkedin->get('v1/people/~:(firstName,lastName)');
15+
```
16+
17+
For more info look at the libraries repository: https://github.com/Happyr/LinkedIn-API-client
18+
19+
### Authentication
20+
21+
The easiest way to implement LinkedIn Authentication is to use Symfony's Guard component.

Resources/config/services.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
services:
3+
happyr.linkedin:
4+
class: Happyr\LinkedIn\LinkedIn
5+
arguments:
6+
- %happyr.linkedin.app_id%
7+
- %happyr.linkedin.app_secret%
8+
- %happyr.linkedin.request_format%
9+
- %happyr.linkedin.response_format%

composer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "happyr/linkedin-bundle",
3+
"type": "symfony-bundle",
4+
"description": "A symfony bundle for happyr/linkedin-api-client",
5+
"keywords": [],
6+
"homepage": "http://developer.happyr.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Tobias Nyholm",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.5",
16+
"symfony/symfony":"^2.3|^3.0",
17+
"happyr/linkedin-api-client": "^0.7"
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"Happyr\\LinkedInBundle\\": ""
22+
}
23+
}
24+
}
25+

0 commit comments

Comments
 (0)