-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Cli\Command\Seed; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
|
||
class SeedDiscouragedIpAddress extends AbstractSeedCommand | ||
{ | ||
protected function getSeedName(): string | ||
{ | ||
return 'discouraged-ip-address'; | ||
} | ||
|
||
protected function getContentTypePlural(InputInterface $input = null): string | ||
{ | ||
return 'Discouraged IP addresses'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace TickTackk\Seeder\Seed; | ||
|
||
use XF\Repository\Banning as BanningRepo; | ||
|
||
class DiscouragedIpAddress extends AbstractSeed | ||
{ | ||
protected function seed(array $params = []): bool | ||
{ | ||
$faker = $this->faker(); | ||
|
||
$ip = $faker->boolean ? $faker->ipv4 : $faker->ipv6; | ||
$reason = $faker->boolean ? $faker->text : ''; | ||
|
||
return $this->getBanningRepo()->discourageIp( | ||
$ip, | ||
$reason | ||
); | ||
} | ||
|
||
protected function getBanningRepo() : BanningRepo | ||
{ | ||
return $this->repository('XF:Banning'); | ||
} | ||
} |