Skip to content

Commit

Permalink
ADD group type
Browse files Browse the repository at this point in the history
  • Loading branch information
goten4 committed Apr 23, 2015
1 parent 776a00c commit 4cc5b93
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/migrations/mysql/0001-group-type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `groups` ADD COLUMN `type` VARCHAR(256) NOT NULL DEFAULT 'default';
1 change: 1 addition & 0 deletions data/migrations/postgresql/0001-group-type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE groups ADD COLUMN type VARCHAR(256) NOT NULL DEFAULT 'default';
1 change: 1 addition & 0 deletions data/migrations/sqlite/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CREATE TABLE `groups` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`revision_id` INTEGER NOT NULL,
`name` VARCHAR(256) NOT NULL DEFAULT '',
`type` VARCHAR(256) NOT NULL DEFAULT 'default',
`ordering` INTEGER NOT NULL DEFAULT '0',
`include_pattern` TEXT NOT NULL DEFAULT '',
`exclude_pattern` TEXT NOT NULL DEFAULT ''
Expand Down
2 changes: 2 additions & 0 deletions src/KmbZendDbInfrastructure/Hydrator/GroupHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function extract($object)
$data = [
'revision_id' => $object->getRevision()->getId(),
'name' => $object->getName(),
'type' => $object->getType(),
'ordering' => $object->getOrdering(),
'include_pattern' => $object->getIncludePattern(),
'exclude_pattern' => $object->getExcludePattern(),
Expand All @@ -57,6 +58,7 @@ public function hydrate(array $data, $object)
{
$object->setId($this->getData('id', $data));
$object->setName($this->getData('name', $data));
$object->setType($this->getData('type', $data));
$object->setOrdering($this->getData('ordering', $data));
$object->setIncludePattern($this->getData('include_pattern', $data));
$object->setExcludePattern($this->getData('exclude_pattern', $data));
Expand Down
22 changes: 22 additions & 0 deletions src/KmbZendDbInfrastructure/Proxy/GroupProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ public function getName()
return $this->aggregateRoot->getName();
}

/**
* Set Type.
*
* @param string $type
* @return GroupInterface
*/
public function setType($type)
{
$this->aggregateRoot->setType($type);
return $this;
}

/**
* Get Type.
*
* @return string
*/
public function getType()
{
return $this->aggregateRoot->getType();
}

/**
* @param int $ordering
* @return GroupProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function canHydrateWithTablePrefix()
$hydrator->hydrate([
'g.id' => 1,
'g.name' => 'default',
'g.type' => 'fake',
'g.ordering' => 3,
'g.include_pattern' => '.*',
'g.exclude_pattern' => 'node1.local',
Expand All @@ -51,6 +52,7 @@ protected function createObject()
{
$group = new Group('default');
$group->setId(1);
$group->settype('fake');
$group->setIncludePattern('.*');
$group->setExcludePattern('node1.local');
$group->setOrdering(3);
Expand All @@ -67,6 +69,7 @@ protected function getData()
'id' => 1,
'revision_id' => 2,
'name' => 'default',
'type' => 'fake',
'ordering' => 3,
'include_pattern' => '.*',
'exclude_pattern' => 'node1.local',
Expand Down

0 comments on commit 4cc5b93

Please sign in to comment.