Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkiernan120 committed Jan 16, 2019
1 parent a48e49e commit 158bd59
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/Data/DataHandler.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
*
*/
Expand All @@ -19,7 +20,7 @@ class DataHandler
/**
* summary
*/
public function __construct( $salsa )
public function __construct($salsa)
{
$this->salsa = $salsa;
}
Expand Down Expand Up @@ -75,27 +76,25 @@ public function getType()
*/
public function process()
{
if ( !isset( $this->handler ) ){
if (!isset($this->handler)) {
return false;
}

$type = $this->getType();


if ( $type == "object" && is_callable( $this->handler) ) {
if ($type == "object" && is_callable($this->handler)) {
$this->objectHandler();
}
else if ($type == "string") {
} else if ($type == "string") {
$this->stringHandler();
}
else if ($type == "array") {
} else if ($type == "array") {
$this->arrayHandler();
}
}

public function objectHandler()
{
if ( !isset( $this->handler ) ) {
if (!isset($this->handler)) {
return false;
}
// TODO intercept and expose certain data etc.
Expand All @@ -104,12 +103,12 @@ public function objectHandler()

public function callFunction()
{
$this->setReturnData( call_user_func_array($this->handler, $this->salsa->regex->params));
$this->setReturnData(call_user_func_array($this->handler, $this->salsa->regex->params));
}

public function stringHandler()
{
if ( !isset( $this->handler) ) {
if (!isset($this->handler)) {
return false;
}
$this->outputString($this->handler);
Expand All @@ -122,7 +121,7 @@ public function outputString($string)

public function arrayHandler()
{
if( !isset( $this->handler ) ) {
if (!isset($this->handler)) {
return false;
}
if (isset($this->handler) && isset($this->handler)) {
Expand All @@ -132,14 +131,14 @@ public function arrayHandler()

public function callController($data)
{
if( class_exists( $data["controller"] ) ) {
if (class_exists($data["controller"])) {
$controller = new $data["controller"];
}

if( $controller && method_exists( $controller, $data["method"] ) ) {
$params = array_merge( $this->salsa->params, is_array( $data["params"] ) ? $data["params"] : array() );
$returndata = call_user_func_array( array( $controller, $data["method"] ), $params );
$this->setReturnData( $returndata );
if ($controller && method_exists($controller, $data["method"])) {
$params = array_merge($this->salsa->params, is_array($data["passin"]) ? $data["passin"] : array());
$returndata = call_user_func_array(array($controller, $data["method"]), $params);
$this->setReturnData($returndata);
}
}
}

0 comments on commit 158bd59

Please sign in to comment.