mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
motd configuration
This commit is contained in:
parent
3b6e9da91a
commit
0eb538083a
@ -23,6 +23,12 @@ class Configuration implements ConfigurationInterface
|
||||
->root('nelmio_api_doc')
|
||||
->children()
|
||||
->scalarNode('name')->defaultValue('API documentation')->end()
|
||||
->arrayNode('motd')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('template')->defaultValue('NelmioApiDocBundle::Components/motd.html.twig')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('request_listener')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function ($a) { return is_bool($a); })
|
||||
|
@ -28,6 +28,7 @@ class NelmioApiDocExtension extends Extension
|
||||
$configuration = new Configuration();
|
||||
$config = $processor->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('nelmio_api_doc.motd.template', $config['motd']['template']);
|
||||
$container->setParameter('nelmio_api_doc.api_name', $config['name']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.enabled', $config['sandbox']['enabled']);
|
||||
$container->setParameter('nelmio_api_doc.sandbox.endpoint', $config['sandbox']['endpoint']);
|
||||
|
@ -55,6 +55,11 @@ class HtmlFormatter extends AbstractFormatter
|
||||
*/
|
||||
private $authentication;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $motdTemplate;
|
||||
|
||||
/**
|
||||
* @param array $authentication
|
||||
*/
|
||||
@ -119,6 +124,22 @@ class HtmlFormatter extends AbstractFormatter
|
||||
$this->defaultRequestFormat = $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $motdTemplate
|
||||
*/
|
||||
public function setMotdTemplate($motdTemplate)
|
||||
{
|
||||
$this->motdTemplate = $motdTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMotdTemplate()
|
||||
{
|
||||
return $this->motdTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -162,6 +183,7 @@ class HtmlFormatter extends AbstractFormatter
|
||||
'date' => date(DATE_RFC822),
|
||||
'css' => file_get_contents(__DIR__ . '/../Resources/public/css/screen.css'),
|
||||
'js' => file_get_contents(__DIR__ . '/../Resources/public/js/all.js'),
|
||||
'motdTemplate' => $this->motdTemplate
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@
|
||||
<call method="setTemplatingEngine">
|
||||
<argument type="service" id="templating" />
|
||||
</call>
|
||||
<call method="setMotdTemplate">
|
||||
<argument>%nelmio_api_doc.motd.template%</argument>
|
||||
</call>
|
||||
<call method="setApiName">
|
||||
<argument>%nelmio_api_doc.api_name%</argument>
|
||||
</call>
|
||||
|
3
Resources/views/Components/motd.html.twig
Normal file
3
Resources/views/Components/motd.html.twig
Normal file
@ -0,0 +1,3 @@
|
||||
<p id="colophon">
|
||||
Documentation auto-generated on {{ date }}
|
||||
</p>
|
@ -27,6 +27,7 @@
|
||||
</div>
|
||||
<br style="clear: both;" />
|
||||
</div>
|
||||
{% include motdTemplate %}
|
||||
<div class="container" id="resources_container">
|
||||
<ul id="resources">
|
||||
{% block content %}{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user