PartKeepr\StorageLocationBundle\Entity\StorageLocationCategory::generateCategoryPath PHP Method

generateCategoryPath() public method

public generateCategoryPath ( $pathSeparator )
    public function generateCategoryPath($pathSeparator)
    {
        if ($this->getParent() !== null) {
            return $this->getParent()->generateCategoryPath($pathSeparator) . $pathSeparator . $this->getName();
        } else {
            return $this->getName();
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Recursively updates the category paths.
  *
  * @param StorageLocationCategory $storageLocationCategory The storage location category to update
  * @param EntityManager           $entityManager           The entity manager
  */
 public function updateCategoryPaths(StorageLocationCategory $storageLocationCategory, OnFlushEventArgs $eventArgs)
 {
     $entityManager = $eventArgs->getEntityManager();
     $pathSeparator = $this->container->getParameter('partkeepr.category.path_separator');
     $storageLocationCategory->setCategoryPath($storageLocationCategory->generateCategoryPath($pathSeparator));
     $entityManager->getUnitOfWork()->recomputeSingleEntityChangeSet($entityManager->getClassMetadata(get_class($storageLocationCategory)), $storageLocationCategory);
     foreach ($storageLocationCategory->getChildren() as $child) {
         $this->updateCategoryPaths($child, $eventArgs);
     }
 }