Skip to content

Commit a397103

Browse files
committed
Correções de bugs.
1 parent e598595 commit a397103

File tree

5 files changed

+79
-17
lines changed

5 files changed

+79
-17
lines changed

src/Config/Enums/EntityConfigs.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@
22

33
namespace Zend\EntityMapper\Config\Enums;
44

5+
/**
6+
* Interface EntityConfigs
7+
*
8+
* @package Zend\EntityMapper\Config\Enums
9+
*/
510
interface EntityConfigs
611
{
12+
/**
13+
* Schema where the table is located.
14+
*/
715
const SCHEMA = 'schema';
16+
17+
/**
18+
* Table corresponding to the entity.
19+
*/
820
const TABLE = 'table';
21+
22+
/**
23+
* Entity fields definition.
24+
*/
925
const FIELDS = 'fields';
1026
}

src/Config/Enums/PropertyConfigs.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@
99
*/
1010
interface PropertyConfigs
1111
{
12+
/**
13+
* In-class property name
14+
*/
1215
const PROPERTY = 'property';
16+
17+
/**
18+
* In-Database column name
19+
*/
1320
const ALIAS = 'alias';
21+
22+
/**
23+
* Foreign key definition.
24+
*/
25+
const FOREIGN_KEY = 'foreignKey';
26+
27+
/**
28+
* Define if the field is a primaryKey (boolean)
29+
*/
30+
const PRIMARY_KEY = 'primaryKey';
1431
}

src/Config/Factory/EntityConfigFactory.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Zend\Config\Config;
66
use Zend\Db\Sql\TableIdentifier;
77
use Zend\EntityMapper\Config\Collection;
8-
use Zend\EntityMapper\Config\Container\Container;
98
use Zend\EntityMapper\Config\Entity;
109
use Zend\EntityMapper\Config\Exceptions\ConfigurationException;
1110
use Zend\EntityMapper\Config\Field;
@@ -30,10 +29,11 @@ class EntityConfigFactory
3029
private $config;
3130

3231
/**
33-
* ConfigFactory constructor.
32+
* EntityConfigFactory constructor.
3433
*
3534
* @param array $configArray
3635
* @throws ConfigurationException
36+
* @throws \Zend\Cache\Exception\ExceptionInterface
3737
*/
3838
public function __construct(array $configArray)
3939
{
@@ -51,10 +51,8 @@ public function getConfig(): Entity
5151
}
5252

5353
/**
54-
* Merge $rawConfig into $config
55-
*
56-
* @return void
5754
* @throws ConfigurationException
55+
* @throws \Zend\Cache\Exception\ExceptionInterface
5856
*/
5957
public function mergeEntity(): void
6058
{
@@ -81,6 +79,7 @@ public function mergeEntity(): void
8179

8280
/**
8381
* @param array $fieldConfig
82+
* @throws \Zend\Cache\Exception\ExceptionInterface
8483
*/
8584
public function mergeField(array $fieldConfig)
8685
{

src/Config/Field.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Zend\EntityMapper\Config;
44

5-
use Zend\Filter\FilterInterface;
6-
75
/**
86
* Field
97
*
@@ -97,17 +95,17 @@ public function setAlias(string $alias)
9795
}
9896

9997
/**
100-
* @return string
98+
* @return string|object
10199
*/
102-
public function getInputFilter(): string
100+
public function getInputFilter()
103101
{
104102
return $this->inputFilter;
105103
}
106104

107105
/**
108-
* @param string $inputFilter
106+
* @param string|object $inputFilter
109107
*/
110-
public function setInputFilter(string $inputFilter)
108+
public function setInputFilter($inputFilter)
111109
{
112110
$this->inputFilter = $inputFilter;
113111
}
@@ -117,21 +115,21 @@ public function setInputFilter(string $inputFilter)
117115
*/
118116
public function hasInputFilter(): bool
119117
{
120-
return (!empty($this->inputFilter)) && class_exists($this->inputFilter);
118+
return (!empty($this->inputFilter)) || class_exists($this->inputFilter);
121119
}
122120

123121
/**
124-
* @return string
122+
* @return string|object
125123
*/
126-
public function getOutputFilter(): string
124+
public function getOutputFilter()
127125
{
128126
return $this->outputFilter;
129127
}
130128

131129
/**
132-
* @param string $outputFilter
130+
* @param string|object $outputFilter
133131
*/
134-
public function setOutputFilter(string $outputFilter)
132+
public function setOutputFilter($outputFilter)
135133
{
136134
$this->outputFilter = $outputFilter;
137135
}
@@ -141,7 +139,7 @@ public function setOutputFilter(string $outputFilter)
141139
*/
142140
public function hasOutputFilter(): bool
143141
{
144-
return (!empty($this->outputFilter)) && class_exists($this->outputFilter);
142+
return (!empty($this->outputFilter)) || class_exists($this->outputFilter);
145143
}
146144

147145
/**
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Zend\EntityMapper\Db\Gateway\Factory;
4+
5+
use Interop\Container\ContainerInterface;
6+
use Zend\EntityMapper\Db\Gateway\DynamicTableGateway;
7+
use Zend\ServiceManager\Factory\FactoryInterface;
8+
9+
/**
10+
* DynamicTableGatewayFactory
11+
*
12+
* @package Zend\EntityMapper\Db\Gateway\Factory
13+
*/
14+
class DynamicTableGatewayFactory implements FactoryInterface
15+
{
16+
/**
17+
* @param ContainerInterface $container
18+
* @param string $requestedName
19+
* @param array|null $options
20+
* @return object|DynamicTableGateway
21+
* @throws \Psr\Container\ContainerExceptionInterface
22+
* @throws \Psr\Container\NotFoundExceptionInterface
23+
* @throws \Zend\Cache\Exception\ExceptionInterface
24+
*/
25+
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
26+
{
27+
$adapter = $container->get('Zend\Db\Adapter\Adapter');
28+
$dynamicTableGateway = new DynamicTableGateway($adapter);
29+
30+
return $dynamicTableGateway;
31+
}
32+
}

0 commit comments

Comments
 (0)