Generate plugin headers.

@param string $name

@return array
776821
protected function generatePluginHeaders(string $name)
    {
        $description = $this->ask('Description:', '');
        $author = $this->ask('Author:', 'Themosis');
        $textdomain = $this->ask('Text domain:', trim($name, '\/-_'));
        $variable = strtoupper($this->ask('Domain variable:', 'PLUGIN_TD'));
        $prefix = $this->ask('Plugin prefix:', str_replace(['-', ' '], '_', $name));
        $namespace = $this->ask('PHP Namespace:', 'Tld\Domain\Plugin');

        return [
            'name' => ucwords(str_replace(['-', '_'], ' ', $name)),
            'description' => $description,
            'author' => $author,
            'text_domain' => $textdomain,
            'domain_var' => $variable,
            'plugin_prefix' => $prefix,
            'plugin_namespace' => $namespace,
            'plugin_id' => $name
        ];
    }
702261
function FindHeaders($name) {
        $result = array();
        //if ($name[0]<>'/') $name='/^'.$name.'$/';//If regex not found convert it to an "exact phrase" regex as default
        //Return header directly if not written as regular expression (separated for speed)
        if ($name[0] <> '/') {
            if (array_key_exists($name, $_SERVER)){
                $result[$name] = $_SERVER[$name];
            }
        }else {
            //Regular expression headers search
            foreach ($_SERVER as $key => $value) {
                if (preg_match($name, $key, $match)){
                    $result[$key] = $value;
                }
            }
        }
        return $result;
    }
921661
public function get($name)
	{
		$templates = $this->getTemplates();
		$form = $templates->get($name, $this->plugin->name, true);
		if ($form)
		{
			$form['title'] = $form['desc'];
			unset($form['desc']);
		}
		return $form;
	}
556500
public function getFormCode($name)
	{
		$templates = $this->getTemplates();
		return $templates->get($name, $this->plugin->name);
	}
452091
public function getHeader($name)
    {
        $name = strtolower($name);

        return $this->hasHeader($name) ? $this->headers[$name] : [];
    }
839281
private function getHeader($name, $headers)
    {
        $headers = array_change_key_case($headers);
        $name = strtolower($name);

        return isset($headers[$name]) ? (string) $headers[$name] : false;
    }
590089
public static function getPluginClass(string $name): string
    {
        $class = "";
        if (empty($name) === false && empty(self::$plugin_classes[$name]) === false) {
            $class = self::$plugin_classes[$name];
        }
        return $class;
    }
697314
public function plugin($name = null) {
        $this->out();

        $pluginName = $name ?: $this->args[0];
        $plugin = Admin::getPlugin($pluginName);

        if (!$plugin) {
            $this->err(sprintf('<error>%s plugin does not exist</error>', $pluginName));
            return;
        }

        $this->out(sprintf('<success>Installing %s...</success>', $pluginName));

        // Create parent object
        $parent_id = $this->ControlObject->addObject($pluginName);
        $adminAlias = Configure::read('Admin.aliases.administrator');

        // Create children objects
        foreach ($plugin['models'] as $model) {
            $this->out($model['title']);

            $this->ControlObject->addObject($model['id'], $parent_id);

            // Give admin access
            $this->Permission->allow($adminAlias, $pluginName . '/' . $model['id']);
        }

        $this->out(sprintf('<success>%s model ACOs installed</success>', $pluginName));
    }
99040
public function getAll($name = null)
    {
        if (!isset($name)) {
            $headers = [];
            foreach ($this->headers as $collection) {
                $headers = array_merge($headers, $collection);
            }

            return $headers;
        }

        $lowerName = strtolower($name);
        if (!array_key_exists($lowerName, $this->headers)) {
            return [];
        }

        return $this->headers[$lowerName];
    }
584024
public function getHeader($name, $all=false)
    {
        $nameLower = strtolower($name);
        if ($all) {
            $values = [];
            foreach ($this->_headers as &$h) {
                if ($h && strtolower($h[0]) == $nameLower) {
                    $values[] = $h[1];
                }
            }
            return $values;
        } else {
            foreach ($this->_headers as &$h) {
                if ($h && strtolower($h[0]) == $nameLower) {
                    return $h[1];
                }
            }
        }
        return null;
    }
214120
public function getHeaders(string $name = null)
    {
        if (is_null($name)) {
            return $this->get('headers');
        }

        return $this->get('headers', $name);
    }
295305
public function getHeader($name)
    {
        return isset($this->message['headers'][$name]) ? $this->message['headers'][$name] : null;
    }
369430
public function GenerateSource($header_name)
    {
        // Variables used by some template files.
        $authors = \Peg\Lib\Settings::GetAuthors();
        $contributors = \Peg\Lib\Settings::GetContributors();
        $extension = \Peg\Lib\Settings::GetExtensionName();
        $version = \Peg\Lib\Settings::GetVersion();

        $header_object = $this->symbols->headers[$header_name];
        $header_define = $this->GetHeaderDefine($header_name);
        $php_header_name = $this->GetHeaderNamePHP($header_name);

        $source_content = "";

        // Get heading of source file
        ob_start();
            include($this->GetTemplatePath(
                $header_name,
                "sources",
                "header",
                "helpers",
                "source"
            ));
            $source_content .= ob_get_contents();
        ob_end_clean();

        // Get constants function template content
        if($header_object->HasConstants() || $header_object->HasGlobalVariables())
        {
            // Constants function heading
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "constants",
                    "function_header",
                    "helpers",
                    "constant"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            foreach($header_object->namespaces as $namespace_name=>$namespace_object)
            {
                if($namespace_name == "\\")
                    $namespace_name = "";

                $namespace_name_cpp = str_replace(
                    "\\",
                    "::",
                    $namespace_name
                );

                $namespace_name_var = str_replace(
                    "\\",
                    "_",
                    $namespace_name
                );

                foreach($namespace_object->constants as $constant_name=>$constant_object)
                {
                    ob_start();
                        include($this->GetRegisterConstantTemplate($constant_name));
                        $source_content .= $this->Indent(ob_get_contents(), 4);
                    ob_end_clean();
                }

                foreach($namespace_object->global_variables as $constant_name=>$constant_object)
                {
                    ob_start();
                        include($this->GetRegisterVarConstantTemplate($constant_object));
                        $source_content .= $this->Indent(ob_get_contents(), 4);
                    ob_end_clean();
                }
            }

            // Constants function footer
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "constants",
                    "function_footer",
                    "helpers",
                    "constant"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            $source_content .= "\n";
        }

        // Get enums function template content
        if($header_object->HasEnumerations())
        {
            // Enums function heading
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "enums",
                    "function_header",
                    "helpers",
                    "enum"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            foreach($header_object->namespaces as $namespace_name=>$namespace_object)
            {
                if($namespace_name == "\\")
                    $namespace_name = "";

                $namespace_name_cpp = str_replace(
                    "\\",
                    "::",
                    $namespace_name
                );

                $namespace_name_var = str_replace(
                    "\\",
                    "_",
                    $namespace_name
                );

                foreach($namespace_object->enumerations as $enum_name=>$enum_object)
                {
                    ob_start();
                        include($this->GetTemplatePath(
                            $enum_name,
                            "enums",
                            "declare_class",
                            "helpers",
                            "enum",
                            $namespace_name
                        ));
                        $source_content .= $this->Indent(ob_get_contents(), 4);
                    ob_end_clean();

                    foreach($enum_object->options as $enum_option)
                    {
                        ob_start();
                            include($this->GetTemplatePath(
                                $enum_name,
                                "enums",
                                "declare_constant",
                                "helpers",
                                "enum",
                                $namespace_name
                            ));
                            $source_content .= $this->Indent(ob_get_contents(), 4);
                        ob_end_clean();
                    }
                }
            }

            // Enums function footer
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "enums",
                    "function_footer",
                    "helpers",
                    "enum"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            $source_content .= "\n";
        }

        // Get functions function template content
        if($header_object->HasFunctions())
        {
            // Generate function wrappers
            foreach($header_object->namespaces as $namespace_name=>$namespace_object)
            {
                foreach($namespace_object->functions as $function_name=>$function_object)
                {
                    $source_content .= $this->GenerateFunction($function_object);
                }
            }

            // Generate functions registration code

            // Functions registration heading
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "functions",
                    "function_header",
                    "helpers",
                    "function"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "functions",
                    "table_begin",
                    "helpers",
                    "function"
                ));
                $source_content .= $this->Indent(ob_get_contents(), 4);
            ob_end_clean();

            foreach($header_object->namespaces as $namespace_name=>$namespace_object)
            {
                if($namespace_name == "\\")
                    $namespace_name = "";

                $namespace_name_cpp = str_replace(
                    "\\",
                    "::",
                    $namespace_name
                );

                $namespace_name_var = str_replace(
                    "\\",
                    "_",
                    $namespace_name
                );

                foreach($namespace_object->functions as $function_name=>$function_object)
                {
                    ob_start();
                        include($this->GetTemplatePath(
                            $header_name,
                            "functions",
                            "table_entry",
                            "helpers",
                            "function"
                        ));
                        $source_content .= $this->Indent(ob_get_contents(), 8);
                    ob_end_clean();
                }
            }

            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "functions",
                    "table_end",
                    "helpers",
                    "function"
                ));
                $source_content .= $this->Indent(ob_get_contents(), 4);
            ob_end_clean();

            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "functions",
                    "table_register",
                    "helpers",
                    "function"
                ));
                $source_content .= $this->Indent(ob_get_contents(), 4);
            ob_end_clean();

            // Functions registration footer
            ob_start();
                include($this->GetTemplatePath(
                    $header_name,
                    "functions",
                    "function_footer",
                    "helpers",
                    "function"
                ));
                $source_content .= ob_get_contents();
            ob_end_clean();

            $source_content .= "\n";
        }

        // Get footer of source file
        ob_start();
            include($this->GetTemplatePath(
                $header_name,
                "sources",
                "footer",
                "helpers",
                "source"
            ));
            $source_content .= ob_get_contents();
        ob_end_clean();

        return $source_content;
    }
1082411
public function getPlugin($name)
    {
        if (!isset($this->plugins[$name])) {
            throw new \InvalidArgumentException(sprintf('Plugin %s is not registered'));
        }

        return $this->plugins[$name];
    }
704860
public function headers($name = null, $default = null)
    {
        if ($name) {
            return $this->request->headers->get($name, $default);
        }

        return $this->request->headers->all();
    }
1151434
public function getPlugin($name)
    {
        if (!$this->has($name)) {
            throw new PluginNotFoundException($name, array_keys($this->plugins));
        }

        return $this->plugins[$name];
    }
1369405
protected function getRequestHeader($Name)
    {
        $headers = self::getAllRequestHeaders();
        if (isset($headers[strtolower($Name)])) {
            return $headers[strtolower($Name)];
        }
        return false;
    }