Progress towards slim4/php-di etc
This commit is contained in:
parent
4aff68d5ab
commit
7c22e0f68c
7 changed files with 12 additions and 16 deletions
|
|
@ -4,7 +4,6 @@ namespace Benzine\ORM\Components;
|
|||
|
||||
use Benzine\Exceptions\BenzineException;
|
||||
use Benzine\ORM\Connection\Database;
|
||||
use Benzine\ORM\Exception\Exception;
|
||||
use Benzine\ORM\Laminator;
|
||||
use Gone\Inflection\Inflect;
|
||||
use Laminas\Db\Metadata\Object\ColumnObject;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class RelatedModel extends Entity
|
|||
protected Model $remoteRelatedModel;
|
||||
protected Database $database;
|
||||
|
||||
protected Model $relatedModel;
|
||||
|
||||
/**
|
||||
* @return Database
|
||||
*/
|
||||
|
|
@ -317,7 +319,6 @@ class RelatedModel extends Entity
|
|||
return $this->getRemoteClassPrefix();
|
||||
}
|
||||
|
||||
protected Model $relatedModel;
|
||||
/**
|
||||
* @return Model
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Benzine\ORM\Connection;
|
||||
|
||||
use Benzine\Exceptions\BenzineException;
|
||||
use Benzine\ORM\Exception\Exception;
|
||||
use Benzine\Services\ConfigurationService;
|
||||
|
||||
class Databases
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Benzine\ORM\Entities;
|
||||
|
||||
use Benzine\Migrator\Traits\Support;
|
||||
|
||||
abstract class Entity
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Psr\Container\ContainerExceptionInterface;
|
|||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Benzine\ORM\Abstracts\Model as AbstractModel;
|
||||
use Benzine\ORM\Interfaces\ModelInterface as ModelInterface;
|
||||
use Benzine\⌬ as App;
|
||||
use Benzine\App as App;
|
||||
|
||||
{% include '_overwrite_warning.twig' %}
|
||||
{% set existingMethods = [] %}
|
||||
|
|
@ -87,7 +87,7 @@ abstract class Base{{ class_name }}Model extends AbstractModel implements ModelI
|
|||
protected function get{{ related_object.getRemoteClass }}Service() : Services\{{ related_object.getRemoteClass }}Service
|
||||
{
|
||||
if (!isset($this->{{ related_object.getRemoteVariable }}Service)){
|
||||
$this->{{ related_object.getRemoteVariable }}Service = App::Container()->get(Services\{{ related_object.getRemoteClass }}Service::class);
|
||||
$this->{{ related_object.getRemoteVariable }}Service = App::Instance()->get(Services\{{ related_object.getRemoteClass }}Service::class);
|
||||
}
|
||||
|
||||
return $this->{{ related_object.getRemoteVariable }}Service;
|
||||
|
|
@ -105,7 +105,7 @@ abstract class Base{{ class_name }}Model extends AbstractModel implements ModelI
|
|||
protected function get{{ remote_object.getLocalClass }}Service() : Services\{{ remote_object.getLocalClass }}Service
|
||||
{
|
||||
if (!isset($this->{{ remote_object.getLocalVariable }}Service)){
|
||||
$this->{{ remote_object.getLocalVariable }}Service = App::Container()->get(Services\{{ remote_object.getLocalClass }}Service::class);
|
||||
$this->{{ remote_object.getLocalVariable }}Service = App::Instance()->get(Services\{{ remote_object.getLocalClass }}Service::class);
|
||||
}
|
||||
|
||||
return $this->{{ remote_object.getLocalVariable }}Service;
|
||||
|
|
@ -133,7 +133,7 @@ abstract class Base{{ class_name }}Model extends AbstractModel implements ModelI
|
|||
{
|
||||
{% for column in columns %}
|
||||
{% if column.hasRelatedObjects %}
|
||||
${{ column.getField|replace({"Id":"s"}) }}Service = App::Container()->get(Services\{{ column.getModel.getClassName }}Service::class);
|
||||
${{ column.getField|replace({"Id":"s"}) }}Service = App::Instance()->get(Services\{{ column.getModel.getClassName }}Service::class);
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
return [
|
||||
|
|
@ -281,7 +281,7 @@ abstract class Base{{ class_name }}Model extends AbstractModel implements ModelI
|
|||
public function save(): Models\{{ class_name }}Model
|
||||
{
|
||||
/** @var TableGateways\{{ class_name }}TableGateway $tableGateway */
|
||||
$tableGateway = App::Container()->get(TableGateways\{{ class_name }}TableGateway::class);
|
||||
$tableGateway = App::Instance()->get(TableGateways\{{ class_name }}TableGateway::class);
|
||||
|
||||
return $tableGateway->save($this);
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ abstract class Base{{ class_name }}Model extends AbstractModel implements ModelI
|
|||
public function destroy(): int
|
||||
{
|
||||
/** @var TableGateways\{{ class_name }}TableGateway $tableGateway */
|
||||
$tableGateway = App::Container()->get(TableGateways\{{ class_name }}TableGateway::class);
|
||||
$tableGateway = App::Instance()->get(TableGateways\{{ class_name }}TableGateway::class);
|
||||
|
||||
return $tableGateway->delete($this->getPrimaryKeys_dbColumns());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class {{ class_name }}Test extends BaseTestCase
|
|||
public static function setup{{ class_name }}MockData(): void
|
||||
{
|
||||
/** @var {{ class_name }}TableGateway ${{ variable_name }}TableGateway */
|
||||
${{ variable_name }}TableGateway = App::Container()->get({{ class_name }}TableGateway::class);
|
||||
${{ variable_name }}TableGateway = App::Instance()->get({{ class_name }}TableGateway::class);
|
||||
for($i = 0; $i <= 5; $i++){
|
||||
self::$MockData[] = ${{ variable_name }}TableGateway
|
||||
->getNewMockModelInstance()
|
||||
|
|
@ -49,7 +49,7 @@ class {{ class_name }}Test extends BaseTestCase
|
|||
*/
|
||||
public function setup{{ class_name }}Service(): void
|
||||
{
|
||||
$this->{{ variable_name }}Service = App::Container()->get(Services\{{ class_name }}Service::class);
|
||||
$this->{{ variable_name }}Service = App::Instance()->get(Services\{{ class_name }}Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ class {{ class_name }}Test extends BaseTestCase
|
|||
*/
|
||||
public function setup{{ class_name }}TableGateway(): void
|
||||
{
|
||||
$this->{{ variable_name }}TableGateway = App::Container()->get({{ class_name }}TableGateway::class);
|
||||
$this->{{ variable_name }}TableGateway = App::Instance()->get({{ class_name }}TableGateway::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace Benzine\ORM\Profiler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Benzine\ORM\Interfaces\QueryStatisticInterface;
|
||||
use Gone\UUID\UUID;
|
||||
use Laminas\Db\Adapter\ParameterContainer;
|
||||
use Laminas\Db\Adapter\Profiler\ProfilerInterface;
|
||||
use Monolog\Logger;
|
||||
|
||||
class Profiler implements ProfilerInterface
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue