├── .gitignore ├── Tests ├── config.yml └── BundleInitializationTest.php ├── Resources └── config │ └── services.yml ├── HappyrLinkedInBundle.php ├── phpunit.xml.dist ├── LICENSE ├── composer.json ├── DependencyInjection ├── Configuration.php └── HappyrLinkedInExtension.php ├── .travis.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | phpunit.xml 3 | composer.lock 4 | vendor 5 | -------------------------------------------------------------------------------- /Tests/config.yml: -------------------------------------------------------------------------------- 1 | happyr_linkedin: 2 | app_id: foo 3 | app_secret: bar -------------------------------------------------------------------------------- /Resources/config/services.yml: -------------------------------------------------------------------------------- 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%" -------------------------------------------------------------------------------- /HappyrLinkedInBundle.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class HappyrLinkedInBundle extends Bundle 12 | { 13 | public function getContainerExtension() 14 | { 15 | return new HappyrLinkedInExtension(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | ./Tests 17 | 18 | 19 | 20 | 21 | 22 | . 23 | 24 | ./Resources 25 | ./Tests 26 | ./vendor 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | 23 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 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": "tobias@happyr.com" 12 | } 13 | ], 14 | "require": { 15 | "php": "^5.5 || ^7.0", 16 | "happyr/linkedin-api-client": "^1.0", 17 | "symfony/dependency-injection": "^2.3 || ^3.0 || ^4.0", 18 | "symfony/http-kernel": "^2.3 || ^3.0 || ^4.0" 19 | }, 20 | "require-dev": { 21 | "guzzlehttp/psr7": "^1.4", 22 | "nyholm/symfony-bundle-test": "^1.3.1", 23 | "php-http/curl-client": "^1.7", 24 | "php-http/httplug-bundle": "^1.8", 25 | "php-http/message": "^1.6", 26 | "symfony/phpunit-bridge": "^3.4 || ^4.0" 27 | }, 28 | "suggest": { 29 | "php-http/httplug-bundle": "For easier configure your HTTP clients" 30 | }, 31 | 32 | "autoload": { 33 | "psr-4": { 34 | "Happyr\\LinkedInBundle\\": "" 35 | } 36 | }, 37 | "config": { 38 | "sort-packages": true 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | 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')->defaultValue('httplug.client')->info('A service id for a Httplug adapter')->end() 23 | ->scalarNode('http_message_factory')->defaultValue('httplug.message_factory')->info('A service id for a Httplug adapter')->end() 24 | ->scalarNode('app_id')->isRequired()->end() 25 | ->scalarNode('app_secret')->isRequired()->end() 26 | ->scalarNode('request_format')->cannotBeEmpty()->defaultValue('json')->end() 27 | ->scalarNode('response_format')->cannotBeEmpty()->defaultValue('array')->end() 28 | ->end(); 29 | 30 | return $treeBuilder; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Tests/BundleInitializationTest.php: -------------------------------------------------------------------------------- 1 | addCompilerPass(new PublicServicePass('|happyr.*|')); 18 | } 19 | 20 | protected function getBundleClass() 21 | { 22 | return HappyrLinkedInBundle::class; 23 | } 24 | 25 | public function testInitBundle() 26 | { 27 | $kernel = $this->createKernel(); 28 | $kernel->addConfigFile(__DIR__.'/config.yml'); 29 | $kernel->addBundle(HttplugBundle::class); 30 | 31 | 32 | // Boot the kernel. 33 | $this->bootKernel(); 34 | 35 | // Get the container 36 | $container = $this->getContainer(); 37 | 38 | // Test if you services exists 39 | $this->assertTrue($container->has('happyr.linkedin')); 40 | $service = $container->get('happyr.linkedin'); 41 | $this->assertInstanceOf(LinkedIn::class, $service); 42 | } 43 | } -------------------------------------------------------------------------------- /DependencyInjection/HappyrLinkedInExtension.php: -------------------------------------------------------------------------------- 1 | 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 | if (!empty($config['http_message_factory'])) { 38 | $def = $container->getDefinition('happyr.linkedin'); 39 | $def->addMethodCall('setHttpMessageFactory', [new Reference($config['http_message_factory'])]); 40 | } 41 | } 42 | 43 | public function getAlias() 44 | { 45 | return 'happyr_linkedin'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | sudo: false 3 | cache: 4 | directories: 5 | - $HOME/.composer/cache/files 6 | - $HOME/symfony-bridge/.phpunit 7 | 8 | env: 9 | global: 10 | - PHPUNIT_FLAGS="-v" 11 | - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" 12 | 13 | matrix: 14 | fast_finish: true 15 | include: 16 | # Minimum supported dependencies with the latest and oldest PHP version 17 | - php: 7.2 18 | env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" 19 | - php: 5.5 20 | env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" 21 | 22 | # Test the latest stable release 23 | - php: 5.5 24 | - php: 5.6 25 | - php: 7.0 26 | - php: 7.1 27 | - php: 7.2 28 | env: COVERAGE=true PHPUNIT_FLAGS="-v --testsuite main --coverage-text --coverage-clover=build/coverage.xml" 29 | 30 | - php: 7.1 31 | env: DEPENDENCIES="dunglas/symfony-lock:^2" 32 | - php: 7.1 33 | env: DEPENDENCIES="dunglas/symfony-lock:^3" 34 | - php: 7.1 35 | env: DEPENDENCIES="dunglas/symfony-lock:^4" 36 | 37 | # Latest commit to master 38 | - php: 7.2 39 | env: STABILITY="dev" 40 | 41 | allow_failures: 42 | # Dev-master is allowed to fail. 43 | - env: STABILITY="dev" 44 | 45 | before_install: 46 | - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi 47 | - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; 48 | - if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; 49 | 50 | install: 51 | # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 52 | - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi 53 | - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction 54 | - ./vendor/bin/simple-phpunit install 55 | 56 | script: 57 | - composer validate --strict --no-check-lock 58 | - ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 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 | 5 | ### Easy installation 6 | 7 | For an easy installation of all components, you can run this Composer command: 8 | ```bash 9 | composer require php-http/curl-client guzzlehttp/psr7 php-http/message happyr/linkedin-bundle 10 | ``` 11 | 12 | Then add LinkedInBundle to your AppKernel. 13 | ```php 14 | // app/AppKernel.php 15 | class AppKernel extends Kernel 16 | { 17 | public function registerBundles() 18 | { 19 | $bundles = array( 20 | // ... 21 | new Happyr\LinkedInBundle\HappyrLinkedInBundle() 22 | ); 23 | } 24 | } 25 | ``` 26 | #### Optional 27 | 28 | If you want some great debugging and an easier set up you may install the [HTTPlugBundle](https://github.com/php-http/HttplugBundle). 29 | 30 | ```bash 31 | composer require php-http/httplug-bundle 32 | ``` 33 | 34 | Then make sure you have both HttplugBundle and LinkedInBundle to your AppKernel. 35 | ```php 36 | // app/AppKernel.php 37 | class AppKernel extends Kernel 38 | { 39 | public function registerBundles() 40 | { 41 | $bundles = array( 42 | // ... 43 | new Http\HttplugBundle\HttplugBundle(), 44 | new Happyr\LinkedInBundle\HappyrLinkedInBundle() 45 | ); 46 | } 47 | } 48 | ``` 49 | 50 | #### Why installing so many packages? 51 | See the installation note at the [LinkedIn client (installation)](https://github.com/Happyr/LinkedIn-API-client#installation) or 52 | the HTTPlug [documentation](http://php-http.readthedocs.io/en/latest/httplug/users.html). 53 | 54 | ### Usage 55 | 56 | ```yaml 57 | happyr_linkedin: 58 | app_id: 'xxx' 59 | app_secret: 'yyy' 60 | request_format: 'json' # Default 61 | response_format: 'array' # Default 62 | http_client: 'httplug.client' # Service ID for an object implementing Http\Client\HttpClient 63 | http_message_factory: 'httplug.message_factory' # Service ID for an object implementing Http\Message\MessageFactory 64 | ``` 65 | 66 | ```php 67 | $linkedin = $this->get('happyr.linkedin'); 68 | $user = $linkedin->get('v1/people/~:(firstName,lastName)'); 69 | ``` 70 | 71 | For more info look at the libraries repository: https://github.com/Happyr/LinkedIn-API-client 72 | 73 | ### Authentication 74 | 75 | The easiest way to implement LinkedIn Authentication is to use Symfony's Guard component. 76 | --------------------------------------------------------------------------------