public function getEmailTemplateDropdownValues()
    {
        $templates = [];

        $finder = new FileFinder();
        $finder->setOption('name_regex', '/^.*\.ss$/');

        $parent = $this->getFormParent();

        if (!$parent) {
            return [];
        }

        $emailTemplateDirectory = $parent->config()->get('email_template_directory');
        $templateDirectory = ModuleResourceLoader::resourcePath($emailTemplateDirectory);

        if (!$templateDirectory) {
            return [];
        }

        $found = $finder->find(BASE_PATH . DIRECTORY_SEPARATOR . $templateDirectory);

        foreach ($found as $key => $value) {
            $template = pathinfo($value);
            $absoluteFilename = $template['dirname'] . DIRECTORY_SEPARATOR . $template['filename'];

            // Optionally remove vendor/ path prefixes
            $resource = ModuleResourceLoader::singleton()->resolveResource($emailTemplateDirectory);
            if ($resource instanceof ModuleResource && $resource->getModule()) {
                $prefixToStrip = $resource->getModule()->getPath();
            } else {
                $prefixToStrip = BASE_PATH;
            }
            $templatePath = substr($absoluteFilename, strlen($prefixToStrip) + 1);

            // Optionally remove "templates/" prefixes
            if (preg_match('/(?<=templates\/).*$/', $templatePath, $matches)) {
                $templatePath = $matches[0];
            }

            $templates[$templatePath] = $template['filename'];
        }

        return $templates;
    }
public function getEmailTemplateDropdownValues()
    {
        $templates = [];

        $finder = new FileFinder();
        $finder->setOption('name_regex', '/^.*\.ss$/');

        $parent = $this->getFormParent();

        if (!$parent) {
            return [];
        }

        $emailTemplateDirectory = $parent->config()->get('email_template_directory');
        $templateDirectory = ModuleResourceLoader::resourcePath($emailTemplateDirectory);

        if (!$templateDirectory) {
            return [];
        }

        $found = $finder->find(BASE_PATH . DIRECTORY_SEPARATOR . $templateDirectory);

        foreach ($found as $key => $value) {
            $template = pathinfo($value);
            $absoluteFilename = $template['dirname'] . DIRECTORY_SEPARATOR . $template['filename'];

            // Optionally remove vendor/ path prefixes
            $resource = ModuleResourceLoader::singleton()->resolveResource($emailTemplateDirectory);
            if ($resource instanceof ModuleResource && $resource->getModule()) {
                $prefixToStrip = $resource->getModule()->getPath();
            } else {
                $prefixToStrip = BASE_PATH;
            }
            $templatePath = substr($absoluteFilename, strlen($prefixToStrip) + 1);

            // Optionally remove "templates/" prefixes
            if (preg_match('/(?<=templates\/).*$/', $templatePath, $matches)) {
                $templatePath = $matches[0];
            }

            $templates[$templatePath] = $template['filename'];
        }

        return $templates;
    }
public function getEmailTemplateDropdownValues ( ) { $ templates = [ ] ; $ finder = new FileFinder ( ) ; $ finder -> setOption ( 'name_regex' , '/^.*\.ss$/' ) ; $ parent = $ this -> getFormParent ( ) ; if ( ! $ parent ) { return [ ] ; } $ emailTemplateDirectory = $ parent -> config ( ) -> get ( 'email_template_directory' ) ; $ templateDirectory = ModuleResourceLoader :: resourcePath ( $ emailTemplateDirectory ) ; if ( ! $ templateDirectory ) { return [ ] ; } $ found = $ finder -> find ( BASE_PATH . DIRECTORY_SEPARATOR . $ templateDirectory ) ; foreach ( $ found as $ key => $ value ) { $ template = pathinfo ( $ value ) ; $ absoluteFilename = $ template [ 'dirname' ] . DIRECTORY_SEPARATOR . $ template [ 'filename' ] ; // Optionally remove vendor/ path prefixes $ resource = ModuleResourceLoader :: singleton ( ) -> resolveResource ( $ emailTemplateDirectory ) ; if ( $ resource instanceof ModuleResource && $ resource -> getModule ( ) ) { $ prefixToStrip = $ resource -> getModule ( ) -> getPath ( ) ; } else { $ prefixToStrip = BASE_PATH ; } $ templatePath = substr ( $ absoluteFilename , strlen ( $ prefixToStrip ) + 1 ) ; // Optionally remove "templates/" prefixes if ( preg_match ( '/(?<=templates\/).*$/' , $ templatePath , $ matches ) ) { $ templatePath = $ matches [ 0 ] ; } $ templates [ $ templatePath ] = $ template [ 'filename' ] ; } return $ templates ; }
Gets a list of email templates suitable for populating the email template dropdown.

@return array
Gets a list of email templates suitable for populating the email template dropdown .