--- /dev/null
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys TreeBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\TreeBundle\Entity;
+
+use Rapsys\UserBundle\Entity\Civility as BaseCivility;
+
+class Civility extends BaseCivility {
+}
--- /dev/null
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys TreeBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\TreeBundle\Entity;
+
+use Rapsys\UserBundle\Entity\Group as BaseGroup;
+
+class Group extends BaseGroup {
+}
--- /dev/null
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys TreeBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\TreeBundle\Entity;
+
+use Doctrine\Common\Collections\Collection;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
+/**
+ * Resource
+ */
+class Resource {
+ /**
+ * @var int
+ */
+ private ?int $id;
+
+ /**
+ * @var \DateTime
+ */
+ private \DateTime $created;
+
+ /**
+ * @var \DateTime
+ */
+ private \DateTime $updated;
+
+ /**
+ * Constructor
+ *
+ * @param string $path The resource path
+ */
+ public function __construct(private User $user, private string $path) {
+ $this->created = new \DateTime('now');
+ $this->updated = new \DateTime('now');
+ }
+
+ /**
+ * Get id
+ *
+ * @return ?int
+ */
+ public function getId(): ?int {
+ return $this->id;
+ }
+
+ /**
+ * Set user
+ *
+ * @param \Rapsys\BlogBundle\Entity\User $user
+ *
+ * @return Resource
+ */
+ public function setUser(User $user): Resource {
+ $this->user = $user;
+
+ return $this;
+ }
+
+ /**
+ * Get user
+ *
+ * @return \Rapsys\BlogBundle\Entity\User
+ */
+ public function getUser(): User {
+ return $this->user;
+ }
+
+ /**
+ * Set path
+ *
+ * @param string $path
+ *
+ * @return Resource
+ */
+ public function setPath(string $path): Resource {
+ $this->path = $path;
+
+ return $this;
+ }
+
+ /**
+ * Get path
+ *
+ * @return string
+ */
+ public function getPath(): string {
+ return $this->path;
+ }
+
+ /**
+ * Set created
+ *
+ * @param \DateTime $created
+ *
+ * @return Resource
+ */
+ public function setCreated(\DateTime $created): Resource {
+ $this->created = $created;
+
+ return $this;
+ }
+
+ /**
+ * Get created
+ *
+ * @return \DateTime
+ */
+ public function getCreated(): \DateTime {
+ return $this->created;
+ }
+
+ /**
+ * Set updated
+ *
+ * @param \DateTime $updated
+ *
+ * @return Resource
+ */
+ public function setUpdated(\DateTime $updated): Resource {
+ $this->updated = $updated;
+
+ return $this;
+ }
+
+ /**
+ * Get updated
+ *
+ * @return \DateTime
+ */
+ public function getUpdated(): \DateTime {
+ return $this->updated;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function preUpdate(PreUpdateEventArgs $eventArgs): ?Resource {
+ //Check that we have an snippet instance
+ if (($entity = $eventArgs->getEntity()) instanceof Resource) {
+ //Set updated value
+ return $entity->setUpdated(new \DateTime('now'));
+ }
+ }
+}
--- /dev/null
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys TreeBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\TreeBundle\Entity;
+
+use Doctrine\Common\Collections\Collection;
+use Doctrine\Common\Collections\ArrayCollection;
+
+use Rapsys\UserBundle\Entity\User as BaseUser;
+
+/**
+ * {@inheritdoc}
+ */
+class User extends BaseUser {
+ /**
+ * @var \Doctrine\Common\Collections\Collection
+ */
+ private Collection $resources;
+
+ /**
+ * Constructor
+ *
+ * @param string $mail The user mail
+ * @param string $password The user password
+ * @param ?Civility $civility The user civility
+ * @param ?string $forename The user forename
+ * @param ?string $surname The user surname
+ * @param bool $active The user is active
+ * @param bool $enable The user is enable
+ * @param ?string $pseudonym The user pseudonym
+ * @param ?string $slug The user slug
+ */
+ public function __construct(string $mail, string $password, ?Civility $civility = null, ?string $forename = null, ?string $surname = null, bool $active = false, bool $enable = true, ?string $pseudonym = null, ?string $slug = null) {
+ //Call parent constructor
+ parent::__construct($mail, $password, $civility, $forename, $surname, $active, $enable);
+
+ //Set defaults
+
+ //Set collections
+ $this->resources = new ArrayCollection();
+ }
+
+ /**
+ * Add resource
+ *
+ * @param Resource $resource
+ *
+ * @return User
+ */
+ public function addResource(Resource $resource): User {
+ $this->resources[] = $resource;
+
+ return $this;
+ }
+
+ /**
+ * Remove resource
+ *
+ * @param Resource $resource
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function removeResource(Resource $resource): Collection {
+ return $this->resources->removeElement($resource);
+ }
+
+ /**
+ * Get resources
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getResources(): Collection {
+ return $this->resources;
+ }
+}
--- /dev/null
+Rapsys\TreeBundle\Entity\Civility:
+ type: entity
+ #repositoryClass: Rapsys\TreeBundle\Repository\CivilityRepository
+ table: civilities
+ oneToMany:
+ users:
+ targetEntity: User
+ mappedBy: civility
--- /dev/null
+Rapsys\TreeBundle\Entity\Group:
+ type: entity
+ #repositoryClass: Rapsys\TreeBundle\Repository\GroupRepository
+ table: groups
+ manyToMany:
+ users:
+ targetEntity: Rapsys\TreeBundle\Entity\User
+ mappedBy: groups
--- /dev/null
+Rapsys\TreeBundle\Entity\Resource:
+ type: entity
+ repositoryClass: Rapsys\TreeBundle\Repository\ResourceRepository
+ table: resources
+ id:
+ id:
+ type: integer
+ generator:
+ strategy: AUTO
+ options:
+ unsigned: true
+ fields:
+ path:
+ type: string
+ length: 4096
+ nullable: true
+ created:
+ type: datetime
+ updated:
+ type: datetime
+ manyToOne:
+ user:
+ targetEntity: Rapsys\TreeBundle\Entity\User
+ inversedBy: resources
+ lifecycleCallbacks:
+ preUpdate: ['preUpdate']
--- /dev/null
+Rapsys\TreeBundle\Entity\User:
+ type: entity
+ repositoryClass: Rapsys\TreeBundle\Repository\UserRepository
+ table: users
+# fields:
+# pseudonym:
+# type: string
+# length: 64
+# nullable: true
+# slug:
+# type: string
+# length: 64
+# unique: true
+# nullable: true
+ oneToMany:
+ resources:
+ targetEntity: Rapsys\TreeBundle\Entity\Resource
+ mappedBy: user
+# manyToMany:
+# groups:
+# targetEntity: Group
+# inversedBy: users
+# joinTable:
+# name: users_groups
+ associationOverride:
+ groups:
+ joinTable:
+ name: users_groups
+ joinColumns:
+ id:
+ name: user_id
+ inverseJoinColumns:
+ id:
+ name: group_id