forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FINNA-2865] Add site status bar (#3090)
- Loading branch information
Showing
10 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* Site status enum. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) The National Library of Finland 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Site | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
|
||
namespace Finna\Site; | ||
|
||
/** | ||
* Site status enum. | ||
* | ||
* @category VuFind | ||
* @package Site | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
enum SiteStatus: string | ||
{ | ||
case BETA = 'beta'; | ||
case DISABLED = 'disabled'; | ||
case PRODUCTION = 'production'; | ||
case TEST = 'test'; | ||
|
||
/** | ||
* Return a translation key representing the status. | ||
* | ||
* @return string | ||
*/ | ||
public function getTranslationKey(): string | ||
{ | ||
return 'site_status_' . $this->value; | ||
} | ||
|
||
/** | ||
* Return a CSS class representing the status. | ||
* | ||
* @return string | ||
*/ | ||
public function getCssClass(): string | ||
{ | ||
return 'site-status-' . $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/** | ||
* Site status helper class. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) The National Library of Finland 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package View_Helpers | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
|
||
namespace Finna\View\Helper\Root; | ||
|
||
use Finna\Site\SiteStatus as SiteStatusEnum; | ||
|
||
/** | ||
* Site status helper class. | ||
* | ||
* @category VuFind | ||
* @package View_Helpers | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
class SiteStatus extends \Laminas\View\Helper\AbstractHelper | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param array $config Configuration | ||
*/ | ||
public function __construct(protected array $config) | ||
{ | ||
} | ||
|
||
/** | ||
* Return site status. | ||
* | ||
* @return SiteStatusEnum | ||
*/ | ||
public function __invoke(): SiteStatusEnum | ||
{ | ||
return SiteStatusEnum::tryFrom($this->config['Finna']['site_status'] ?? '') | ||
?? SiteStatusEnum::PRODUCTION; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
module/Finna/src/Finna/View/Helper/Root/SiteStatusFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/** | ||
* Site status helper factory. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) The National Library of Finland 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package View_Helpers | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
|
||
namespace Finna\View\Helper\Root; | ||
|
||
use Laminas\ServiceManager\Exception\ServiceNotCreatedException; | ||
use Laminas\ServiceManager\Exception\ServiceNotFoundException; | ||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
use Psr\Container\ContainerExceptionInterface as ContainerException; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* Site status helper factory. | ||
* | ||
* @category VuFind | ||
* @package View_Helpers | ||
* @author Aleksi Peebles <aleksi.peebles@helsinki.fi> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki | ||
*/ | ||
class SiteStatusFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create an object | ||
* | ||
* @param ContainerInterface $container Service manager | ||
* @param string $requestedName Service being created | ||
* @param null|array $options Extra options (optional) | ||
* | ||
* @return object | ||
* | ||
* @throws ServiceNotFoundException if unable to resolve the service. | ||
* @throws ServiceNotCreatedException if an exception is raised when | ||
* creating a service. | ||
* @throws ContainerException if any other error occurs | ||
*/ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
$requestedName, | ||
array $options = null | ||
) { | ||
if (!empty($options)) { | ||
throw new \Exception('Unexpected options sent to factory.'); | ||
} | ||
$config = $container->get(\VuFind\Config\PluginManager::class) | ||
->get('config')->toArray(); | ||
return new $requestedName($config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters