Get the list of templates available. Returns an array of associative arrays

e.g.

array(
array(
'id' => 'home',
'title' => 'Home',
),
array(
'id' => 'about-us',
'title' => 'About Us'
)
);

@return array
10077
public function getTemplates()
    {
        $templates = array();

        if ($handle = opendir(Primer::$PATTERN_PATH . '/templates')) {
            while (false !== ($entry = readdir($handle))) {
                if (substr($entry, 0, 1) !== '.') {
                    $templates[] = array(
                        'id' => $entry,
                        'title' => preg_replace('/[^A-Za-z0-9]/', ' ', $entry),
                    );
                }
            }

            closedir($handle);
        }

        return $templates;
    }
557701
public function buildTemplate()
    {
        if (!empty($this->template)) {
            return $this->template;
        }

        $columns = [];
        foreach ($this->columnTemplateBuilders as $columnTemplateBuilder) {
            $columns[] = $columnTemplateBuilder->buildTemplate();
        }

        $this->template = [
            'type' => 'image_carousel',
            'columns' => $columns,
        ];

        return $this->template;
    }
540770
public function toArray()
        {
            return array_merge(
                $this->getCustomProperties(),
                array(
                    'label'             => $this->getlabel(),
                    'fragment'          => $this->getFragment(),
                    'id'                => $this->getId(),
                    'class'             => $this->getClass(),
                    'title'             => $this->getTitle(),
                    'target'            => $this->getTarget(),
                    'accesskey'         => $this->getAccesskey(),
                    'rel'               => $this->getRel(),
                    'rev'               => $this->getRev(),
                    'customHtmlAttribs' => $this->getCustomHtmlAttribs(),
                    'order'             => $this->getOrder(),
                    'resource'          => $this->getResource(),
                    'privilege'         => $this->getPrivilege(),
                    'active'            => $this->isActive(),
                    'visible'           => $this->isVisible(),
                    'type'              => get_class($this),
                    'pages'             => parent::toArray()
                )
            );
        }
795098
public function getWidgetMapsForViewAndTemplates()
    {
        $widgetMaps = [];

        foreach ($this->getWidgetMaps() as $_widgetMap) {
            $widgetMaps[] = $_widgetMap;
        }

        if ($template = $this->getTemplate()) {
            $templateWidgetMaps = $template->getWidgetMapsForViewAndTemplates();
            $widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
        }

        return $widgetMaps;
    }
321735
public static function allTemplates()
    {
        $result = [];
        $codes = array_keys(self::listAllTemplates());

        foreach ($codes as $code) {
            $result[] = self::findOrMakeTemplate($code);
        }

        return $result;
    }
257984
public function getTemplateVariables()
	{
		return array_merge($this->template_variables, [
			'options' => $this->getOptions(),
			'column' => $this->getColumn(),
			'key' => $this->getKey(),
			'status' => $this,
		]);
	}
637728
public function getArrguments()
    {
        return [
            'model-name' => $this->modelName,
            '--table-name' => $this->tableName,
            '--connection-name' => $this->connectionName,
            '--engine-name' => $this->engineName,
            '--resource-file' => $this->resourceFile,
            '--template-name' => $this->template,
            '--without-timestamps' => $this->withoutTimestamps,
            '--with-soft-delete' => $this->withSoftDelete,
        ];
    }
371440
public function getTemplateAccessors() {
		if($this->templateAccessors) return $this->templateAccessors;
		
		$vars = parent::getTemplateAccessors();


		$cc = new ReflectionClass('ContentController');
		$site_tree = new ReflectionClass('SiteTree');
		$hierarchy = new ReflectionClass('Hierarchy');
		
		$methods = array_merge(
			$site_tree->getMethods(), 
			$cc->getMethods(),
			$hierarchy->getMethods(),
			array_keys(singleton('SiteTree')->has_many()),
			array_keys(singleton('SiteTree')->many_many()),
			array_keys(singleton('SiteTree')->db()),
			array_keys(DataObject::config()->fixed_fields)
		);		
		
		foreach($methods as $m) {
			$name = is_object($m) ? $m->getName() : $m;
			// We only care about methods that follow the UpperCamelCase convention.
			if(preg_match("/[A-Z]/",$name[0])) {
				$vars[] = $name;
			}
		}
		// Just a random exception case
		$vars[] = "Form";

		return $this->templateAccessors = $vars;
	}
1107185
function loadTemplates()
    {
        $result[0] = array();
        $result[1] = array();
        $templates = Templates::getInstance();
        $list = $templates->enum();
        $result[0]= array_values($list);
        $result[1]= array_keys($list);
        return $result;
    }
1194362
protected function getTemplateQtiVariables(){

        $variables = parent::getTemplateQtiVariables();

        $tag = static::$qtiTagName;

        //search existing mathML ns declaration:
        $ns = $this->getXIncludeNamespace();
        if(empty($ns)){
            //add one!
            $relatedItem = $this->getRelatedItem();
            if(!is_null($relatedItem)){
                $ns = 'xi';
                $relatedItem->addNamespace($ns, 'http://www.w3.org/2001/XInclude');
            }
        }
        if(!empty($ns)){
            //proceed to ns addition:
            $tag = $ns.':'.$tag;
        }

        $variables['tag'] = $tag;

        return $variables;
    }
1061046
public function getApiTemplateList()
    {
        $url = $this->getApiEndpoint() . self::REST_TEMPLATES;
        $this->setUrl($url)
            ->setVerb('GET');
        $response = $this->execute();

        if (isset($response->message)) {
            $message = 'GET API CONTACT LIST ' . $response->message;
            $this->helper->debug('getApiTemplateList', [$message]);
        }

        return $response;
    }
1300579
protected static function pluginsWithTemplates(): array
    {
        $plugins = Plugin::loaded();

        array_walk($plugins, function ($plugin, $index) use (&$plugins) {
            $paths = App::path('Template', $plugin);

            array_walk($paths, function ($path, $index) use (&$paths) {
                if (!is_dir($path)) {
                    unset($paths[$index]);
                }
            });
        });

        return $plugins;
    }
1366228
private function getTemplateList()
    {
        $templates = $this->getAvailableTemplates($this->bundle);

        $types = array();
        foreach ($templates as $key => $template) {
            $types[$key] = $template['name'];
        }

        return $types;
    }
575920
public function getTemplate()
    {
        if (! $this->_template instanceof LibBaseTemplateAbstract) {
            //Make sure we have a template identifier
            if (! ($this->_template instanceof AnServiceIdentifier)) {
                $this->setTemplate($this->_template);
            }

            $config = array(
                'view' => $this
            );

            $this->_template = $this->getService($this->_template, $config);
        }

        return $this->_template;
    }
92731
public static function all(): array
    {
        $sections = [];

        foreach (App::path('Template') as $path) {
            if (is_dir($path)) {
                $sections['APP'] = $sections['APP'] ?? [];
                $sections['APP'] = array_merge($sections['APP'], static::iteratePath($path));
            }
        }

        foreach (static::pluginsWithTemplates() as $plugin) {
            foreach (App::path('Template', $plugin) as $path) {
                if (is_dir($path)) {
                    $sections[$plugin] = $sections[$plugin] ?? [];
                    $sections[$plugin] = array_merge($sections[$plugin], static::iteratePath($path));
                }
            }
        }

        return static::clearEmptySections($sections);
    }
1028360
public function getMailTemplate()
    {
        $chunks = explode('\\', get_class($this));
        $className = array_pop($chunks);

        return [
            uncamelcase($className),
            'community_translation',
        ];
    }
876438
public function showTemplates()
		{
			$form_data = array(
				'headers' => 1
			);
			$data = $this->call('show_templates', $form_data, 'csv');
			$csv = new \parseCSV($data);

			$templates = array();

			foreach ($csv->data as $template_item) {
				$template = new Template;
				$template
					->setTemplateId((int)$template_item['Template Number'])
					->setName((string)$template_item['Template Name'])
					->setFolderId((int)$template_item['Folder ID']);
				$templates[] = $template;
			}

			return $templates;
		}