Skip to content

Commit

Permalink
Merge pull request #28 from ticktackk/develop
Browse files Browse the repository at this point in the history
1.1.0 Alpha 2
  • Loading branch information
ticktackk authored Aug 26, 2020
2 parents 7928776 + 71e2679 commit e3ed0ac
Show file tree
Hide file tree
Showing 24 changed files with 482 additions and 23 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
CHANGELOG
==========================

## 1.1.0 Alpha 2 (`1010012`)

- **New:** Seed for media gallery comment (#12)
- **New:** Seed for media gallery item reaction (#13)
- **New:** Seed for media gallery comment reaction (#14)
- **New:** Seed for media gallery album reaction (#15)
- **New:** Seed for profile post (#16)
- **New:** Seed for profile post comment (#17)
- **New:** Seed for profile post reaction (#18)
- **New:** Seed for profile post comment reaction (#19)

## 1.1.0 Alpha 1 (`1010011`)

- **New:** Seed for media gallery category (#7)
Expand Down
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedMediaGalleryAlbumReaction.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 SeedMediaGalleryAlbumReaction extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'media-gallery-album-reaction';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Media gallery album reactions';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedMediaGalleryComment.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 SeedMediaGalleryComment extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'media-gallery-comment';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Media gallery comments';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedMediaGalleryCommentReaction.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 SeedMediaGalleryCommentReaction extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'media-gallery-comment-reaction';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Media gallery comment reactions';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedMediaGalleryItemReaction.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 SeedMediaGalleryItemReaction extends AbstractSeedCommand
{
protected function getSeedName(): string
{
return 'media-gallery-item-reaction';
}

protected function getContentTypePlural(InputInterface $input = null): string
{
return 'Media gallery item reactions';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedProfilePost.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 SeedProfilePost extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'profile-post';
}

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

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Profile post comments';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedProfilePostCommentReaction.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 SeedProfilePostCommentReaction extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'profile-post-comment-reaction';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Profile post comment reactions';
}
}
18 changes: 18 additions & 0 deletions Cli/Command/Seed/SeedProfilePostReaction.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 SeedProfilePostReaction extends AbstractSeedCommand
{
protected function getSeedName() : string
{
return 'profile-post-reaction';
}

protected function getContentTypePlural(InputInterface $input = null) : string
{
return 'Profile post reactions';
}
}
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,31 @@ 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-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-thread` | Seeds threads |
| `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-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 |
| 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 |

License
-------
Expand Down
2 changes: 1 addition & 1 deletion Seed/MediaGalleryAlbum.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MediaGalleryAlbum extends AbstractSeed
{
use MediaGalleryRandomContainerTrait;
use MediaGalleryRandomContentTrait;

protected function seed(array $params = []): bool
{
Expand Down
21 changes: 21 additions & 0 deletions Seed/MediaGalleryAlbumReaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace TickTackk\Seeder\Seed;

class MediaGalleryAlbumReaction extends AbstractContentReaction
{
protected function getEntityShortName(): string
{
return 'XFMG:Album';
}

protected function getUserIdColumn(): string
{
return 'user_id';
}

protected function getReactionRelationName(): string
{
return 'Reactions';
}
}
38 changes: 38 additions & 0 deletions Seed/MediaGalleryComment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace TickTackk\Seeder\Seed;

use XF\Mvc\Entity\Entity;
use XFMG\Service\Comment\Creator as CommentCreatorSvc;

class MediaGalleryComment extends AbstractSeed
{
use MediaGalleryRandomContentTrait;

protected function seed(array $params = []): bool
{
$randomContent = $this->findRandomAlbumOrMediaItemContent();
if (!$randomContent)
{
return false;
}

$faker = $this->faker();
$commentCreatorSvc = $this->getCommentCreatorSvc($randomContent);
$commentCreatorSvc->setMessage($faker->text);

if (!$commentCreatorSvc->validate())
{
return false;
}

$commentCreatorSvc->save();

return true;
}

protected function getCommentCreatorSvc(Entity $content) : CommentCreatorSvc
{
return $this->service('XFMG:Comment\Creator', $content);
}
}
21 changes: 21 additions & 0 deletions Seed/MediaGalleryCommentReaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace TickTackk\Seeder\Seed;

class MediaGalleryCommentReaction extends AbstractContentReaction
{
protected function getEntityShortName(): string
{
return 'XFMG:Comment';
}

protected function getUserIdColumn(): string
{
return 'user_id';
}

protected function getReactionRelationName(): string
{
return 'Reactions';
}
}
2 changes: 1 addition & 1 deletion Seed/MediaGalleryItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class MediaGalleryItem extends AbstractSeed
{
use MediaGalleryRandomContainerTrait;
use MediaGalleryRandomContentTrait;

/**
* @throws \XF\PrintableException
Expand Down
20 changes: 20 additions & 0 deletions Seed/MediaGalleryItemReaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace TickTackk\Seeder\Seed;

class MediaGalleryItemReaction extends AbstractContentReaction
{
protected function getEntityShortName() : string
{
return 'XFMG:MediaItem';
}
protected function getUserIdColumn() : string
{
return 'user_id';
}

protected function getReactionRelationName() : string
{
return 'Reactions';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

namespace TickTackk\Seeder\Seed;

use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Finder;
use XFMG\Entity\Category as CategoryEntity;
use XFMG\Entity\Album as AlbumEntity;
use XFMG\Entity\MediaItem;
use XFMG\Finder\Album as AlbumFinder;
use XFMG\Finder\MediaItem as MediaItemFinder;

/**
* @method Finder finderWithRandomOrder(string $identifier)
*/
trait MediaGalleryRandomContainerTrait
trait MediaGalleryRandomContentTrait
{
public function findRandomCategory() :? CategoryEntity
{
Expand All @@ -26,4 +29,25 @@ public function findRandomAlbum() :? AlbumEntity

return $finder->applyVisibilityLimit()->applyAddMediaLimit()->fetchOne();
}

protected function findRandomMediaItem() :? MediaItem
{
return $this->finderWithRandomOrder('XFMG:MediaItem')->fetchOne();
}

/**
* @return AlbumEntity|MediaItem|null
*/
protected function findRandomAlbumOrMediaItemContent() :? Entity
{
do
{
$content = $this->faker()->boolean
? $this->findRandomAlbum()
: $this->findRandomMediaItem();
}
while ($content === null);

return $content;
}
}
Loading

0 comments on commit e3ed0ac

Please sign in to comment.