2017-09-03 02:35:33 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-09-03 02:35:33 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
namespace Pterodactyl\Http\ViewComposers\Server;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
use Illuminate\View\View;
|
|
|
|
use Illuminate\Contracts\Session\Session;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
class ServerDataComposer
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Contracts\Session\Session
|
|
|
|
*/
|
|
|
|
protected $session;
|
|
|
|
|
|
|
|
/**
|
2017-09-03 21:32:52 +00:00
|
|
|
* ServerDataComposer constructor.
|
2017-09-03 02:35:33 +00:00
|
|
|
*
|
2017-09-03 21:32:52 +00:00
|
|
|
* @param \Illuminate\Contracts\Session\Session $session
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
2017-09-03 21:32:52 +00:00
|
|
|
public function __construct(Session $session)
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
2017-09-03 21:32:52 +00:00
|
|
|
$this->session = $session;
|
|
|
|
}
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
/**
|
|
|
|
* Attach server data to a view automatically.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\View\View $view
|
|
|
|
*/
|
|
|
|
public function compose(View $view)
|
|
|
|
{
|
|
|
|
$data = $this->session->get('server_data');
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
$view->with('server', array_get($data, 'model'));
|
|
|
|
$view->with('node', object_get($data['model'], 'node'));
|
|
|
|
$view->with('daemon_token', array_get($data, 'token'));
|
2017-09-03 02:35:33 +00:00
|
|
|
}
|
|
|
|
}
|