Limpieza de objetos externos

This commit is contained in:
2022-08-08 22:36:04 -04:00
parent a9968dec58
commit cdb4b382b7
57 changed files with 1210 additions and 339 deletions

View File

@ -1,2 +1,2 @@
<?php
$app->add($app->getContainer()->get(Contabilidad\Common\Middleware\Auth::class));
$app->add($app->getContainer()->get(Common\Middleware\Auth::class));

View File

@ -2,28 +2,39 @@
use Psr\Container\ContainerInterface as Container;
return [
'folders' => function(Container $c) {
$arr = [
'base' => dirname(__DIR__, 2)
];
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'resources'
]);
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
$arr['resources'],
'routes'
]);
$arr['public'] = implode(DIRECTORY_SEPARATOR, [
$arr['base'],
'public'
]);
return (object) $arr;
},
'urls' => function(Container $c) {
$arr = [
'python' => 'http://python:5000'
];
return (object) $arr;
}
'folders' => function(Container $c) {
return \ProVM\Implement\Collection::fromArray([
'base' => dirname(__DIR__, 2),
'resources' => function(\Psr\Collection\CollectionInterface $collection) {
return implode(DIRECTORY_SEPARATOR, [
$collection['base'],
'resources'
]);
},
'documentation' => function(\Psr\Collection\CollectionInterface $collection) {
return implode(DIRECTORY_SEPARATOR, [
$collection['resources'],
'documentation'
]);
},
'routes' => function(\Psr\Collection\CollectionInterface $collection) {
return implode(DIRECTORY_SEPARATOR, [
$collection['resources'],
'routes'
]);
},
'public' => function(\Psr\Collection\CollectionInterface $collection) {
return implode(DIRECTORY_SEPARATOR, [
$collection['base'],
'public'
]);
}
]);
},
'urls' => function(Container $c) {
$arr = [
'python' => 'http://python:5000'
];
return (object) $arr;
}
];

View File

@ -14,15 +14,6 @@ return [
'name' => $_ENV['MYSQL_DATABASE']
]
];
function toObj($arr) {
$obj = (object) $arr;
foreach ($arr as $k => $v) {
if (is_array($v)) {
$obj->{$k} = toObj($v);
}
}
return $obj;
}
return (object) ['databases' => toObj($arr), 'short_names' => true];
return (object) ['databases' => \ProVM\Implement\Collection::fromArray($arr), 'short_names' => true];
}
];

View File

@ -0,0 +1,14 @@
<?php
use Psr\Container\ContainerInterface;
return [
\Common\Service\Auth::class => function(ContainerInterface $container) {
return new \Common\Service\Auth($container->get('api_key'));
},
\Common\Middleware\Auth::class => function(ContainerInterface $container) {
return new \Common\Middleware\Auth(
$container->get(\Nyholm\Psr7\Factory\Psr17Factory::class),
$container->get(\Common\Service\Auth::class)
);
}
];

View File

@ -2,12 +2,12 @@
use Psr\Container\ContainerInterface;
return [
\Common\Concept\Database::class => function(ContainerInterface $container) {
$settings = $container->get('databases')->default;
return new \Contabilidad\Implement\Database\MySQL(
$settings->host->name,
$settings->user->name,
$settings->user->password,
\Psr\Database\DatabaseInterface::class => function(ContainerInterface $container) {
$settings = (object) $container->get('databases')->databases->default;
return new \ProVM\Implement\Database\MySQL(
$settings->host['name'],
$settings->user['name'],
$settings->user['password'],
$settings->name
);
}