-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a4199fc
Showing
15 changed files
with
1,001 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Papercut-bridge-bundle | ||
|
||
Symfony bundle for Papercut XML-RPC client which is base on token authentication | ||
|
||
## Required configuration | ||
|
||
### Modify framework.yaml | ||
```yaml | ||
papercut: | ||
authentication: | ||
protocol: "http" | ||
host: "127.0.0.1" | ||
port: "80" | ||
path: "/rpc/api/xmlrpc" | ||
token: "TOKEN" | ||
``` | ||
```yaml | ||
papercut: | ||
authentication: | ||
path: "http://URL/rpc/api/xmlrpc" | ||
token: "TOKEN" | ||
``` | ||
### Modify services.yaml | ||
```yaml | ||
services: | ||
MaillotF\Papercut\PapercutBridgeBundle\Service\PapercutService: '@papercut.service' | ||
``` | ||
##Package instalation with composer | ||
```console | ||
$ composer require maillotf/papercut-bridge-bundle | ||
``` | ||
|
||
## Use in controller: | ||
|
||
```php | ||
<?php | ||
//... | ||
use MaillotF\Papercut\PapercutBridgeBundle\Service\PapercutService; | ||
|
||
class exampleController extends AbstractController | ||
{ | ||
/** | ||
* Example | ||
* | ||
* @Route("example", name="example", methods={"GET"}) | ||
* | ||
*/ | ||
public function test(PapercutService $ps) | ||
{ | ||
$user = $ps->user->getUser('4665'); | ||
|
||
return ($this->json($user->getEmail())); | ||
} | ||
|
||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
{ | ||
"name": "maillotf/papercut-bridge-bundle", | ||
"type": "symfony-bundle", | ||
"description": "A Papercut bundle for Symfony", | ||
"keywords": ["papercut", "print", "bridge", "symfony"], | ||
"homepage": "https://github.com/maillotf/papercut-bridge-bundle", | ||
"authors": [{ | ||
"name": "Flavien Maillot", | ||
"email": "contact@webcomputing.fr" | ||
}], | ||
"require": { | ||
"php": "^7.1", | ||
"symfony/http-kernel": "^3.2|^4.0|^4.1|^5.1", | ||
"symfony/config": "^3.2|^4.0|^4.1|^5.1", | ||
"symfony/dependency-injection": "^3.2|^4.0|^4.1|^5.1", | ||
"phpxmlrpc/phpxmlrpc": "^4.3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MaillotF\\Papercut\\PapercutBridgeBundle\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* Description of Configuration | ||
* | ||
* @package MaillotF\Papercut\PapercutBridgeBundle\DependencyInjection | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* @return TreeBuilder | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$builder = new TreeBuilder('papercut'); | ||
|
||
$builder->getRootNode()->addDefaultsIfNotSet() | ||
->children() | ||
->arrayNode('authentication') | ||
->isRequired() | ||
->children() | ||
->scalarNode('protocol') | ||
// ->isRequired() | ||
// ->cannotBeEmpty() | ||
->defaultValue(null) | ||
->end() | ||
->scalarNode('host') | ||
// ->isRequired() | ||
// ->cannotBeEmpty() | ||
->defaultValue(null) | ||
->end() | ||
->integerNode('port') | ||
// ->isRequired() | ||
->defaultValue(null) | ||
->end() | ||
->scalarNode('path') | ||
->isRequired() | ||
->cannotBeEmpty() | ||
->end() | ||
->scalarNode('token') | ||
->isRequired() | ||
->cannotBeEmpty() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
; | ||
return ($builder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\Extension; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
|
||
/** | ||
* Class PapercutExtension | ||
* | ||
* @package MaillotF\Papercut\PapercutBridgeBundle\DependencyInjection | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class PapercutExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
// Authentication | ||
$container->setParameter('papercut.authentication.protocol', $config['authentication']['protocol']); | ||
$container->setParameter('papercut.authentication.host', $config['authentication']['host']); | ||
$container->setParameter('papercut.authentication.port', $config['authentication']['port']); | ||
$container->setParameter('papercut.authentication.path', $config['authentication']['path']); | ||
$container->setParameter('papercut.authentication.token', $config['authentication']['token']); | ||
|
||
// load services for bundle | ||
$loader = new YamlFileLoader( | ||
$container, | ||
new FileLocator(__DIR__ . '/../Resources/config') | ||
); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle\Exception; | ||
|
||
/** | ||
* Description of PapercutException | ||
* | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class PapercutException extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle\Objects; | ||
|
||
/** | ||
* Description of AbstractPapercutObject | ||
* | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class AbstractPapercutObject | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?php | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle\Objects; | ||
|
||
/** | ||
* Description of User | ||
* | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class User | ||
{ | ||
private $username; | ||
|
||
private $password; | ||
|
||
private $fullName; | ||
|
||
private $email; | ||
|
||
private $balance; | ||
|
||
private $primaryCardNumber; | ||
|
||
private $secondaryCardNumber; | ||
|
||
private $restricted; | ||
|
||
public function getProperties(): array | ||
{ | ||
$properties = array_keys(get_object_vars($this)); | ||
unset($properties[0]); | ||
unset($properties[1]); | ||
return \MaillotF\Papercut\PapercutBridgeBundle\Utils\Normalizer::normalizeArray($properties); | ||
} | ||
|
||
public function setUsername(string $username) | ||
{ | ||
$this->username = $username; | ||
return $this; | ||
} | ||
|
||
public function getUsername(): string | ||
{ | ||
return $this->username; | ||
} | ||
|
||
public function setPassword(string $password) | ||
{ | ||
$this->password = $password; | ||
return $this; | ||
} | ||
|
||
public function getPassword(): string | ||
{ | ||
return $this->password; | ||
} | ||
|
||
public function setFullname(string $fullName) | ||
{ | ||
$this->fullName = $fullName; | ||
return $this; | ||
} | ||
|
||
public function getFullname(): string | ||
{ | ||
return $this->fullName; | ||
} | ||
|
||
public function setEmail(string $email) | ||
{ | ||
$this->email = $email; | ||
return $this; | ||
} | ||
|
||
public function getEmail(): string | ||
{ | ||
return $this->email; | ||
} | ||
|
||
public function setBalance(string $balance) | ||
{ | ||
$this->balance = $balance; | ||
return $this; | ||
} | ||
|
||
public function getBalance(): string | ||
{ | ||
return $this->balance; | ||
} | ||
|
||
public function setPrimaryCardNumber(string $primaryCardNumber) | ||
{ | ||
$this->primaryCardNumber = $primaryCardNumber; | ||
return $this; | ||
} | ||
public function getPrimaryCardNumber(): string | ||
{ | ||
return $this->primaryCardNumber; | ||
} | ||
|
||
public function setSecondaryCardNumber(string $secondaryCardNumber) | ||
{ | ||
$this->secondaryCardNumber = $secondaryCardNumber; | ||
return $this; | ||
} | ||
public function getSecondaryCardNumber(): string | ||
{ | ||
return $this->secondaryCardNumber; | ||
} | ||
|
||
public function setRestricted(string $restricted) | ||
{ | ||
$this->restricted = $restricted; | ||
return $this; | ||
} | ||
|
||
public function getRestricted(): string | ||
{ | ||
return $this->restricted; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace MaillotF\Papercut\PapercutBridgeBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
use MaillotF\Papercut\PapercutBridgeBundle\DependencyInjection\PapercutExtension; | ||
|
||
/** | ||
* Class PapercutBridgeBundle | ||
* | ||
* @package MaillotF\Papercut\PapercutBridgeBundle | ||
* @author Flavien Maillot "contact@webcomputing.fr" | ||
*/ | ||
class PapercutBridgeBundle extends Bundle | ||
{ | ||
public function getContainerExtension() | ||
{ | ||
return new PapercutExtension(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
papercut.service: | ||
class: MaillotF\Papercut\PapercutBridgeBundle\Service\PapercutService | ||
arguments: | ||
- "%papercut.authentication.path%" | ||
- "%papercut.authentication.token%" | ||
- "%papercut.authentication.protocol%" | ||
- "%papercut.authentication.host%" | ||
- "%papercut.authentication.port%" |
Oops, something went wrong.