Skip to content

Commit

Permalink
[FEATURE] Provide agency info with typoscript
Browse files Browse the repository at this point in the history
  • Loading branch information
buepro committed Mar 8, 2023
1 parent cb7a01c commit 70ccdb3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 302 deletions.
17 changes: 13 additions & 4 deletions Classes/Controller/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,27 @@ static function (Site $site) use ($configurationRepository, $pageRepository) {
}

protected function getAgencyData(): array
{
$agencyData = $this->getAgencyDataFromSite() ?? $this->settings['agency'] ?? null;
if ($agencyData === null) {
return [];
}
if (isset($agencyData['phone'])) {
$agencyData['phone'] = preg_replace('#(\s|\.|\/|-|\(|\))#i', '', $agencyData['phone']) ?? '';
}
return $agencyData;
}

private function getAgencyDataFromSite(): ?array
{
$site = $this->request->getAttribute('site');
if (
$site instanceof Site &&
is_array($settings = $site->getAttribute('easyconf')) &&
is_array($agency = $settings['data']['admin']['agency'] ?? false)
) {
if (isset($agency['phone'])) {
$agency['phone'] = preg_replace('#(\s|\.|\/|-|\(|\))#i', '', $agency['phone']) ?? '';
}
return $agency;
}
return [];
return null;
}
}
41 changes: 30 additions & 11 deletions Documentation/Configuration/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,40 @@
Configuration
=============

Support information
===================
Agency information
==================

When closing the form editor an info panel is shown providing agency related
links. The links can be defined in the site configuration:
links. The links can be defined in the site configuration or in the typoscript
setup.

.. code-block:: yaml
.. tabs::

easyconf:
data:
admin:
agency:
email: bh@agency.ch
phone: '111 111 11 11'
url: 'https://www.agency.ch'
.. group-tab:: Site configuration

.. code-block:: yaml
easyconf:
data:
admin:
agency:
email: info@agency.ch
phone: '111 111 11 11'
url: 'https://www.agency.ch'
.. group-tab:: TypoScript setup

.. code-block:: typoscript
module.tx_easyconf {
settings {
agency {
url = info@agency.ch
phone = 111 111 11 11
email = https://www.agency.ch
}
}
}
TCA
===
Expand Down
288 changes: 1 addition & 287 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70ccdb3

Please sign in to comment.