Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
02beb04b
Commit
02beb04b
authored
Feb 10, 2016
by
Vassilis Kanellopoulos
Browse files
sch_mm module fetch unit from mm.sch.gr
parent
03aa0d64
Changes
5
Hide whitespace changes
Inline
Side-by-side
config/app.config.php
View file @
02beb04b
...
...
@@ -15,6 +15,7 @@ return [
'module/authorization/bootstrap.php'
,
// 'module/sch_ldap/bootstrap.php',
'module/sch_sso/bootstrap.php'
,
'module/sch_mm/bootstrap.php'
,
// 'module/sch_auto_create/bootstrap.php',
'module/schools/bootstrap.php'
,
'module/application/bootstrap.php'
,
...
...
module/application/src/Model/User.php
→
config/settings/sch_mm.local.php.dist
View file @
02beb04b
<?php
/**
* gredu_labs
.
*
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Application\Model
;
use
RedBeanPHP\SimpleModel
;
class
User
extends
SimpleModel
{
}
return
[
'sch_mm'
=>
[
'api_url'
=>
''
,
'api_user'
=>
''
,
'api_pass'
=>
''
,
]
];
\ No newline at end of file
module/application/bootstrap.php
View file @
02beb04b
...
...
@@ -82,7 +82,7 @@ return function (Slim\App $app) {
$container
[
'settings'
][
'db'
][
'pass'
]
);
define
(
'REDBEAN_MODEL_PREFIX'
,
'
GrEduLabs\\Application\\Model\\
'
);
define
(
'REDBEAN_MODEL_PREFIX'
,
''
);
},
10000000
);
...
...
module/sch_mm/bootstrap.php
0 → 100644
View file @
02beb04b
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
return
function
(
Slim
\
App
$app
)
{
$container
=
$app
->
getContainer
();
$container
[
'autoloader'
]
->
addPsr4
(
'SchMM\\'
,
__DIR__
.
'/src/'
);
$container
[
SchMM\FetchUnit
::
class
]
=
function
(
$c
)
{
$settings
=
$c
[
'settings'
];
return
new
SchMM\FetchUnit
(
new
GuzzleHttp\Client
([
'base_uri'
=>
$settings
[
'sch_mm'
][
'api_url'
],
'auth'
=>
[
$settings
[
'sch_mm'
][
'api_user'
],
$settings
[
'sch_mm'
][
'api_pass'
],
],
]));
};
};
\ No newline at end of file
module/sch_mm/src/FetchUnit.php
0 → 100644
View file @
02beb04b
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
SchMM
;
use
GuzzleHttp\ClientInterface
;
class
FetchUnit
{
/**
* @var ClientInterface
*/
protected
$httpClient
;
/**
* Class constructor
*
* @param ClientInterface $httpClient
*/
public
function
__construct
(
ClientInterface
$httpClient
)
{
$this
->
httpClient
=
$httpClient
;
}
public
function
__invoke
(
$mmId
)
{
$config
=
$this
->
httpClient
->
getConfig
();
$baseUri
=
$config
[
'base_uri'
];
$auth
=
$config
[
'auth'
];
$url
=
$baseUri
->
withQueryValue
(
$baseUri
,
'registry_no'
,
$mmId
);
$response
=
$this
->
httpClient
->
request
(
'GET'
,
$url
,
[
'auth'
=>
$auth
]);
$responseData
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
!
isset
(
$responseData
[
'data'
])
||
empty
(
$responseData
[
'data'
]))
{
return
null
;
}
return
$responseData
[
'data'
][
0
];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment