Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions tests/Gedmo/Sluggable/Fixture/Handler/People/UrilizedOccupation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Sluggable\Fixture\Handler\People;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Sluggable\Handler\InversedRelativeSlugHandler;
use Gedmo\Sluggable\Handler\TreeSlugHandler;
use Gedmo\Tree\Entity\Repository\NestedTreeRepository;

/**
* @Gedmo\Tree(type="nested")
*
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
*/
#[ORM\Entity(repositoryClass: NestedTreeRepository::class)]
#[Gedmo\Tree(type: 'nested')]
class UrilizedOccupation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;

/**
* @ORM\Column(length=64)
*/
#[ORM\Column(length: 64)]
private ?string $title = null;

/**
* @Gedmo\Slug(handlers={
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\TreeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="parentRelationField", value="parent"),
* @Gedmo\SlugHandlerOption(name="separator", value="/")
* }),
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\InversedRelativeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="relationClass", value="Gedmo\Tests\Sluggable\Fixture\Handler\People\UrilizedPerson"),
* @Gedmo\SlugHandlerOption(name="mappedBy", value="occupation"),
* @Gedmo\SlugHandlerOption(name="inverseSlugField", value="slug")
* })
* }, fields={"title"})
*
* @ORM\Column(length=64, unique=true)
*/
#[Gedmo\Slug(fields: ['title'])]
#[Gedmo\SlugHandler(class: TreeSlugHandler::class, options: ['parentRelationField' => 'parent', 'separator' => '/'])]
#[Gedmo\SlugHandler(class: InversedRelativeSlugHandler::class, options: ['relationClass' => UrilizedPerson::class, 'mappedBy' => 'occupation', 'inverseSlugField' => 'slug'])]
#[ORM\Column(length: 64, unique: true)]
private ?string $slug = null;

/**
* @Gedmo\TreeParent
*
* @ORM\ManyToOne(targetEntity="UrilizedOccupation")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
#[ORM\ManyToOne(targetEntity: self::class)]
#[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[Gedmo\TreeParent]
private ?UrilizedOccupation $parent = null;

/**
* @var Collection<int, self>
*/
private Collection $children;

/**
* @Gedmo\TreeLeft
*
* @ORM\Column(type="integer")
*/
#[ORM\Column(type: Types::INTEGER)]
#[Gedmo\TreeLeft]
private ?int $lft = null;

/**
* @Gedmo\TreeRight
*
* @ORM\Column(type="integer")
*/
#[ORM\Column(type: Types::INTEGER)]
#[Gedmo\TreeRight]
private ?int $rgt = null;

/**
* @Gedmo\TreeRoot
*
* @ORM\Column(type="integer")
*/
#[ORM\Column(type: Types::INTEGER)]
#[Gedmo\TreeRoot]
private ?int $root = null;

/**
* @Gedmo\TreeLevel
*
* @ORM\Column(name="lvl", type="integer")
*/
#[ORM\Column(name: 'lvl', type: Types::INTEGER)]
#[Gedmo\TreeLevel]
private ?int $level = null;

public function __construct()
{
$this->children = new ArrayCollection();
}

public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}

/**
* @return Collection<int, self>
*/
public function getChildren(): Collection
{
return $this->children;
}

public function getParent(): ?self
{
return $this->parent;
}

public function getRoot(): ?int
{
return $this->root;
}

public function getLeft(): ?int
{
return $this->lft;
}

public function getRight(): ?int
{
return $this->rgt;
}

public function getLevel(): ?int
{
return $this->level;
}

public function getId(): ?int
{
return $this->id;
}

public function setTitle(?string $title): void
{
$this->title = $title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function getSlug(): ?string
{
return $this->slug;
}
}
93 changes: 93 additions & 0 deletions tests/Gedmo/Sluggable/Fixture/Handler/People/UrilizedPerson.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Sluggable\Fixture\Handler\People;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Sluggable\Handler\RelativeSlugHandler;

/**
* @ORM\Entity
*/
#[ORM\Entity]
class UrilizedPerson
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;

/**
* @ORM\Column(length=64)
*/
#[ORM\Column(length: 64)]
private ?string $name = null;

/**
* @Gedmo\Slug(handlers={
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\RelativeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="relationField", value="occupation"),
* @Gedmo\SlugHandlerOption(name="relationSlugField", value="slug"),
* @Gedmo\SlugHandlerOption(name="separator", value="/"),
* @Gedmo\SlugHandlerOption(name="urilize", value=true),
* })
* }, separator="-", updatable=true, fields={"name"})
*
* @ORM\Column(name="slug", type="string", length=64, unique=true)
*/
#[Gedmo\Slug(separator: '-', updatable: true, fields: ['name'])]
#[Gedmo\SlugHandler(class: RelativeSlugHandler::class, options: ['relationField' => 'occupation', 'relationSlugField' => 'slug', 'separator' => '/', 'urilize' => true])]
#[ORM\Column(name: 'slug', type: Types::STRING, length: 64, unique: true)]
private ?string $slug = null;

/**
* @ORM\ManyToOne(targetEntity="UrilizedOccupation")
*/
#[ORM\ManyToOne(targetEntity: UrilizedOccupation::class)]
private ?UrilizedOccupation $occupation = null;

public function setOccupation(?UrilizedOccupation $occupation = null): void
{
$this->occupation = $occupation;
}

public function getOccupation(): ?UrilizedOccupation
{
return $this->occupation;
}

public function getId(): ?int
{
return $this->id;
}

public function setName(?string $name): void
{
$this->name = $name;
}

public function getName(): ?string
{
return $this->name;
}

public function getSlug(): ?string
{
return $this->slug;
}
}
97 changes: 97 additions & 0 deletions tests/Gedmo/Sluggable/Fixture/Handler/UrilizedArticle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Doctrine Behavioral Extensions package.
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Gedmo\Tests\Sluggable\Fixture\Handler;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Sluggable\Handler\InversedRelativeSlugHandler;
use Gedmo\Sluggable\Sluggable;

/**
* @ORM\Entity
*/
#[ORM\Entity]
class UrilizedArticle implements Sluggable
{
/**
* @var int|null
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @ORM\Column(name="title", type="string", length=64)
*/
#[ORM\Column(name: 'title', type: Types::STRING, length: 64)]
private ?string $title = null;

/**
* @ORM\Column(name="code", type="string", length=16)
*/
#[ORM\Column(name: 'code', type: Types::STRING, length: 16)]
private ?string $code = null;

/**
* @var string|null
*
* @Gedmo\Slug(handlers={
* @Gedmo\SlugHandler(class="Gedmo\Sluggable\Handler\InversedRelativeSlugHandler", options={
* @Gedmo\SlugHandlerOption(name="relationClass", value="Gedmo\Tests\Sluggable\Fixture\Handler\UrilizedArticleRelativeSlug"),
* @Gedmo\SlugHandlerOption(name="mappedBy", value="article"),
* @Gedmo\SlugHandlerOption(name="inverseSlugField", value="slug")
* })
* }, separator="-", updatable=true, fields={"title", "code"})
*
* @ORM\Column(name="slug", type="string", length=64, unique=true)
*/
#[Gedmo\Slug(separator: '-', updatable: true, fields: ['title', 'code'])]
#[Gedmo\SlugHandler(class: InversedRelativeSlugHandler::class, options: ['relationClass' => UrilizedArticleRelativeSlug::class, 'mappedBy' => 'article', 'inverseSlugField' => 'slug'])]
#[ORM\Column(name: 'slug', type: Types::STRING, length: 64, unique: true)]
private $slug;

public function getId(): ?int
{
return $this->id;
}

public function setTitle(?string $title): void
{
$this->title = $title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setCode(?string $code): void
{
$this->code = $code;
}

public function getCode(): ?string
{
return $this->code;
}

public function getSlug(): ?string
{
return $this->slug;
}
}
Loading
Loading