Skip to content

Commit

Permalink
updating examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelog committed Jan 3, 2016
1 parent af5bb6a commit 31f9c59
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 80 deletions.
5 changes: 0 additions & 5 deletions doc/examples/mock/MyPAGIApplication.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php
require_once 'PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();
require_once __DIR__ . '/../quickstart/MyPAGIApplication.php';

$variables = array(
'request' => 'request.php',
'channel' => 'SIP/blah-00803890',
Expand All @@ -27,7 +23,6 @@
);

$mock = new PAGI\Client\Impl\MockedClientImpl(array(
'log4php.properties' => __DIR__ . '/../quickstart/log4php.properties',
'variables' => $variables
));
$mock
Expand Down
3 changes: 0 additions & 3 deletions doc/examples/mock/mocktest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
date_default_timezone_set('America/Buenos_Aires');
require_once 'PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();
$variables = array(
'request' => 'request.php',
'channel' => 'SIP/blah-00803890',
Expand Down
5 changes: 0 additions & 5 deletions doc/examples/node/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,5 @@ public function shutdown()
{
$this->asteriskLogger->notice('Shutdown');
}

public function setLogger(\Logger $logger)
{
$this->logger = $logger;
}
}

12 changes: 1 addition & 11 deletions doc/examples/node/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@
declare(ticks=1);

date_default_timezone_set('America/Buenos_Aires');
define('ROOT_PATH', realpath(__DIR__ . '/../../..'));
ini_set('include_path', implode(PATH_SEPARATOR, array(
ROOT_PATH . '/src/mg',
ROOT_PATH . '/vendor/php/log4php',
ini_get('include_path')
)));
require_once ROOT_PATH . '/src/mg/PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();

require_once __DIR__ . '/example.php';

use PAGI\Client\Impl\ClientImpl as PagiClient;

// Go, go, gooo!
$pagiClientOptions = array(
'log4php.properties' => ROOT_PATH . '/resources/log4php.properties',
);
$pagiClientOptions = array();
$pagiClient = PagiClient::getInstance($pagiClientOptions);
$pagiAppOptions = array(
'pagiClient' => $pagiClient,
Expand Down
13 changes: 1 addition & 12 deletions doc/examples/node/test_example.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
<?php
date_default_timezone_set('America/Buenos_Aires');
define('ROOT_PATH', realpath(__DIR__ . '/../../..'));
ini_set('include_path', implode(PATH_SEPARATOR, array(
ROOT_PATH . '/src/mg',
ROOT_PATH . '/vendor/php/log4php',
ini_get('include_path')
)));
require_once ROOT_PATH . '/src/mg/PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();

require_once __DIR__ . '/example.php';

use PAGI\Client\Impl\ClientImpl as PagiClient;
use PAGI\Node\Node;

// Go, go, gooo!
$pagiClientOptions = array(
'log4php.properties' => ROOT_PATH . '/resources/log4php.properties',
);
$pagiClientOptions = array();
$pagiClient = new \PAGI\Client\Impl\MockedClientImpl($pagiClientOptions);
$pagiAppOptions = array(
'pagiClient' => $pagiClient,
Expand Down
5 changes: 0 additions & 5 deletions doc/examples/nodecontroller/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,5 @@ public function shutdown()
{
$this->asteriskLogger->notice('Shutdown');
}

public function setLogger(\Logger $logger)
{
$this->logger = $logger;
}
}

13 changes: 1 addition & 12 deletions doc/examples/nodecontroller/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@
declare(ticks=1);

date_default_timezone_set('America/Buenos_Aires');
define('ROOT_PATH', realpath(__DIR__ . '/../../..'));
ini_set('include_path', implode(PATH_SEPARATOR, array(
ROOT_PATH . '/src/mg',
ROOT_PATH . '/vendor/php/log4php',
ini_get('include_path')
)));
require_once ROOT_PATH . '/src/mg/PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();

require_once __DIR__ . '/example.php';

use PAGI\Client\Impl\ClientImpl as PagiClient;

// Go, go, gooo!
$pagiClientOptions = array(
'log4php.properties' => ROOT_PATH . '/resources/log4php.properties',
);
$pagiClientOptions = array();
$pagiClient = PagiClient::getInstance($pagiClientOptions);
$pagiAppOptions = array(
'pagiClient' => $pagiClient,
Expand Down
12 changes: 1 addition & 11 deletions doc/examples/quickstart/MyPAGIApplication.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
<?php
define('ROOT_PATH', getenv('root')); // Only used inside log4php.properties

/**
* PAGI basic use example. Please see run.sh in this same directory for an
* example of how to actually run this from your dialplan.
*
* Note: The client accepts an array with options. The available options are
*
* log4php.properties => Optional. If set, should contain the absolute
* path to the log4php.properties file.
*
* stdin => Optional. If set, should contain an already open stream from
* where the client will read data (useful to make it interact with fastagi
* servers or even text files to mock stuff when testing). If not set, stdin
Expand Down Expand Up @@ -54,9 +49,6 @@
*
* Note: The client accepts an array with options. The available options are
*
* log4php.properties => Optional. If set, should contain the absolute
* path to the log4php.properties file.
*
* stdin => Optional. If set, should contain an already open stream from
* where the client will read data (useful to make it interact with fastagi
* servers or even text files to mock stuff when testing). If not set, stdin
Expand Down Expand Up @@ -95,9 +87,7 @@ public function init()
public function log($msg)
{
$agi = $this->getAgi();
if ($this->logger->isDebugEnabled()) {
$this->logger->debug($msg);
}
$this->logger->debug($msg);
$agi->consoleLog($msg);
}

Expand Down
10 changes: 2 additions & 8 deletions doc/examples/quickstart/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
# Sample application to run from your dialplan.
################################################################################
################################################################################
# Get our base directory (the one where this script is located)
me=$(dirname ${0})
root=${me}/../../..
Expand All @@ -10,18 +10,12 @@ export root=`cd ${root}; pwd`
# This is the application that will be run.
export PAGIApplication=MyPAGIApplication

# Location for your log4php.properties
export log4php_properties=${root}/resources/log4php.properties

# Make sure this is in the include path.
export PAGIBootstrap=MyPAGIApplication.php

# Your copy of log4php
log4php=${root}/vendor/php/log4php

# PHP to run and options
php=/usr/php/bin/php
phpoptions="-c ${root}/resources/php.ini -d include_path=${root}/src/mg:${log4php}:${root}/docs/examples/quickstart"
phpoptions="-c ${root}/resources/php.ini -d include_path=${root}/src/mg:${root}/docs/examples/quickstart"

# Standard.. the idea is to have a common launcher.
launcher=${root}/src/mg/PAGI/Application/PAGILauncher.php
Expand Down
8 changes: 0 additions & 8 deletions doc/examples/quickstart/spooling.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
* limitations under the License.
*
*/

ini_set('include_path', implode(PATH_SEPARATOR, array(
realpath(__DIR__ .'/../../../src/mg'),
ini_get('include_path')
)));
require_once 'PAGI/Autoloader/Autoloader.php'; // Include PAGI autoloader.
\PAGI\Autoloader\Autoloader::register(); // Call autoloader register for PAGI autoloader.

use PAGI\CallSpool\CallFile;
use PAGI\CallSpool\Impl\CallSpoolImpl;
use PAGI\DialDescriptor\SIPDialDescriptor;
Expand Down

0 comments on commit 31f9c59

Please sign in to comment.