Created basic functionality. May be buggy sometimes yet.
This commit is contained in:
parent
2e8eadf32c
commit
47086cc541
46
DependencyInjection/Configuration.php
Normal file
46
DependencyInjection/Configuration.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\SmsSenderBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* Description of Configuration
|
||||
*
|
||||
* @author Gergely Polonkai
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('gergely_polonkai_sms_sender');
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->booleanNode('verify_ssl')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->scalarNode('sender_url')
|
||||
->isRequired()
|
||||
->end()
|
||||
->scalarNode('content_type')
|
||||
->defaultValue('application/json')
|
||||
->end()
|
||||
->scalarNode('content_encoding')
|
||||
->defaultValue('utf-8')
|
||||
->end()
|
||||
->booleanNode('verbose_curl')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
->scalarNode('username')
|
||||
->isRequired()
|
||||
->end()
|
||||
->scalarNode('password')
|
||||
->isRequired()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
32
DependencyInjection/GergelyPolonkaiSmsSenderExtension.php
Normal file
32
DependencyInjection/GergelyPolonkaiSmsSenderExtension.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\SmsSenderBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
/**
|
||||
* Description of GergelyPolonkaiSmsSenderExtension
|
||||
*
|
||||
* @author Gergely Polonkai
|
||||
*/
|
||||
class GergelyPolonkaiSmsSenderExtension extends Extension
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
|
||||
$loader->load('services.xml');
|
||||
|
||||
$container->setParameter('verify_ssl', $config['verify_ssl']);
|
||||
$container->setParameter('sender_url', $config['sender_url']);
|
||||
$container->setParameter('content_type', $config['content_type']);
|
||||
$container->setParameter('content_encoding', $config['content_encoding']);
|
||||
$container->setParameter('verbose_curl', $config['verbose_curl']);
|
||||
$container->setParameter('username', $config['username']);
|
||||
$container->setParameter('password', $config['password']);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ namespace GergelyPolonkai\SmsSenderBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class SmsSenderBundle extends Bundle
|
||||
class GergelyPolonkaiSmsSenderBundle extends Bundle
|
||||
{
|
||||
}
|
||||
|
16
Resources/config/services.xml
Normal file
16
Resources/config/services.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="gergely_polonkai_sms_sender.sender.class">GergelyPolonkai\SmsSenderBundle\Service\Sender</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="gergely_polonkai_sms_sender.sender" class="%gergely_polonkai_sms_sender.sender.class%">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
51
Service/Sender.php
Normal file
51
Service/Sender.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\SMSSenderBundle\Service;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use RuntimeException;
|
||||
use GergelyPolonkai\SmsSender\Sender as BaseSender;
|
||||
|
||||
/**
|
||||
* @author Gergely Polonkai
|
||||
*
|
||||
* SMS Sending service for JSON-RPC based SMS Sender server
|
||||
*/
|
||||
class Sender
|
||||
{
|
||||
private $loggedIn;
|
||||
|
||||
private $sender;
|
||||
|
||||
/**
|
||||
* @var Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
*/
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
$this->sender = new BaseSender(
|
||||
$this->container->getParameter('sender_url'),
|
||||
$this->container->getParameter('content_type'),
|
||||
$this->container->getParameter('content_encoding'),
|
||||
$this->container->getParameter('verify_ssl'),
|
||||
$this->container->getParameter('verbose_curl')
|
||||
);
|
||||
}
|
||||
|
||||
public function login($username, $password)
|
||||
{
|
||||
var_dump($this->sender->login($username, $password));
|
||||
}
|
||||
|
||||
public function sendMessage($recipient, $message, array $passwordLocations)
|
||||
{
|
||||
var_dump($this->sender->sendMessage($recipient, $message, $passwordLocations));
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
var_dump($this->sender->logout());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user