Limpieza de objetos externos
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
<?php
|
||||
$app->add($app->getContainer()->get(Contabilidad\Common\Middleware\Auth::class));
|
||||
$app->add($app->getContainer()->get(Common\Middleware\Auth::class));
|
||||
|
@ -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;
|
||||
}
|
||||
];
|
||||
|
@ -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];
|
||||
}
|
||||
];
|
||||
|
14
api/setup/setups/01_auth.php
Normal file
14
api/setup/setups/01_auth.php
Normal 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)
|
||||
);
|
||||
}
|
||||
];
|
@ -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
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user