Get Jentil templates directory

@param string $type 'path' or 'url'.
@param string $form 'relative' or 'absolute'.
184635
public function templatesDir(
        string $type,
        string $append = '',
        string $form = ''
    ): string {
        return $this->_dir($type, "/app/templates{$append}", $form);
    }
117811
public function templates($type)
    {
        $data      = [];
        $extension = $this->repository->findOrFail($type);
        foreach ($extension->param('templates') as $template) {
            $data[] = ['key' => $template['path'], 'value' => $template['description']];
        }

        return response()->json([
            'template' => $data[0]['key'],
            'selected' => $type,
            'data'     => $data,
        ], 200);
    }
212748
public function get($type, $file = null)
    {
        if (!isset($this->paths[$type])) {
            $method = 'get'.Utils::camelize($type).'Dir';

            if (!method_exists($this, $method)) {
                return null;
            }

            $this->set($type, $this->$method());
        }

        $path = $this->paths[$type];
        if ($file) {
            if ($path instanceof pathmanager\FallbackInterface) {
                $path = $path->resolve($file);
            } else {
                $path .= '/' . ltrim($file, '/');
            }
        }

        return $path;
    }
887116
public function tabBuilder(\samsoncms\app\material\form\Form & $form)
    {
        // If we have related structures
        if (count($form->navigationIDs)) {
            // Get all gallery additional field for material form structures
            $galleryFields = $this->query->entity(\samsoncms\api\Field::class)
                ->where('Type', 9)
                ->join('structurefield')
                ->where('structurefield_StructureID', $form->navigationIDs)
                ->exec();

            // Create tab for each additional gallery field
            foreach ($galleryFields as $field) {
                $form->tabs[] = new Gallery($this, $this->query, $form->entity, $field);
            }
        }
    }
778642
public function render(Form $form, $mode = null): string
	{
		$usedPrimary = false;

		$form->getElementPrototype()->setNovalidate(true);

		foreach ($form->getControls() as $control) {

			if ($control instanceof Controls\BaseControl
				&& !($control instanceof Controls\Checkbox)
				&& !($control instanceof Controls\CheckboxList)
				&& !($control instanceof Controls\RadioList)) {
				$control->getLabelPrototype()->addClass('col-form-label col col-sm-3');
			}

			switch (true) {
				case $control instanceof Controls\Button:
					/** @var string|null $class */
					$class = $control->getControlPrototype()->getAttribute('class');
					if ($class === null || mb_strpos($class, 'btn') === false) {
						$control->getControlPrototype()->addClass($usedPrimary === false ? 'btn btn-primary' : 'btn btn-secondary');
						$usedPrimary = true;
					}
					break;

				case $control instanceof Controls\TextBase:
				case $control instanceof Controls\SelectBox:
				case $control instanceof Controls\MultiSelectBox:
					$control->getControlPrototype()->addClass('form-control');
					break;

				case $control instanceof Controls\Checkbox:
				case $control instanceof Controls\CheckboxList:
				case $control instanceof Controls\RadioList:
					$control->getSeparatorPrototype()->setName('div')->addClass('form-check');
					$control->getControlPrototype()->addClass('form-check-input');
					$control->getLabelPrototype()->addClass('form-check-label');
					break;
			}
		}

		return parent::render($form, $mode);
	}
1326002
public function define_form(&$form) {
        $form->addElement('header', '_commonsettings', get_string('profilecommonsettings', 'admin'));
        $this->define_form_common($form);

        $form->addElement('header', '_specificsettings', get_string('profilespecificsettings', 'admin'));
        $this->define_form_specific($form);
    }
983786
public function formAction(Request $request, $type)
    {
        $this->buildBreadcrumbs($type);

        $form = $this->createForm('clastic_settings', array('module' => $type));
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            $request->getSession()
                ->getFlashBag()
                ->add('success', 'Your changes were saved!');

            return $this->redirect($request->getPathInfo());
        }

        return $this->render('ClasticBackofficeBundle:Settings:form.html.twig', array(
            'form' => $form->createView(),
            'module' => $this->getModuleManager()->getModule($type),
        ));
    }
206179
function getExportScriptPath( $type ) {

		$fullpath = false;

		if ( CustomCss::isCustomCss() ) {
			$fullpath = CustomCss::getCustomCssFolder() . "/$type.js";
			if ( ! is_file( $fullpath ) ) {
				$fullpath = false;
			}
		}

		if ( ! $fullpath ) {
			$dir = Container::get( 'Styles' )->getDir();
			if ( Container::get( 'Styles' )->isCurrentThemeCompatible( 2 ) ) {
				// Check for v2 themes
				$fullpath = realpath( "$dir/assets/scripts/$type/script.js" );
			} else {
				$fullpath = realpath( "$dir/export/$type/script.js" );
			}
			if ( CustomCss::isCustomCss() && CustomCss::isRomanized() && 'prince' === $type ) {
				$fullpath = realpath( get_stylesheet_directory() . "/export/$type/script-romanize.js" );
			}
		}

		return $fullpath;
	}
90404
public static function getConfigTypeDir(?string $type = ''): ?string
    {
        $subdir = null;
        $type = Inflector::underscore(Inflector::pluralize($type));

        if (!in_array($type, ['events', 'attendees', 'calendars'])) {
            throw new InvalidArgumentException((string)__('Wrong Config Calendar Type'));
        }

        if ('calendars' == $type) {
            $subdir = 'calendar';
        }

        if ('events' == $type) {
            $subdir = 'calendar_' . $type;
        }

        if ('attendees' == $type) {
            $subdir = 'calendar_' . $type;
        }

        return $subdir;
    }
131718
public function setObjectACLFromForm($entity, $form, $type)
    {
        $aces = $form->get('ace')->getData();
        $this->setObjectACL($entity, $aces, $type);
    }
213894
public function vendorDir(
        string $type,
        string $append = '',
        string $form = ''
    ): string {
        $rel_dir = \explode('/', $this->relativeDir());
        $vendor = \reset($rel_dir) ?: 'vendor';

        return 'relative' === $form ?
            "{$vendor}{$append}" :
            $this->themeDir($type, "/{$vendor}{$append}");
    }
1221180
public function setActionUrl(Form $form)
    {

        $current = explode('/', rtrim($this->urlProvider->currentUrl(), '/'));

        $lastSegment = array_pop($current);

        if (in_array($lastSegment, ['create','edit'])) {

            $parentUrl = implode('/', $current);

            $form->setAction($parentUrl);

        } else {
            $form->setAction($this->urlProvider->currentUrl());
        }

        if ($lastSegment == 'create') {
            $form->setVerb('post');
            return;
        }

        if($lastSegment == 'edit') {
            $form->setVerb('put');
            return;
        }

    }
1069221
public static function getConfigByType($type)
	{
		$configPath = null;

		try {
			$templatePaths = CustomTemplate::getTemplates($type);
			if (!empty($templatePaths[0])) {
				$configPath = substr($templatePaths[0], 0, -6) . '_config.php';
			}
		}
		catch (\Exception $e) {
			$configPath = null;
		}

		if ($configPath === null || !file_exists($configPath)) {
			$allConfigs = array_merge(
				glob(TL_ROOT . '/templates/' . $type . '_config.php') ?: array(),
				glob(TL_ROOT . '/templates/*/' . $type . '_config.php') ?: array()
			);
			if (count($allConfigs)) {
				$configPath = $allConfigs[0];
			}
			else {
				return;
			}
		}

		$config = include $configPath;

		if ($config) {
			$config['fields'] = is_array($config['fields']) ? $config['fields'] : array();
		}

		return $config;
	}
261665
public function getForm($type)
    {
        $arguments = array();
        switch (strtolower($type)) {
            case 'config':
                $class = 'Config';
                $arguments[] = $this->getService();
                break;
            case 'advanced':
                $class = 'AdvancedConfig';
                $arguments[] = $this->getService();
                break;
            case 'batch':
                $class = 'Batch';
                $arguments[] = $this->getInvoiceManager();
                break;
            case 'invoice':
                $class = 'InvoiceStatusOverview';
                $arguments[] = $this->getInvoiceManager();
                $arguments[] = $this->getAcumulusEntryManager();
                $arguments[] = $this->getService();
                break;
            default;
                throw new \InvalidArgumentException("Unknown form type $type");
        }
        $arguments = array_merge($arguments, array(
            $this->getFormHelper(),
            $this->getShopCapabilities(),
            $this->getConfig(),
            $this->getTranslator(),
            $this->getLog(),
        ));
        /** @noinspection PhpIncompatibleReturnTypeInspection */
        return $this->getInstance($class . 'Form', 'Shop', $arguments);
    }
848631
public function includeFileFromManifest(string $fileName, string $type = 'legacy', $config = null): \Twig\Markup
    {
        return Template::raw(
            Twigpack::$plugin->manifest->getFileFromManifest($fileName, $type, $config)
        );
    }
805199
private function buildFallbackConfig(string $type, array $config): array
    {
        $type           = substr($type, 3);
        $fallbackConfig = $this->environment->getConfig()->get('form.layouts.' . $type, []);
        $fallbackConfig = ArrayUtil::merge($this->fallbackConfig, $fallbackConfig);

        foreach ($this->sections as $section) {
            $name = 'fallback' . ucfirst($section);

            if ($config[$name]) {
                $fallbackConfig['templates'][$section] = $config[$name];
            }
        }

        return $fallbackConfig;
    }
15839
public function getStructure(string $key, string $type = null): JsonResponse
    {
        try {
            $form = $this->formManager->getForm($key, $type);
        } catch (HCException $exception) {
            return $this->response->error($exception->getMessage());
        }

        return $this->response->success('OK', $form);
    }