Skip to content

Commit

Permalink
closes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
ticktackk committed Mar 9, 2021
1 parent c5fe152 commit 0da5035
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG
- **New:** Seed for threadmark category (#37)
- **New:** Seed for post threadmark (#38)
- **New:** Seed for conversation message threadmark (#39)
- **New:** Seed for discouraged IP addresses (#41)
- **Fix:** Threads cannot be seeded (#36)

## 1.1.0 Alpha 3 (`1010013`)
Expand Down
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedDiscouragedIpAddress.php
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';
}
}
26 changes: 26 additions & 0 deletions Seed/DiscouragedIpAddress.php
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');
}
}

0 comments on commit 0da5035

Please sign in to comment.