diff --git a/src/Components/Model.php b/src/Components/Model.php index 05a3d37..933d343 100644 --- a/src/Components/Model.php +++ b/src/Components/Model.php @@ -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; diff --git a/src/Components/RelatedModel.php b/src/Components/RelatedModel.php index b38b545..6a8bd48 100644 --- a/src/Components/RelatedModel.php +++ b/src/Components/RelatedModel.php @@ -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 */ diff --git a/src/Connection/Databases.php b/src/Connection/Databases.php index 02ad2f4..29bee4d 100644 --- a/src/Connection/Databases.php +++ b/src/Connection/Databases.php @@ -3,7 +3,6 @@ namespace Benzine\ORM\Connection; use Benzine\Exceptions\BenzineException; -use Benzine\ORM\Exception\Exception; use Benzine\Services\ConfigurationService; class Databases diff --git a/src/Entities/Entity.php b/src/Entities/Entity.php index 07d2a52..ef0d8ef 100644 --- a/src/Entities/Entity.php +++ b/src/Entities/Entity.php @@ -2,9 +2,6 @@ namespace Benzine\ORM\Entities; -use Benzine\Migrator\Traits\Support; - abstract class Entity { - } diff --git a/src/Generator/templates/Models/basemodel.php.twig b/src/Generator/templates/Models/basemodel.php.twig index 52779a1..a8dc9fd 100644 --- a/src/Generator/templates/Models/basemodel.php.twig +++ b/src/Generator/templates/Models/basemodel.php.twig @@ -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()); } diff --git a/src/Generator/templates/Services/tests.service.php.twig b/src/Generator/templates/Services/tests.service.php.twig index 970466b..8a1de13 100644 --- a/src/Generator/templates/Services/tests.service.php.twig +++ b/src/Generator/templates/Services/tests.service.php.twig @@ -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); } /** diff --git a/src/Profiler/Profiler.php b/src/Profiler/Profiler.php index 9234a7b..7e68d4b 100644 --- a/src/Profiler/Profiler.php +++ b/src/Profiler/Profiler.php @@ -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 {