partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit da51e30e1a9842e62b8cf63395407239f22e5db7
parent 954887af44d1eb9e79475b53271455a9c3408dda
Author: Felicitus <felicitus@felicitus.org>
Date:   Sat,  7 Nov 2015 19:55:31 +0100

Added category path interface

Diffstat:
Asrc/PartKeepr/CategoryBundle/Entity/CategoryPathInterface.php | 21+++++++++++++++++++++
Msrc/PartKeepr/CoreBundle/Command/UpdateCategoryPathCommand.php | 11+++++++----
Msrc/PartKeepr/FootprintBundle/Entity/FootprintCategory.php | 11++++-------
Msrc/PartKeepr/PartBundle/Entity/PartCategory.php | 11++++-------
Msrc/PartKeepr/StorageLocationBundle/Entity/StorageLocationCategory.php | 11++++-------
5 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/src/PartKeepr/CategoryBundle/Entity/CategoryPathInterface.php b/src/PartKeepr/CategoryBundle/Entity/CategoryPathInterface.php @@ -0,0 +1,21 @@ +<?php +namespace PartKeepr\CategoryBundle\Entity; + + +interface CategoryPathInterface +{ + /** + * Sets the category path + * + * @param string $categoryPath The category path + */ + public function setCategoryPath($categoryPath); + + /** + * Generates the category path + * + * @param string $pathSeparator The path separator + * @return string The category path + */ + public function generateCategoryPath($pathSeparator); +} diff --git a/src/PartKeepr/CoreBundle/Command/UpdateCategoryPathCommand.php b/src/PartKeepr/CoreBundle/Command/UpdateCategoryPathCommand.php @@ -2,7 +2,7 @@ namespace PartKeepr\CoreBundle\Command; use Gedmo\Tree\Entity\Repository\NestedTreeRepository; -use PartKeepr\CategoryBundle\Entity\AbstractCategory; +use PartKeepr\CategoryBundle\Entity\CategoryPathInterface; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,16 +21,16 @@ class UpdateCategoryPathCommand extends ContainerAwareCommand $entities = array( 'PartKeepr\FootprintBundle\Entity\FootprintCategory', 'PartKeepr\PartBundle\Entity\PartCategory', - 'PartKeepr\StorageLocationBundle\Entity\StorageLocationCategory' + 'PartKeepr\StorageLocationBundle\Entity\StorageLocationCategory', ); foreach ($entities as $entity) { $this->regenerateCategoryPaths($entity); } - } - public function regenerateCategoryPaths ($entity) { + public function regenerateCategoryPaths($entity) + { $repository = $this->getContainer()->get("doctrine.orm.default_entity_manager")->getRepository($entity); /** @@ -41,6 +41,9 @@ class UpdateCategoryPathCommand extends ContainerAwareCommand $pathSeparator = $this->getContainer()->getParameter("partkeepr.category.path_separator"); foreach ($rootNodes as $rootNode) { + /** + * @var $rootNode CategoryPathInterface + */ $rootNode->setCategoryPath(uniqid()); } diff --git a/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php b/src/PartKeepr/FootprintBundle/Entity/FootprintCategory.php @@ -5,6 +5,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use PartKeepr\CategoryBundle\Entity\AbstractCategory; +use PartKeepr\CategoryBundle\Entity\CategoryPathInterface; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use Symfony\Component\Serializer\Annotation\Groups; @@ -15,7 +16,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * The entity for our footprint categories * @TargetService(uri="/api/footprint_categories") */ -class FootprintCategory extends AbstractCategory +class FootprintCategory extends AbstractCategory implements CategoryPathInterface { /** * @Gedmo\TreeParent @@ -95,9 +96,7 @@ class FootprintCategory extends AbstractCategory } /** - * Sets the category path - * - * @param string $categoryPath The category path + * {@inheritdoc} */ public function setCategoryPath($categoryPath) { @@ -105,9 +104,7 @@ class FootprintCategory extends AbstractCategory } /** - * Generates the category path - * - * @return string The category path + * {@inheritdoc} */ public function generateCategoryPath($pathSeparator) { diff --git a/src/PartKeepr/PartBundle/Entity/PartCategory.php b/src/PartKeepr/PartBundle/Entity/PartCategory.php @@ -5,6 +5,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use PartKeepr\CategoryBundle\Entity\AbstractCategory; +use PartKeepr\CategoryBundle\Entity\CategoryPathInterface; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use Symfony\Component\Serializer\Annotation\Groups; @@ -17,7 +18,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * @TargetService(uri="/api/part_categories") * */ -class PartCategory extends AbstractCategory +class PartCategory extends AbstractCategory implements CategoryPathInterface { /** * @Gedmo\TreeParent @@ -82,9 +83,7 @@ class PartCategory extends AbstractCategory } /** - * Sets the category path - * - * @param string $categoryPath The category path + * {@inheritdoc} */ public function setCategoryPath($categoryPath) { @@ -92,9 +91,7 @@ class PartCategory extends AbstractCategory } /** - * Generates the category path - * - * @return string The category path + * {@inheritdoc} */ public function generateCategoryPath($pathSeparator) { diff --git a/src/PartKeepr/StorageLocationBundle/Entity/StorageLocationCategory.php b/src/PartKeepr/StorageLocationBundle/Entity/StorageLocationCategory.php @@ -5,6 +5,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use PartKeepr\CategoryBundle\Entity\AbstractCategory; +use PartKeepr\CategoryBundle\Entity\CategoryPathInterface; use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; use Symfony\Component\Serializer\Annotation\Groups; @@ -15,7 +16,7 @@ use Symfony\Component\Serializer\Annotation\Groups; * The entity for our storage location categories * @TargetService(uri="/api/storage_location_categories") */ -class StorageLocationCategory extends AbstractCategory +class StorageLocationCategory extends AbstractCategory implements CategoryPathInterface { /** * @Gedmo\TreeParent @@ -94,9 +95,7 @@ class StorageLocationCategory extends AbstractCategory } /** - * Sets the category path - * - * @param string $categoryPath The category path + * {@inheritdoc} */ public function setCategoryPath($categoryPath) { @@ -104,9 +103,7 @@ class StorageLocationCategory extends AbstractCategory } /** - * Generates the category path - * - * @return string The category path + * {@inheritdoc} */ public function generateCategoryPath($pathSeparator) {