Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
27pchrisl committed Nov 3, 2020
2 parents 3b94d5a + 7ff4d6c commit 486016e
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 46 deletions.
338 changes: 317 additions & 21 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/ComplexType.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function getDeclaredProperties(): ObjectArray
return $this->properties->sliceByClass(DeclaredProperty::class);
}

public function getDynamicProperties(): ObjectArray
public function getGeneratedProperties(): ObjectArray
{
return $this->properties->sliceByClass(DynamicProperty::class);
return $this->properties->sliceByClass(GeneratedProperty::class);
}

public function getProperty(string $property): ?Property
Expand All @@ -83,11 +83,11 @@ public function getNavigationProperty(string $property): ?NavigationProperty
return $property instanceof NavigationProperty ? $property : null;
}

public function getDynamicProperty(string $property): ?DynamicProperty
public function getGeneratedProperty(string $property): ?GeneratedProperty
{
$property = $this->properties->get($property);

return $property instanceof DynamicProperty ? $property : null;
return $property instanceof GeneratedProperty ? $property : null;
}

public function getProperties(): ObjectArray
Expand Down
1 change: 0 additions & 1 deletion src/Drivers/EloquentEntitySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Flat3\Lodata\Drivers;

use Exception;
use Flat3\Lodata\DeclaredProperty;
use Flat3\Lodata\Drivers\SQL\SQLConnection;
use Flat3\Lodata\Drivers\SQL\SQLFilter;
use Flat3\Lodata\Drivers\SQL\SQLSchema;
Expand Down
2 changes: 2 additions & 0 deletions src/Drivers/SQLEntitySet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Flat3\Lodata\Drivers\SQL\SQLFilter;
use Flat3\Lodata\Drivers\SQL\SQLLimits;
use Flat3\Lodata\Drivers\SQL\SQLOrderBy;
use Flat3\Lodata\Drivers\SQL\SQLSchema;
use Flat3\Lodata\Drivers\SQL\SQLSearch;
use Flat3\Lodata\Entity;
use Flat3\Lodata\EntitySet;
Expand Down Expand Up @@ -38,6 +39,7 @@ class SQLEntitySet extends EntitySet implements SearchInterface, FilterInterface
use SQLOrderBy;
use SQLSearch;
use SQLLimits;
use SQLSchema;

/** @var ObjectArray $sourceMap Mapping of OData properties to source identifiers */
protected $sourceMap;
Expand Down
6 changes: 3 additions & 3 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function emit(Transaction $transaction): void
$entityType = $this->getType();
$navigationRequests = $transaction->getNavigationRequests();

/** @var DynamicProperty $dynamicProperty */
foreach ($this->getType()->getDynamicProperties() as $dynamicProperty) {
$dynamicProperty->generatePropertyValue($this);
/** @var GeneratedProperty $generatedProperty */
foreach ($this->getType()->getGeneratedProperties() as $generatedProperty) {
$generatedProperty->generatePropertyValue($this);
}

/** @var NavigationProperty $navigationProperty */
Expand Down
6 changes: 3 additions & 3 deletions src/DynamicProperty.php → src/GeneratedProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Flat3\Lodata\Exception\Protocol\InternalServerErrorException;
use Flat3\Lodata\Helper\PropertyValue;

abstract class DynamicProperty extends Property
abstract class GeneratedProperty extends Property
{
abstract public function invoke(Entity $entity);

Expand All @@ -21,9 +21,9 @@ public function generatePropertyValue(Entity $entity): PropertyValue
$result === null && $type instanceof PrimitiveType && !$type->isNullable()
) {
throw new InternalServerErrorException(
'invalid_dynamic_property_type',
'invalid_generated_property_type',
sprintf(
'The dynamic property %s did not return a value of its defined type %s',
'The generated property %s did not return a value of its defined type %s',
$this->getName(),
$type->getIdentifier()
)
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/PropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Flat3\Lodata\Controller\Response;
use Flat3\Lodata\Controller\Transaction;
use Flat3\Lodata\DynamicProperty;
use Flat3\Lodata\Entity;
use Flat3\Lodata\EntitySet;
use Flat3\Lodata\Exception\Internal\LexerException;
Expand All @@ -13,6 +12,7 @@
use Flat3\Lodata\Exception\Protocol\NoContentException;
use Flat3\Lodata\Exception\Protocol\NotFoundException;
use Flat3\Lodata\Expression\Lexer;
use Flat3\Lodata\GeneratedProperty;
use Flat3\Lodata\Interfaces\ContextInterface;
use Flat3\Lodata\Interfaces\EmitInterface;
use Flat3\Lodata\Interfaces\PipeInterface;
Expand Down Expand Up @@ -173,7 +173,7 @@ public static function pipe(
$property->generatePropertyValue($transaction, $navigationRequest, $argument);
}

if ($property instanceof DynamicProperty) {
if ($property instanceof GeneratedProperty) {
$property->generatePropertyValue($argument);
}

Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/Queries/Entity/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Flat3\Lodata\Tests\Unit\Queries\Entity;

use Flat3\Lodata\DynamicProperty;
use Flat3\Lodata\Entity;
use Flat3\Lodata\Facades\Lodata;
use Flat3\Lodata\GeneratedProperty;
use Flat3\Lodata\Tests\Request;
use Flat3\Lodata\Tests\TestCase;
use Flat3\Lodata\Transaction\Metadata;
Expand Down Expand Up @@ -142,11 +142,11 @@ public function test_select_star()
);
}

public function test_dynamic_property()
public function test_generated_property()
{
$airport = Lodata::getEntityType('airport');

$property = new class('cp', Type::int32()) extends DynamicProperty {
$property = new class('cp', Type::int32()) extends GeneratedProperty {
public function invoke(Entity $entity)
{
return new Int32(4);
Expand All @@ -160,11 +160,11 @@ public function invoke(Entity $entity)
);
}

public function test_dynamic_property_selected()
public function test_generated_property_selected()
{
$airport = Lodata::getEntityType('airport');

$property = new class('cp', Type::int32()) extends DynamicProperty {
$property = new class('cp', Type::int32()) extends GeneratedProperty {
public function invoke(Entity $entity)
{
return new Int32(4);
Expand All @@ -179,11 +179,11 @@ public function invoke(Entity $entity)
);
}

public function test_dynamic_property_not_selected()
public function test_generated_property_not_selected()
{
$airport = Lodata::getEntityType('airport');

$property = new class('cp', Type::int32()) extends DynamicProperty {
$property = new class('cp', Type::int32()) extends GeneratedProperty {
public function invoke(Entity $entity)
{
return new Int32(4);
Expand All @@ -198,11 +198,11 @@ public function invoke(Entity $entity)
);
}

public function test_dynamic_property_emit()
public function test_generated_property_emit()
{
$airport = Lodata::getEntityType('airport');

$property = new class('cp', Type::int32()) extends DynamicProperty {
$property = new class('cp', Type::int32()) extends GeneratedProperty {
public function invoke(Entity $entity)
{
return new Int32(4);
Expand All @@ -216,11 +216,11 @@ public function invoke(Entity $entity)
);
}

public function test_bad_dynamic_property()
public function test_bad_generated_property()
{
$airport = Lodata::getEntityType('airport');

$property = new class('cp', Type::int32()) extends DynamicProperty {
$property = new class('cp', Type::int32()) extends GeneratedProperty {
public function invoke(Entity $entity)
{
return new String_(4);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OData-Error: {"code":"invalid_generated_property_type","message":"The generated property cp did not return a value of its defined type Edm.Int32"}

0 comments on commit 486016e

Please sign in to comment.