src/Website/LinkGenerator/CategoryLinkGenerator.php line 41

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace App\Website\LinkGenerator;
  15. use App\Model\Product\Category;
  16. use App\Website\Tool\Text;
  17. use Pimcore\Model\DataObject\ClassDefinition\LinkGeneratorInterface;
  18. use Pimcore\Model\DataObject\Concrete;
  19. use Pimcore\Model\Document;
  20. class CategoryLinkGenerator extends AbstractProductLinkGenerator implements LinkGeneratorInterface
  21. {
  22.     /**
  23.      * @param Concrete $object
  24.      * @param array $params
  25.      * @param bool $reset
  26.      *
  27.      * @return string
  28.      */
  29.     public function generate(Concrete $object, array $params = [], $reset false): string
  30.     {
  31.         if (false === $object instanceof Category) {
  32.             throw new \InvalidArgumentException('Given object is no category');
  33.         }
  34.         return $this->pimcoreUrl->__invoke(
  35.             [
  36.                 'categoryname' => $object->getName(),
  37.                 'category' => $object->getId()         
  38.                 
  39.             ],
  40.             'shop-category',
  41.             $reset
  42.         );
  43.     }
  44. }