Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ integrated binding filter with factory

+ constructors signatures now adhered to
+ modified modeler query statements
  • Loading branch information...
commit b73d3f27fd2fbc355a0c06625425ca4c90a6d51b 1 parent 0f1a56a
@jgswift jgswift authored
View
17 modules/DBAL/Data/Entity/Attribute.php
@@ -7,11 +7,10 @@ class Attribute extends \DBAL\Data\Model\Attribute
const AutoIncrement = 2;
const NotNull = 4;
- private $_outerName;
private $_value;
private $_relationship;
private $_load;
- private $_length;
+ private $length;
function getLoadName()
{
@@ -113,20 +112,22 @@ function isReference()
public function getLength()
{
- //TODO: GET DEFAULT LENGTH
- return $this->_length;
+ if( is_null( $this->length ) )
+ $this->length = $this->Type->getDefaultLength();
+
+ return $this->length;
}
public function setLength($length)
{
- $this->_length = $length;
+ $this->length = $length;
}
- function equals( Attribute $attr )
+ function equals( $attribute )
{
- if( (int)$this->getLength() !== (int)$attr->getLength() )
+ if( (int)$this->getLength() !== (int)$attribute->getLength() )
return false;
- return parent::equals( $attr );
+ return parent::equals( $attribute );
}
}
View
5 modules/DBAL/Data/Filter/Entity.php
@@ -23,8 +23,11 @@ function __construct()
'*-*.entity' => 'EntityName',
'*-*.mappedBy' => 'MappedBy',
'*-*.inversedBy' => 'InversedBy');
+
+ $signatures = array( 'entity' => array('name'),
+ 'attribute' => array('name') );
- parent::__construct( $params, $mapping );
+ parent::__construct( $params, $mapping, $signatures );
}
protected function map( $mappedObject, $subject )
View
12 modules/DBAL/Data/Model/Attribute.php
@@ -21,7 +21,7 @@ function __construct( $name = null, $type = null )
$this->setFlags( $flags );
}
- function equals( Attribute $attribute )
+ function equals( $attribute )
{
if( parent::equals( $attribute ) &&
$this->getDefault() == $attribute->getDefault() &&
@@ -99,18 +99,8 @@ function setFlags(array $flags)
$this->addFlag( $flag );
}
- public function setInnerName($innerName)
- {
- $this->setName( $innerName );
- }
-
function setName( $name )
{
$this->Name = $name;
}
-
- public function setType($type)
- {
- $this->Type = $type;
- }
}
View
2  modules/DBAL/Query.php
@@ -3,7 +3,7 @@
use \Util\Interfaces as I;
-abstract class Query extends \Kinesis\Query
+abstract class Query extends \Kinesis\Task\Query
{
public $Stream;
protected $handler;
View
7 modules/DBAL/SQL/Query/Alter.php
@@ -17,7 +17,12 @@ function execute()
{
$platform = $this->getPlatform();
- return $platform->alter( $this->Parameters['Table'] );
+ $sql = $platform->alter( $this->Parameters['Table'] );
+
+ if( count( $this->Children ) > 0 )
+ $sql .= parent::execute();
+
+ return $sql;
//parent::execute();
}
}
View
9 modules/DBAL/SQL/Query/Attribute.php
@@ -5,19 +5,20 @@ class Attribute extends Statement
{
function __construct( $attribute, \Kinesis\Task $parent )
{
- $parent->Children['Create']->addChild( $this );
+ $parent->addChild( $this );
+ $this->setComponent( $parent->Parent->getComponent() );
parent::__construct( array('Attribute' => $attribute ),
- $parent->Children['Create'] );
+ $parent );
}
function initialise()
{
$attribute = $this->Parameters['Attribute'];
- if( $attribute instanceof \DBAL\Entity\Attribute )
+ if( $attribute instanceof \DBAL\Data\Entity\Attribute )
{
$this->Parameters['Name'] = $attribute->getName();
- $this->Parameters['Type'] = (string)$attribute->DataType;
+ $this->Parameters['Type'] = (string)$attribute->getTypeName();
$this->Parameters['Length'] = $attribute->Length;
$this->Parameters['Default']= $attribute->Default;
$this->Parameters['Flags'] = $attribute->Flags;
View
7 modules/DBAL/SQL/Query/Drop.php
@@ -5,7 +5,9 @@ class Drop extends Statement
{
function __construct( $item, \Kinesis\Task $parent )
{
- parent::__construct( array('Item' => $item), $parent );
+ $container = $parent->Parameters['Container'];
+ $container->addChild( $this );
+ parent::__construct( array('Item' => $item), $container );
}
function initialise()
@@ -18,9 +20,6 @@ function initialise()
elseif( $item instanceof \DBAL\Data\Entity\Attribute )
{
$this->Parameters['Column'] = $item->getName();
- $this->Parent->Children['Alter']->addChild( $this );
- unset( $this->Parent->Children['Drop']);
- $this->Parent = $this->Parent->Children['Alter'];
}
}
View
10 modules/Kinesis/Parameter.php
@@ -1,7 +1,9 @@
<?php
namespace Kinesis;
-abstract class Parameter
+use Util\Interfaces as I;
+
+abstract class Parameter implements I\Comparable
{
public $Name;
public $Type; //OBJECT||VALUETYPE
@@ -9,10 +11,14 @@
function __construct( $name = null, $type = null )
{
$this->Name = $name;
+
+ if( is_string( $type ))
+ $type = Type::load( $type );
+
$this->Type = $type;
}
- function equals( Parameter $parameter )
+ function equals( $parameter )
{
if( $this->Name == $parameter->Name &&
(string)$this->Type == (string)$parameter->Type )
View
4 modules/Kinesis/Task.php
@@ -4,12 +4,12 @@
abstract class Task extends Component
{
/**
- * Implemented differently for various tasks
+ * Implemented for various possibly disparate tasks
*/
abstract protected function execute();
/**
- * Catch or ensure invoke arguments
+ * Catch or ensure arguments exist
* @return mixed Task execution result
*/
function __invoke()
View
16 modules/Kinesis/Task/Factory.php
@@ -7,14 +7,15 @@
*/
class Factory extends \Kinesis\Task
{
- private $_filter;
+ private $filter;
+ private $signatures = array();
function initialise()
{
if( !$this->hasNamespace() )
$this->Parameters['Namespace'] = 'Object\Type';
if( array_key_exists( 'Mapping', $this->Parameters ) )
- $this->_filter = new \DBAL\Data\Mapping\Filter( $this->Parameters,
+ $this->filter = new \DBAL\Data\Mapping\Filter( $this->Parameters,
$this->getMapping() );
}
@@ -35,9 +36,10 @@ function getMapping()
function isMapped()
{
- return !is_null( $this->_filter );
+ return !is_null( $this->filter );
}
-
+
+
/**
* resolves a class name from \Kinesis\Parameter
* pre-pends local namespace parameter
@@ -64,7 +66,7 @@ protected function getClassName( \Kinesis\Parameter $parameter )
*/
private function map( $name )
{
- $filter = $this->_filter;
+ $filter = $this->filter;
return $filter( array('input' => strtolower( $name ) ));
}
@@ -74,8 +76,10 @@ private function map( $name )
* and an array of arguments to pass into constructor
* @return mixed new instance of class
*/
- protected function execute( array $arguments )
+ protected function execute()
{
+ $arguments = func_get_arg(0);
+
$param = $arguments[0];
if( is_string( $param ) )
if( $this->isMapped() )
View
6 modules/Kinesis/Query.php → modules/Kinesis/Task/Query.php
@@ -1,7 +1,7 @@
<?php
-namespace Kinesis;
+namespace Kinesis\Task;
-abstract class Query extends Task implements \IteratorAggregate
+abstract class Query extends \Kinesis\Task implements \IteratorAggregate
{
protected $builder;
protected $iterator;
@@ -44,7 +44,7 @@ function build()
protected function assemble()
{
- if( ($builder = $this->builder) instanceof Task )
+ if( ($builder = $this->builder) instanceof \Kinesis\Task )
return $builder();
return null;
View
16 modules/Kinesis/Type.php
@@ -23,6 +23,11 @@ static function initialise( $ref )
$ref->Parameter = self::field( $typeName, $type );
}
+ static function load( $typeName )
+ {
+ return self::execute( $typeName );
+ }
+
public static function reflect( $className )
{
if( !array_key_exists( $className, self::$reflection ))
@@ -108,10 +113,17 @@ private static function scalar( $ref )
else
$name = gettype( $ref );
- switch( $name )
+ switch( strtolower( $name ) )
{
+ case 'integer':
+ case 'int':
+ $type = new Type\Integer();
+ break;
+ case 'timestamp':
+ $type = new Type\TimeStamp();
+ break;
default:
- $type = new Type\ObjectType();
+ throw new \Exception('Type '.$name.' not found.');
}
return $type;
View
7 modules/Util/Interfaces/Comparable.php
@@ -0,0 +1,7 @@
+<?php
+namespace Util\Interfaces;
+
+interface Comparable
+{
+ function equals( $compare );
+}
View
7 modules/Util/Interfaces/Comparer.php
@@ -1,7 +0,0 @@
-<?php
-namespace Util\Interfaces;
-
-interface Comparer
-{
- function Compare( $compare, $with );
-}
Please sign in to comment.
Something went wrong with that request. Please try again.