mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Added FormClassNameService
This commit is contained in:
		@@ -0,0 +1,31 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\FormManagement;
 | 
			
		||||
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
final class FormClassNameService implements FormClassNameServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    const ENTITY_BASE_PATH = 'App\\Entity';
 | 
			
		||||
 | 
			
		||||
    const FORM_BASE_PATH = 'App\\Form';
 | 
			
		||||
 | 
			
		||||
    const SUFFIX = 'Type';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param EntityInterface $entity
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function getName(EntityInterface $entity): string
 | 
			
		||||
    {
 | 
			
		||||
        $class = get_class($entity);
 | 
			
		||||
        $replaced = str_replace(self::ENTITY_BASE_PATH, self::FORM_BASE_PATH, $class);
 | 
			
		||||
        $withSuffix = $replaced.self::SUFFIX;
 | 
			
		||||
 | 
			
		||||
        return $withSuffix;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\FormManagement;
 | 
			
		||||
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface FormClassNameServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param EntityInterface $entity
 | 
			
		||||
     *
 | 
			
		||||
     * @return string The name of the form of the entity
 | 
			
		||||
     */
 | 
			
		||||
    public function getName(EntityInterface $entity): string;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user