-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2151 from dpfaffenbauer/features/2146
[StorageList & Slug] fixes for shared wishlist & slugs
- Loading branch information
Showing
8 changed files
with
69 additions
and
65 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
50 changes: 0 additions & 50 deletions
50
src/CoreShop/Bundle/FrontendBundle/Resources/views/Wishlist/share/summary.html.twig
This file was deleted.
Oops, something went wrong.
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
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
57 changes: 57 additions & 0 deletions
57
src/CoreShop/Component/Resource/Pimcore/ResourceSlugLinkGenerator.php
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* CoreShop | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - CoreShop Commercial License (CCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org) | ||
* @license https://www.coreshop.org/license GPLv3 and CCL | ||
* | ||
*/ | ||
|
||
namespace CoreShop\Component\Resource\Pimcore; | ||
|
||
use CoreShop\Component\Pimcore\Exception\LinkGenerationNotPossibleException; | ||
use CoreShop\Component\Pimcore\Slug\SluggableInterface; | ||
use CoreShop\Component\Resource\Metadata\RegistryInterface; | ||
use Pimcore\Model\DataObject\ClassDefinition\LinkGeneratorInterface; | ||
use Pimcore\Model\DataObject\Concrete; | ||
|
||
class ResourceSlugLinkGenerator implements LinkGeneratorInterface | ||
{ | ||
public function __construct( | ||
private LinkGeneratorInterface $inner, | ||
private RegistryInterface $metadataRegistry, | ||
) { | ||
} | ||
|
||
public function generate(Concrete $object, array $params = []): string | ||
{ | ||
if (!$object instanceof SluggableInterface) { | ||
throw new LinkGenerationNotPossibleException( | ||
sprintf( | ||
'Object with Path "%s" must implement %s', | ||
$object->getFullPath(), | ||
SluggableInterface::class, | ||
) | ||
); | ||
} | ||
|
||
if ($this->metadataRegistry->hasClass($object::class)) { | ||
$metadata = $this->metadataRegistry->getByClass($object::class); | ||
|
||
if ($metadata->hasParameter('slug') && !$metadata->getParameter('slug')) { | ||
throw new LinkGenerationNotPossibleException(); | ||
} | ||
} | ||
|
||
return $this->inner->generate($object, $params); | ||
} | ||
} |