mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Defined config and implementation to delete short URLs
This commit is contained in:
@@ -26,6 +26,6 @@ class AppOptionsFactory implements FactoryInterface
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
{
|
||||
$config = $container->has('config') ? $container->get('config') : [];
|
||||
return new AppOptions(isset($config['app_options']) ? $config['app_options'] : []);
|
||||
return new AppOptions($config['app_options'] ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
34
module/Core/src/Options/DeleteShortUrlsOptions.php
Normal file
34
module/Core/src/Options/DeleteShortUrlsOptions.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Options;
|
||||
|
||||
use Zend\Stdlib\AbstractOptions;
|
||||
|
||||
class DeleteShortUrlsOptions extends AbstractOptions
|
||||
{
|
||||
private $visitsThreshold = 15;
|
||||
private $checkVisitsThreshold = true;
|
||||
|
||||
public function getVisitsThreshold(): int
|
||||
{
|
||||
return $this->visitsThreshold;
|
||||
}
|
||||
|
||||
protected function setVisitsThreshold(int $visitsThreshold): self
|
||||
{
|
||||
$this->visitsThreshold = $visitsThreshold;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function doCheckVisitsThreshold(): bool
|
||||
{
|
||||
return $this->checkVisitsThreshold;
|
||||
}
|
||||
|
||||
protected function setCheckVisitsThreshold(bool $checkVisitsThreshold): self
|
||||
{
|
||||
$this->checkVisitsThreshold = $checkVisitsThreshold;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
31
module/Core/src/Options/DeleteShortUrlsOptionsFactory.php
Normal file
31
module/Core/src/Options/DeleteShortUrlsOptionsFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Options;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Interop\Container\Exception\ContainerException;
|
||||
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
|
||||
use Zend\ServiceManager\Exception\ServiceNotFoundException;
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
|
||||
class DeleteShortUrlsOptionsFactory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create an object
|
||||
*
|
||||
* @param ContainerInterface $container
|
||||
* @param string $requestedName
|
||||
* @param null|array $options
|
||||
* @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)
|
||||
{
|
||||
$config = $container->has('config') ? $container->get('config') : [];
|
||||
return new DeleteShortUrlsOptions($config['delete_short_urls'] ?? []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user