sync ordering
This commit is contained in:
parent
807d12a2b5
commit
911045cdd2
|
@ -14,6 +14,14 @@ use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
class Connect
|
class Connect
|
||||||
{
|
{
|
||||||
|
protected static $resources = [
|
||||||
|
'Role',
|
||||||
|
'Company',
|
||||||
|
'Team',
|
||||||
|
'User',
|
||||||
|
'UserTeam'
|
||||||
|
];
|
||||||
|
|
||||||
protected $app;
|
protected $app;
|
||||||
protected $synchronized = [];
|
protected $synchronized = [];
|
||||||
|
|
||||||
|
@ -26,7 +34,7 @@ class Connect
|
||||||
|
|
||||||
public function setSynchronized($models)
|
public function setSynchronized($models)
|
||||||
{
|
{
|
||||||
$this->synchronized = [];
|
$items = [];
|
||||||
|
|
||||||
foreach ($models as $model)
|
foreach ($models as $model)
|
||||||
{
|
{
|
||||||
|
@ -36,8 +44,19 @@ class Connect
|
||||||
$class = explode('\\', $model);
|
$class = explode('\\', $model);
|
||||||
$resource = $model::$connectResource ?? end($class);
|
$resource = $model::$connectResource ?? end($class);
|
||||||
|
|
||||||
$this->synchronized[$resource] = $model;
|
$items[$resource] = $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$synchronized = [];
|
||||||
|
|
||||||
|
foreach (self::$resources as $resourceType) { // Re-ordering
|
||||||
|
foreach ($items as $resource => $model) {
|
||||||
|
if ($resource == $resourceType)
|
||||||
|
$synchronized[$resource] = $model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->synchronized = $synchronized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
Loading…
Reference in New Issue