From: Raphaƫl Gertz Date: Tue, 5 Nov 2024 00:24:33 +0000 (+0100) Subject: Rename asset into element X-Git-Tag: 0.0.8~9 X-Git-Url: https://git.rapsys.eu/treebundle/commitdiff_plain/d1f5c6c9ff6d8e7435f0bfba5983b327c89266d4?hp=e2432989d03536f53ea8d9b6bf1cfc91c1b6077f Rename asset into element --- diff --git a/Entity/Album.php b/Entity/Album.php index 9177b10..0a812f8 100644 --- a/Entity/Album.php +++ b/Entity/Album.php @@ -37,7 +37,7 @@ class Album { /** * @var \Doctrine\Common\Collections\Collection */ - private Collection $assets; + private Collection $elements; /** * Constructor @@ -51,7 +51,7 @@ class Album { $this->updated = new \DateTime('now'); //Set collections - $this->assets = new ArrayCollection(); + $this->elements = new ArrayCollection(); } /** @@ -152,36 +152,36 @@ class Album { } /** - * Add asset + * Add element * - * @param Asset $asset + * @param Element $element * * @return User */ - public function addAsset(Asset $asset): User { - $this->assets[] = $asset; + public function addElement(Element $element): User { + $this->elements[] = $element; return $this; } /** - * Remove asset + * Remove element * - * @param Asset $asset + * @param Element $element * * @return \Doctrine\Common\Collections\Collection */ - public function removeAsset(Asset $asset): Collection { - return $this->assets->removeElement($asset); + public function removeElement(Element $element): Collection { + return $this->elements->removeElement($element); } /** - * Get assets + * Get elements * * @return \Doctrine\Common\Collections\Collection */ - public function getAssets(): Collection { - return $this->assets; + public function getElements(): Collection { + return $this->elements; } /** diff --git a/Entity/Asset.php b/Entity/Element.php similarity index 80% rename from Entity/Asset.php rename to Entity/Element.php index 666277d..464c537 100644 --- a/Entity/Asset.php +++ b/Entity/Element.php @@ -16,9 +16,9 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; /** - * Asset + * Element */ -class Asset { +class Element { /** * @var ?int */ @@ -37,7 +37,7 @@ class Asset { /** * Constructor * - * @param ?string $path The asset path + * @param ?string $path The element path */ public function __construct(private Album $album, private User $user, private ?string $path = null) { $this->created = new \DateTime('now'); @@ -58,9 +58,9 @@ class Asset { * * @param \Rapsys\TreeBundle\Entity\Album $album * - * @return Asset + * @return Element */ - public function setAlbum(Album $album): Asset { + public function setAlbum(Album $album): Element { $this->album = $album; return $this; @@ -80,9 +80,9 @@ class Asset { * * @param \Rapsys\TreeBundle\Entity\User $user * - * @return Asset + * @return Element */ - public function setUser(User $user): Asset { + public function setUser(User $user): Element { $this->user = $user; return $this; @@ -102,9 +102,9 @@ class Asset { * * @param ?string $path * - * @return Asset + * @return Element */ - public function setPath(?string $path): Asset { + public function setPath(?string $path): Element { $this->path = $path; return $this; @@ -124,9 +124,9 @@ class Asset { * * @param \DateTime $created * - * @return Asset + * @return Element */ - public function setCreated(\DateTime $created): Asset { + public function setCreated(\DateTime $created): Element { $this->created = $created; return $this; @@ -146,9 +146,9 @@ class Asset { * * @param \DateTime $updated * - * @return Asset + * @return Element */ - public function setUpdated(\DateTime $updated): Asset { + public function setUpdated(\DateTime $updated): Element { $this->updated = $updated; return $this; @@ -166,9 +166,9 @@ class Asset { /** * {@inheritdoc} */ - public function preUpdate(PreUpdateEventArgs $eventArgs): ?Asset { + public function preUpdate(PreUpdateEventArgs $eventArgs): ?Element { //Check that we have an snippet instance - if (($entity = $eventArgs->getEntity()) instanceof Asset) { + if (($entity = $eventArgs->getEntity()) instanceof Element) { //Set updated value return $entity->setUpdated(new \DateTime('now')); } diff --git a/Entity/User.php b/Entity/User.php index cabdde5..4c4ea57 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -23,7 +23,7 @@ class User extends BaseUser { /** * @var \Doctrine\Common\Collections\Collection */ - private Collection $assets; + private Collection $elements; /** * Constructor @@ -45,39 +45,39 @@ class User extends BaseUser { //Set defaults //Set collections - $this->assets = new ArrayCollection(); + $this->elements = new ArrayCollection(); } /** - * Add asset + * Add element * - * @param Asset $asset + * @param Element $element * * @return User */ - public function addAsset(Asset $asset): User { - $this->assets[] = $asset; + public function addElement(Element $element): User { + $this->elements[] = $element; return $this; } /** - * Remove asset + * Remove element * - * @param Asset $asset + * @param Element $element * * @return \Doctrine\Common\Collections\Collection */ - public function removeAsset(Asset $asset): Collection { - return $this->assets->removeElement($asset); + public function removeElement(Element $element): Collection { + return $this->elements->removeElement($element); } /** - * Get assets + * Get elements * * @return \Doctrine\Common\Collections\Collection */ - public function getAssets(): Collection { - return $this->assets; + public function getElements(): Collection { + return $this->elements; } } diff --git a/Repository.php b/Repository.php index b60959f..6caf70d 100644 --- a/Repository.php +++ b/Repository.php @@ -69,8 +69,8 @@ class Repository extends EntityRepository { $tables = [ 'Rapsys\TreeBundle\Entity\UserGroup' => $qs->getJoinTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\User')->getAssociationMapping('groups'), $manager->getClassMetadata('Rapsys\TreeBundle\Entity\User'), $dp), 'Rapsys\TreeBundle\Entity\Album' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\Album'), $dp), - 'Rapsys\TreeBundle\Entity\Asset' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\Asset'), $dp), 'Rapsys\TreeBundle\Entity\Civility' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\Civility'), $dp), + 'Rapsys\TreeBundle\Entity\Element' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\Element'), $dp), 'Rapsys\TreeBundle\Entity\Group' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\Group'), $dp), 'Rapsys\TreeBundle\Entity\User' => $qs->getTableName($manager->getClassMetadata('Rapsys\TreeBundle\Entity\User'), $dp), //Set locale diff --git a/Repository/AlbumRepository.php b/Repository/AlbumRepository.php index c1901d9..e56ae8a 100644 --- a/Repository/AlbumRepository.php +++ b/Repository/AlbumRepository.php @@ -42,7 +42,7 @@ SQL; //Set the request $req = << $data['updated'], 'modified' => $data['modified'], 'link' => $this->router->generate('rapsystree_album', ['id' => $id, 'slug' => $slug, 'path' => '/']), - 'assets' => [] + 'elements' => [] ]; - //Explode asset ids + //Explode element ids $data['s_ids'] = explode("\n", $data['s_ids']); - //Explode asset paths + //Explode element paths $data['s_paths'] = explode("\n", $data['s_paths']); foreach($data['s_ids'] as $s => $id) { - $return[$data['id']]['assets'][$id] = [ + $return[$data['id']]['elements'][$id] = [ 'id' => $id, 'path' => $path = $data['s_paths'][$s], - 'link' => $this->router->generate('rapsystree_asset', ['id' => $id, 'path' => $path]), + 'link' => $this->router->generate('rapsystree_element', ['id' => $id, 'path' => $path]), ]; } } diff --git a/config/doctrine/Album.orm.yml b/config/doctrine/Album.orm.yml index 05cbd62..54659b0 100644 --- a/config/doctrine/Album.orm.yml +++ b/config/doctrine/Album.orm.yml @@ -25,8 +25,8 @@ Rapsys\TreeBundle\Entity\Album: updated: type: datetime oneToMany: - assets: - targetEntity: Rapsys\TreeBundle\Entity\Asset + elements: + targetEntity: Rapsys\TreeBundle\Entity\Element mappedBy: album lifecycleCallbacks: preUpdate: ['preUpdate'] diff --git a/config/doctrine/Asset.orm.yml b/config/doctrine/Element.orm.yml similarity index 78% rename from config/doctrine/Asset.orm.yml rename to config/doctrine/Element.orm.yml index 0147e90..bfd9d7b 100644 --- a/config/doctrine/Asset.orm.yml +++ b/config/doctrine/Element.orm.yml @@ -1,7 +1,7 @@ -Rapsys\TreeBundle\Entity\Asset: +Rapsys\TreeBundle\Entity\Element: type: entity - #repositoryClass: Rapsys\TreeBundle\Repository\AssetRepository - table: assets + #repositoryClass: Rapsys\TreeBundle\Repository\ElementRepository + table: elements id: id: type: integer @@ -21,10 +21,10 @@ Rapsys\TreeBundle\Entity\Asset: manyToOne: album: targetEntity: Rapsys\TreeBundle\Entity\Album - inversedBy: assets + inversedBy: elements user: targetEntity: Rapsys\TreeBundle\Entity\User - inversedBy: assets + inversedBy: elements uniqueConstraints: album_user_path: columns: [ album_id, user_id, path ] diff --git a/config/doctrine/User.orm.yml b/config/doctrine/User.orm.yml index d57abeb..af4250f 100644 --- a/config/doctrine/User.orm.yml +++ b/config/doctrine/User.orm.yml @@ -13,8 +13,8 @@ Rapsys\TreeBundle\Entity\User: # unique: true # nullable: true oneToMany: - assets: - targetEntity: Rapsys\TreeBundle\Entity\Asset + elements: + targetEntity: Rapsys\TreeBundle\Entity\Element mappedBy: user # manyToMany: # groups: diff --git a/config/routes/rapsystree.yaml b/config/routes/rapsystree.yaml index 03d85ea..d52b998 100644 --- a/config/routes/rapsystree.yaml +++ b/config/routes/rapsystree.yaml @@ -28,19 +28,6 @@ rapsystree_album: slug: '[\w-]+' methods: GET|POST -rapsystree_asset: - path: - en_gb: '/en/asset/{id}{path}' - fr_fr: '/actif/{id}{path}' - controller: Rapsys\TreeBundle\Controller\TreeController::asset - defaults: - id: ~ - path: ~ - requirements: - id: '\d+' - path: '/.*' - methods: GET|POST - rapsystree_contact: path: en_gb: '/en/contact' @@ -75,6 +62,19 @@ rapsysuser_edit: hash: '[a-zA-Z0-9=_-]+' methods: GET|POST +rapsystree_element: + path: + en_gb: '/en/element/{id}{path}' + fr_fr: '/element/{id}{path}' + controller: Rapsys\TreeBundle\Controller\TreeController::element + defaults: + id: ~ + path: ~ + requirements: + id: '\d+' + path: '/.*' + methods: GET|POST + rapsysuser_index: path: en_gb: '/en/user' diff --git a/templates/index.html.twig b/templates/index.html.twig index 0c95ed5..68daf1b 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -4,13 +4,13 @@ {% for id, album in albums %}