Skip to content

Commit 532ee98

Browse files
committed
Merge branch 'feature/fix-repositories' into develop
2 parents fb74fbc + b3d7c6f commit 532ee98

File tree

162 files changed

+1512
-2858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1512
-2858
lines changed

app/Console/Commands/Server/RebuildServerCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function handle()
7777
$json = array_merge($this->configurationStructureService->handle($server), ['rebuild' => true]);
7878

7979
try {
80-
$this->daemonRepository->setNode($server->node_id)->setAccessServer($server->uuid)->update($json);
80+
$this->daemonRepository->setServer($server)->update($json);
8181
} catch (RequestException $exception) {
8282
$this->output->error(trans('command/messages.server.rebuild_failed', [
8383
'name' => $server->name,

app/Console/Commands/User/DeleteUserCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function handle()
6161
$search = $this->option('user') ?? $this->ask(trans('command/messages.user.search_users'));
6262
Assert::notEmpty($search, 'Search term must be a non-null value, received %s.');
6363

64-
$results = $this->repository->search($search)->all();
64+
$results = $this->repository->setSearchTerm($search)->all();
6565
if (count($results) < 1) {
6666
$this->error(trans('command/messages.user.no_users_found'));
6767
if ($this->input->isInteractive()) {

app/Console/Commands/User/DisableTwoFactorCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function handle()
5454
}
5555

5656
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
57-
$user = $this->repository->withColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);
57+
$user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);
5858

59-
$this->repository->withoutFresh()->update($user->id, [
59+
$this->repository->withoutFreshModel()->update($user->id, [
6060
'use_totp' => false,
6161
'totp_secret' => null,
6262
]);
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository;
114

5+
use Illuminate\Support\Collection;
6+
127
interface AllocationRepositoryInterface extends RepositoryInterface
138
{
149
/**
@@ -18,13 +13,13 @@ interface AllocationRepositoryInterface extends RepositoryInterface
1813
* @param array $ids
1914
* @return int
2015
*/
21-
public function assignAllocationsToServer($server, array $ids);
16+
public function assignAllocationsToServer(int $server = null, array $ids): int;
2217

2318
/**
2419
* Return all of the allocations for a specific node.
2520
*
2621
* @param int $node
27-
* @return \Illuminate\Database\Eloquent\Collection
22+
* @return \Illuminate\Support\Collection
2823
*/
29-
public function getAllocationsForNode($node);
24+
public function getAllocationsForNode(int $node): Collection;
3025
}
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Attributes;
114

125
interface SearchableInterface
136
{
147
/**
15-
* Filter results by search term.
8+
* Set the search term.
169
*
17-
* @param string $term
10+
* @param string|null $term
1811
* @return $this
12+
* @deprecated
1913
*/
2014
public function search($term);
15+
16+
/**
17+
* Set the search term to use when requesting all records from
18+
* the model.
19+
*
20+
* @param string|null $term
21+
* @return $this
22+
*/
23+
public function setSearchTerm(string $term = null);
24+
25+
/**
26+
* Determine if a valid search term is set on this repository.
27+
*
28+
* @return bool
29+
*/
30+
public function hasSearchTerm(): bool;
31+
32+
/**
33+
* Return the search term.
34+
*
35+
* @return string|null
36+
*/
37+
public function getSearchTerm();
2138
}
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,65 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Daemon;
114

5+
use GuzzleHttp\Client;
6+
use Pterodactyl\Models\Node;
7+
use Pterodactyl\Models\Server;
8+
129
interface BaseRepositoryInterface
1310
{
1411
/**
1512
* Set the node model to be used for this daemon connection.
1613
*
17-
* @param int $id
14+
* @param \Pterodactyl\Models\Node $node
1815
* @return $this
19-
*
20-
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
2116
*/
22-
public function setNode($id);
17+
public function setNode(Node $node);
2318

2419
/**
2520
* Return the node model being used.
2621
*
27-
* @return \Pterodactyl\Models\Node
22+
* @return \Pterodactyl\Models\Node|null
2823
*/
2924
public function getNode();
3025

3126
/**
32-
* Set the UUID for the server to be used in the X-Access-Server header for daemon requests.
27+
* Set the Server model to use when requesting information from the Daemon.
3328
*
34-
* @param null|string $server
29+
* @param \Pterodactyl\Models\Server $server
3530
* @return $this
3631
*/
37-
public function setAccessServer($server = null);
32+
public function setServer(Server $server);
3833

3934
/**
40-
* Return the UUID of the server being used in requests.
35+
* Return the Server model.
4136
*
42-
* @return string
37+
* @return \Pterodactyl\Models\Server|null
4338
*/
44-
public function getAccessServer();
39+
public function getServer();
4540

4641
/**
4742
* Set the token to be used in the X-Access-Token header for requests to the daemon.
4843
*
49-
* @param null|string $token
44+
* @param string $token
5045
* @return $this
5146
*/
52-
public function setAccessToken($token = null);
47+
public function setToken(string $token);
5348

5449
/**
5550
* Return the access token being used for requests.
5651
*
57-
* @return string
52+
* @return string|null
5853
*/
59-
public function getAccessToken();
54+
public function getToken();
6055

6156
/**
6257
* Return an instance of the Guzzle HTTP Client to be used for requests.
6358
*
6459
* @param array $headers
6560
* @return \GuzzleHttp\Client
61+
*
62+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
6663
*/
67-
public function getHttpClient(array $headers = []);
64+
public function getHttpClient(array $headers = []): Client;
6865
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Daemon;
114

5+
use Psr\Http\Message\ResponseInterface;
6+
127
interface CommandRepositoryInterface extends BaseRepositoryInterface
138
{
149
/**
@@ -17,5 +12,5 @@ interface CommandRepositoryInterface extends BaseRepositoryInterface
1712
* @param string $command
1813
* @return \Psr\Http\Message\ResponseInterface
1914
*/
20-
public function send($command);
15+
public function send(string $command): ResponseInterface;
2116
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Daemon;
114

5+
use Psr\Http\Message\ResponseInterface;
6+
127
interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
138
{
149
/**
@@ -17,5 +12,5 @@ interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
1712
* @param array $overrides
1813
* @return \Psr\Http\Message\ResponseInterface
1914
*/
20-
public function update(array $overrides = []);
15+
public function update(array $overrides = []): ResponseInterface;
2116
}
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Daemon;
114

5+
use stdClass;
6+
use Psr\Http\Message\ResponseInterface;
7+
128
interface FileRepositoryInterface extends BaseRepositoryInterface
139
{
1410
/**
1511
* Return stat information for a given file.
1612
*
1713
* @param string $path
18-
* @return object
14+
* @return \stdClass
1915
*
2016
* @throws \GuzzleHttp\Exception\RequestException
2117
*/
22-
public function getFileStat($path);
18+
public function getFileStat(string $path): stdClass;
2319

2420
/**
2521
* Return the contents of a given file if it can be edited in the Panel.
2622
*
2723
* @param string $path
28-
* @return object
24+
* @return \stdClass
2925
*
3026
* @throws \GuzzleHttp\Exception\RequestException
3127
*/
32-
public function getContent($path);
28+
public function getContent(string $path): stdClass;
3329

3430
/**
3531
* Save new contents to a given file.
@@ -40,7 +36,7 @@ public function getContent($path);
4036
*
4137
* @throws \GuzzleHttp\Exception\RequestException
4238
*/
43-
public function putContent($path, $content);
39+
public function putContent(string $path, string $content): ResponseInterface;
4440

4541
/**
4642
* Return a directory listing for a given path.
@@ -50,5 +46,5 @@ public function putContent($path, $content);
5046
*
5147
* @throws \GuzzleHttp\Exception\RequestException
5248
*/
53-
public function getDirectory($path);
49+
public function getDirectory(string $path): array;
5450
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Contracts\Repository\Daemon;
114

5+
use Psr\Http\Message\ResponseInterface;
6+
127
interface PowerRepositoryInterface extends BaseRepositoryInterface
138
{
149
const SIGNAL_START = 'start';
@@ -24,5 +19,5 @@ interface PowerRepositoryInterface extends BaseRepositoryInterface
2419
*
2520
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
2621
*/
27-
public function sendSignal($signal);
22+
public function sendSignal(string $signal): ResponseInterface;
2823
}

0 commit comments

Comments
 (0)