The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

Created basic functionality. May be buggy sometimes yet.

2.1
Gergely POLONKAI 10 years ago
parent 2e8eadf32c
commit 47086cc541
  1. 46
      DependencyInjection/Configuration.php
  2. 32
      DependencyInjection/GergelyPolonkaiSmsSenderExtension.php
  3. 2
      GergelyPolonkaiSmsSenderBundle.php
  4. 16
      Resources/config/services.xml
  5. 51
      Service/Sender.php

@ -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;
}
}

@ -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
{
}

@ -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>

@ -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…
Cancel
Save