Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.0 Alpha 4 #40

Merged
merged 18 commits into from
Mar 9, 2021
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
CHANGELOG
==========================

## 1.1.0 Alpha 4 (`1010014`)

- **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)
- **New:** Seed for banned users (#43)
- **New:** Seed for IP address bans (#44)
- **New:** Seed for rejected users (#42)
- **New:** Seed for server error logs (#45)
- **New:** Seed for spam trigger log (#46)
- **New:** Seed for spam cleaner log (#47)
- **New:** Seed for email bounce log (#48)
- **Fix:** Threads cannot be seeded (#36)
- **Fix:** Master template is not created for page nodes (#49)

## 1.1.0 Alpha 3 (`1010013`)

- **Fix:** Updated license and readme files are not copied correctly to add-on archives (#29)
Expand Down
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedConversationMessageThreadmark.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 SeedConversationMessageThreadmark extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'conversation-message-threadmark';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Conversation message threadmarks';
}
}
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';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedEmailBounceLog.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 SeedEmailBounceLog extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'email-bounce-log';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Email bounce logs';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedErrorLog.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 SeedErrorLog extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'error-log';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Error logs';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedIpAddressBan.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 SeedIpAddressBan extends AbstractSeedCommand
{
protected function getSeedName(): string
{
return 'ip-address-ban';
}

protected function getContentTypePlural(InputInterface $input = null): string
{
return 'IP address bans';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedPostThreadmark.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 SeedPostThreadmark extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'post-threadmark';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Post threadmarks';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedSpamCleanerLog.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 SeedSpamCleanerLog extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'spam-cleaner-log';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Spam cleaner log';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedSpamTrigger.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 SeedSpamTrigger extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'spam-trigger';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Spam triggers';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedThreadmarkCategory.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 SeedThreadmarkCategory extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'threadmark-category';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Threadmark categories';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedUserBan.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 SeedUserBan extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'user-ban';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'User bans';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedUserReject.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 SeedUserReject extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'user-reject';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'User rejects';
}
}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 TickTackk
Copyright (c) 2019-2021 TickTackk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 36 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,42 @@ Requirements
CLI Commands
------------

| Command | Description |
| ------------------------------------------------ | ------------------------------------- |
| `tck-seeder:seed-user` | Seeds users |
| `tck-seeder:seed-media-gallery-album` | Seeds media gallery albums |
| `tck-seeder:seed-resource-manager-update` | Seeds resource manager updates |
| `tck-seeder:seed-media-gallery-comment-reaction` | Seeds media gallery comment reactions |
| `tck-seeder:seed-media-gallery-comment` | Seeds media gallery comments |
| `tck-seeder:seed-post-reaction` | Seeds post reactions |
| `tck-seeder:seed-conversation` | Seeds conversations |
| `tck-seeder:seed-forum` | Seeds forums |
| `tck-seeder:seed-page` | Seeds pages |
| `tck-seeder:seed-profile-post-reaction` | Seeds profile post reactions |
| `tck-seeder:seed-thread` | Seeds threads |
| `tck-seeder:seed-profile-post-comment` | Seeds profile post comments |
| `tck-seeder:seed-media-gallery-item-reaction` | Seeds media gallery item reactions |
| `tck-seeder:seed-media-gallery-category` | Seeds media gallery categories |
| `tck-seeder:seed-conversation-message` | Seeds conversation messages |
| `tck-seeder:seed-post` | Seeds posts |
| `tck-seeder:seed-profile-post` | Seeds profile posts |
| `tck-seeder:seed-category` | Seeds categories |
| `tck-seeder:seed-media-gallery-item` | Seeds media gallery media items |
| `tck-seeder:seed-resource-manager-category` | Seeds resource manager categories |
| `tck-seeder:seed-resource-manager-item` | Seeds resource manager items |
| `tck-seeder:seed-profile-post-comment-reaction` | Seeds profile post comment reactions |
| `tck-seeder:seed-media-gallery-album-reaction` | Seeds media gallery album reactions |
| Command | Description |
| ------------------------------------------------- | -------------------------------------- |
| `tck-seeder:seed-conversation` | Seeds conversations |
| `tck-seeder:seed-media-gallery-item` | Seeds media gallery media items |
| `tck-seeder:seed-user-reject` | Seeds user rejects |
| `tck-seeder:seed-profile-post-comment-reaction` | Seeds profile post comment reactions |
| `tck-seeder:seed-spam-cleaner-log` | Seeds spam cleaner log |
| `tck-seeder:seed-resource-manager-update` | Seeds resource manager updates |
| `tck-seeder:seed-media-gallery-item-reaction` | Seeds media gallery item reactions |
| `tck-seeder:seed-media-gallery-comment-reaction` | Seeds media gallery comment reactions |
| `tck-seeder:seed-media-gallery-album` | Seeds media gallery albums |
| `tck-seeder:seed-thread` | Seeds threads |
| `tck-seeder:seed-spam-trigger` | Seeds spam triggers |
| `tck-seeder:seed-error-log` | Seeds error logs |
| `tck-seeder:seed-page` | Seeds pages |
| `tck-seeder:seed-post-reaction` | Seeds post reactions |
| `tck-seeder:seed-post-threadmark` | Seeds post threadmarks |
| `tck-seeder:seed-post` | Seeds posts |
| `tck-seeder:seed-category` | Seeds categories |
| `tck-seeder:seed-media-gallery-comment` | Seeds media gallery comments |
| `tck-seeder:seed-conversation-message` | Seeds conversation messages |
| `tck-seeder:seed-ip-address-ban` | Seeds ip address bans |
| `tck-seeder:seed-media-gallery-category` | Seeds media gallery categories |
| `tck-seeder:seed-forum` | Seeds forums |
| `tck-seeder:seed-user-ban` | Seeds user bans |
| `tck-seeder:seed-user` | Seeds users |
| `tck-seeder:seed-discouraged-ip-address` | Seeds discouraged ip addresses |
| `tck-seeder:seed-conversation-message-threadmark` | Seeds conversation message threadmarks |
| `tck-seeder:seed-email-bounce-log` | Seeds email bounce logs |
| `tck-seeder:seed-profile-post-comment` | Seeds profile post comments |
| `tck-seeder:seed-resource-manager-item` | Seeds resource manager items |
| `tck-seeder:seed-media-gallery-album-reaction` | Seeds media gallery album reactions |
| `tck-seeder:seed-profile-post` | Seeds profile posts |
| `tck-seeder:seed-resource-manager-category` | Seeds resource manager categories |
| `tck-seeder:seed-threadmark-category` | Seeds threadmark categories |
| `tck-seeder:seed-profile-post-reaction` | Seeds profile post reactions |

License
-------
Expand Down
56 changes: 56 additions & 0 deletions Seed/AbstractContentThreadmark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace TickTackk\Seeder\Seed;

use Faker\Provider\Lorem;
use SV\Threadmarks\Entity\ThreadmarkContentInterface as ThreadmarkContentEntityInterface;
use SV\Threadmarks\Entity\ThreadmarkContainerInterface as ThreadmarkContainerEntityInterface;
use SV\Threadmarks\Service\Threadmark\Creator as ThreadmarkCreatorSvc;
use SV\Threadmarks\Entity\ThreadmarkCategory as ThreadmarkCategoryEntity;
use XF\Mvc\Entity\Entity;

abstract class AbstractContentThreadmark extends AbstractSeed
{
/**
* @return Entity[]|ThreadmarkContainerEntityInterface[]|ThreadmarkContentEntityInterface[]|null
*/
abstract protected function findRandomContentAndContainer() :? array;

protected function seed(array $params = []): bool
{
$faker = $this->faker();
$randomContentAndContainer = $this->findRandomContentAndContainer();
if (!$randomContentAndContainer)
{
return false;
}
[$content, $container] = $randomContentAndContainer;

$threadmarkCreatorSvc = $this->getThreadmarkCreatorSvc($content, $container);
$threadmarkCreatorSvc->setLabel(\implode(' ', Lorem::words()));
$threadmarkCreatorSvc->setCategory($this->findRandomThreadmarkCategory());
$threadmarkCreatorSvc->setPosition(false);
$threadmarkCreatorSvc->resetNesting($faker->boolean);

if (!$threadmarkCreatorSvc->validate($errors))
{
return false;
}
$threadmarkCreatorSvc->save();

return true;
}

protected function getThreadmarkCreatorSvc(
ThreadmarkContentEntityInterface $content,
ThreadmarkContainerEntityInterface $container
) : ThreadmarkCreatorSvc
{
return $this->service('SV\Threadmarks:Threadmark\Creator', $content, $container);
}

protected function findRandomThreadmarkCategory() : ThreadmarkCategoryEntity
{
return $this->finderWithRandomOrder('SV\Threadmarks:ThreadmarkCategory')->fetchOne();
}
}
Loading