mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Return empty array when configuration cannot be loaded
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace Alchemy\Phrasea\Core\Provider;
|
namespace Alchemy\Phrasea\Core\Provider;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
|
||||||
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
@@ -37,25 +38,30 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var PropertyAccess $configuration */
|
try {
|
||||||
$configuration = $app['conf'];
|
/** @var PropertyAccess $configuration */
|
||||||
|
$configuration = $app['conf'];
|
||||||
|
|
||||||
$queueConfigurations = $configuration->get(['workers', 'queue'], $defaultConfiguration);
|
$queueConfigurations = $configuration->get(['workers', 'queue'], $defaultConfiguration);
|
||||||
|
|
||||||
$queueConfiguration = reset($queueConfigurations);
|
$queueConfiguration = reset($queueConfigurations);
|
||||||
$queueKey = key($queueConfigurations);
|
$queueKey = key($queueConfigurations);
|
||||||
|
|
||||||
if (! isset($queueConfiguration['name'])) {
|
if (! isset($queueConfiguration['name'])) {
|
||||||
if (! is_string($queueKey)) {
|
if (! is_string($queueKey)) {
|
||||||
throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.');
|
throw new \RuntimeException('Invalid queue configuration: configuration has no key or name.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$queueConfiguration['name'] = $queueKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queueConfiguration['name'] = $queueKey;
|
$config = [ $queueConfiguration['name'] => $queueConfiguration ];
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
catch (RuntimeException $exception) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = [ $queueConfiguration['name'] => $queueConfiguration ];
|
|
||||||
|
|
||||||
return $config;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +74,6 @@ class WorkerConfigurationServiceProvider implements ServiceProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function boot(Application $app)
|
public function boot(Application $app)
|
||||||
{
|
{
|
||||||
// TODO: Implement boot() method.
|
// No-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user