Skip to content

Commit

Permalink
Rename GalleryHasMedia to GalleryItem
Browse files Browse the repository at this point in the history
  • Loading branch information
wbloszyk committed Aug 3, 2020
1 parent 5364076 commit eb9ee07
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Api/GalleryController.php
Expand Up @@ -212,7 +212,7 @@ public function getGalleryMediasAction($id)
*
* @return GalleryItemInterface[]
*/
public function getGalleryGalleryItemAction($id)
public function getGalleryGalleryItemsAction($id)
{
return $this->getGallery($id)->getGalleryItems();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Model/GalleryMediaCollectionInterface.php
Expand Up @@ -19,7 +19,7 @@
*/
interface GalleryMediaCollectionInterface
{
public function addGalleryHasMedia(GalleryItemInterface $galleryItem);
public function addGalleryItem(GalleryItemInterface $galleryItem);

public function removeGalleryHasMedia(GalleryItemInterface $galleryItem);
public function removeGalleryItem(GalleryItemInterface $galleryItem);
}
8 changes: 4 additions & 4 deletions src/Resources/config/routing/api/gallery.xml
Expand Up @@ -9,7 +9,7 @@
<route id="get_gallery_medias" path="/galleries/{id}/medias.{_format}" methods="GET" controller="Sonata\MediaBundle\Controller\Api\GalleryController::getGalleryMediasAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="get_gallery_galleryhasmedias" path="/galleries/{id}/galleryhasmedias.{_format}" methods="GET" controller="Sonata\MediaBundle\Controller\Api\GalleryController::getGalleryGalleryhasmediasAction" format="json">
<route id="get_gallery_galleryitems" path="/galleries/{id}/galleryitems.{_format}" methods="GET" controller="Sonata\MediaBundle\Controller\Api\GalleryController::getGalleryGalleryItemsAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="post_gallery" path="/galleries.{_format}" methods="POST" controller="Sonata\MediaBundle\Controller\Api\GalleryController::postGalleryAction" format="json">
Expand All @@ -18,13 +18,13 @@
<route id="put_gallery" path="/galleries/{id}.{_format}" methods="PUT" controller="Sonata\MediaBundle\Controller\Api\GalleryController::putGalleryAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="post_gallery_media_galleryhasmedia" path="/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}" methods="POST" controller="Sonata\MediaBundle\Controller\Api\GalleryController::postGalleryMediaGalleryhasmediaAction" format="json">
<route id="post_gallery_media_galleryitem" path="/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}" methods="POST" controller="Sonata\MediaBundle\Controller\Api\GalleryController::postGalleryMediaGalleryItemAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="put_gallery_media_galleryhasmedia" path="/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}" methods="PUT" controller="Sonata\MediaBundle\Controller\Api\GalleryController::putGalleryMediaGalleryhasmediaAction" format="json">
<route id="put_gallery_media_galleryitem" path="/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}" methods="PUT" controller="Sonata\MediaBundle\Controller\Api\GalleryController::putGalleryMediaGalleryItemAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="delete_gallery_media_galleryhasmedia" path="/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}" methods="DELETE" controller="Sonata\MediaBundle\Controller\Api\GalleryController::deleteGalleryMediaGalleryhasmediaAction" format="json">
<route id="delete_gallery_media_galleryitem" path="/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}" methods="DELETE" controller="Sonata\MediaBundle\Controller\Api\GalleryController::deleteGalleryMediaGalleryItemAction" format="json">
<requirement key="_format">json|xml|html</requirement>
</route>
<route id="delete_gallery" path="/galleries/{id}.{_format}" methods="DELETE" controller="Sonata\MediaBundle\Controller\Api\GalleryController::deleteGalleryAction" format="json">
Expand Down
8 changes: 8 additions & 0 deletions tests/App/Entity/Gallery.php
Expand Up @@ -15,6 +15,7 @@

use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseGallery;
use Sonata\MediaBundle\Model\GalleryItemInterface;

/**
* @ORM\Entity
Expand All @@ -36,4 +37,11 @@ public function getId(): int
{
return $this->id;
}

public function removeGalleryItem(GalleryItemInterface $galleryItem)
{
if ($this->galleryItems->contains($galleryItem)) {
$this->galleryItems->removeElement($galleryItem);
}
}
}
Expand Up @@ -14,13 +14,13 @@
namespace Sonata\MediaBundle\Tests\App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseGalleryHasMedia;
use Sonata\MediaBundle\Entity\BaseGalleryItem;

/**
* @ORM\Entity
* @ORM\Table(name="media__gallery_has_media")
* @ORM\Table(name="media__gallery_item")
*/
class GalleryHasMedia extends BaseGalleryHasMedia
class GalleryItem extends BaseGalleryItem
{
/**
* @ORM\Id
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config.yml
Expand Up @@ -17,7 +17,7 @@ sonata_media:
class:
media: Sonata\MediaBundle\Tests\App\Entity\Media
gallery: Sonata\MediaBundle\Tests\App\Entity\Gallery
gallery_has_media: Sonata\MediaBundle\Tests\App\Entity\GalleryHasMedia
gallery_item: Sonata\MediaBundle\Tests\App\Entity\GalleryItem
force_disable_category: true
default_context: default
contexts:
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/Api/GalleryControllerTest.php
Expand Up @@ -99,7 +99,7 @@ public function testGetGalleryGalleryItemsAction(): void

$gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test');

$this->assertSame([$galleryItem], $gController->getGalleryGalleryItemAction(1));
$this->assertSame([$galleryItem], $gController->getGalleryGalleryItemsAction(1));
}

public function testGetGalleryMediaAction(): void
Expand Down
8 changes: 4 additions & 4 deletions tests/Functional/RoutingTest.php
Expand Up @@ -82,12 +82,12 @@ public function getRoutes(): iterable
yield ['sonata_api_media_gallery_get_galleries', '/api/media/galleries.{_format}', ['GET']];
yield ['sonata_api_media_gallery_get_gallery', '/api/media/galleries/{id}.{_format}', ['GET']];
yield ['sonata_api_media_gallery_get_gallery_medias', '/api/media/galleries/{id}/medias.{_format}', ['GET']];
yield ['sonata_api_media_gallery_get_gallery_galleryhasmedias', '/api/media/galleries/{id}/galleryhasmedias.{_format}', ['GET']];
yield ['sonata_api_media_gallery_get_gallery_galleryitems', '/api/media/galleries/{id}/galleryitems.{_format}', ['GET']];
yield ['sonata_api_media_gallery_post_gallery', '/api/media/galleries.{_format}', ['POST']];
yield ['sonata_api_media_gallery_put_gallery', '/api/media/galleries/{id}.{_format}', ['PUT']];
yield ['sonata_api_media_gallery_post_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['POST']];
yield ['sonata_api_media_gallery_put_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['PUT']];
yield ['sonata_api_media_gallery_delete_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['DELETE']];
yield ['sonata_api_media_gallery_post_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['POST']];
yield ['sonata_api_media_gallery_put_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['PUT']];
yield ['sonata_api_media_gallery_delete_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['DELETE']];
yield ['sonata_api_media_gallery_delete_gallery', '/api/media/galleries/{id}.{_format}', ['DELETE']];
yield ['sonata_api_media_media_get_media', '/api/media/media.{_format}', ['GET']];
yield ['sonata_api_media_media_get_medium', '/api/media/media/{id}.{_format}', ['GET']];
Expand Down

0 comments on commit eb9ee07

Please sign in to comment.