The bridge receives the class with full namespace of the one trying to call which is not valid. It should receive the class that links to the bridge i.e an entity.
Sample implementation of bridge:
<?php
namespace Cdt\InsuranceBundle\Features\Bootstrap;
use Genesis\SQLExtensionWrapper\BridgeInterface;
use ReflectionClass;
/**
* EntityBridge class.
*/
class EntityBridge implements BridgeInterface
{
private static $entities = [];
/**
* @param string $dataModelClass
*
* @return string
*/
public static function getBaseTable($bridgedClass)
{
if (! isset(self::$entities[$bridgedClass]['reflection'])) {
self::$entities[$bridgedClass]['reflection'] = new ReflectionClass($bridgedClass);
}
return self::$entities[$bridgedClass]['reflection']->getShortName();
}
/**
* @param string $dataModelClass
*
* @return array
*/
public static function getDataMapping($bridgedClass)
{
if (! isset(self::$entities[$bridgedClass]['dataMapping'])) {
$reflection = self::$entities[$bridgedClass]['reflection'];
$dataMapping = [];
foreach ($reflection->getProperties() as $property) {
$dataMapping[$property->name] = strtolower($property->name);
}
self::$entities[$bridgedClass]['dataMapping'] = $dataMapping;
}
return self::$entities[$bridgedClass]['dataMapping'];
}
}
The bridge receives the class with full namespace of the one trying to call which is not valid. It should receive the class that links to the bridge i.e an entity.
Sample implementation of bridge:
Changes goes with PR https://github.com/forceedge01/sql-api-wrapper/pull/19/files. Needs lots of unit and behavioural testing.