private function getTemplateFileName($object, ?string $context = null): ?array
    {
        $fullClassName = get_class($object);

        // Optimisation: let's see if we already performed the file_exists checks.
        $cacheKey = md5("FileBasedRenderer_".$this->directory.'/'.$fullClassName.'/'.$context);

        $cachedValue = $this->cacheService->get($cacheKey);
        if ($cachedValue !== null && !$this->debugMode) {
            return $cachedValue;
        }

        $fileName = $this->findFile($fullClassName, $context);
        $parentClass = $fullClassName;
        // If no file is found, let's go through the parents of the object.
        while (true) {
            if ($fileName != false) {
                break;
            }
            $parentClass = get_parent_class($parentClass);
            if ($parentClass == false) {
                break;
            }
            $fileName = $this->findFile($parentClass, $context);
        }

        // Still no objects? Let's browse the interfaces.
        if ($fileName == false) {
            $interfaces = class_implements($fullClassName);
            foreach ($interfaces as $interface) {
                $fileName = $this->findFile($interface, $context);
                if ($fileName != false) {
                    break;
                }
            }
        }

        $this->cacheService->set($cacheKey, $fileName);

        return $fileName;
    }
private function getTemplateFileName($object, ?string $context = null): ?array
    {
        $fullClassName = get_class($object);

        // Optimisation: let's see if we already performed the file_exists checks.
        $cacheKey = md5("FileBasedRenderer_".$this->directory.'/'.$fullClassName.'/'.$context);

        $cachedValue = $this->cacheService->get($cacheKey);
        if ($cachedValue !== null && !$this->debugMode) {
            return $cachedValue;
        }

        $fileName = $this->findFile($fullClassName, $context);
        $parentClass = $fullClassName;
        // If no file is found, let's go through the parents of the object.
        while (true) {
            if ($fileName != false) {
                break;
            }
            $parentClass = get_parent_class($parentClass);
            if ($parentClass == false) {
                break;
            }
            $fileName = $this->findFile($parentClass, $context);
        }

        // Still no objects? Let's browse the interfaces.
        if ($fileName == false) {
            $interfaces = class_implements($fullClassName);
            foreach ($interfaces as $interface) {
                $fileName = $this->findFile($interface, $context);
                if ($fileName != false) {
                    break;
                }
            }
        }

        $this->cacheService->set($cacheKey, $fileName);

        return $fileName;
    }
private function getTemplateFileName ( $ object , ? string $ context = null ) : ? array { $ fullClassName = get_class ( $ object ) ; // Optimisation: let's see if we already performed the file_exists checks. $ cacheKey = md5 ( "FileBasedRenderer_" . $ this -> directory . '/' . $ fullClassName . '/' . $ context ) ; $ cachedValue = $ this -> cacheService -> get ( $ cacheKey ) ; if ( $ cachedValue !== null && ! $ this -> debugMode ) { return $ cachedValue ; } $ fileName = $ this -> findFile ( $ fullClassName , $ context ) ; $ parentClass = $ fullClassName ; // If no file is found, let's go through the parents of the object. while ( true ) { if ( $ fileName != false ) { break ; } $ parentClass = get_parent_class ( $ parentClass ) ; if ( $ parentClass == false ) { break ; } $ fileName = $ this -> findFile ( $ parentClass , $ context ) ; } // Still no objects? Let's browse the interfaces. if ( $ fileName == false ) { $ interfaces = class_implements ( $ fullClassName ) ; foreach ( $ interfaces as $ interface ) { $ fileName = $ this -> findFile ( $ interface , $ context ) ; if ( $ fileName != false ) { break ; } } } $ this -> cacheService -> set ( $ cacheKey , $ fileName ) ; return $ fileName ; }
Returns the filename of the template or false if no file found.

@param  object      $object
@param  string      $context
@return array<string,string>|null An array with 2 keys: "filename" and "type", or null if nothing found
Returns the filename of the template or false if no file found .