throw d3DicException in case of errors
This commit is contained in:
parent
943adfaa5e
commit
afdb6ff4c1
@ -13,11 +13,13 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use D3\DIContainerHandler\d3DicException;
|
||||||
use D3\DIContainerHandler\d3DicHandler;
|
use D3\DIContainerHandler\d3DicHandler;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @return Container
|
||||||
|
* @throws d3DicException
|
||||||
*/
|
*/
|
||||||
function d3GetOxidDIC(): Container
|
function d3GetOxidDIC(): Container
|
||||||
{
|
{
|
||||||
|
29
d3DicException.php
Normal file
29
d3DicException.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* https://www.d3data.de
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
||||||
|
* @link https://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace D3\DIContainerHandler;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class d3DicException extends Exception
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Exception $previous
|
||||||
|
*/
|
||||||
|
public function __construct(Exception $previous)
|
||||||
|
{
|
||||||
|
parent::__construct($previous->getMessage(), $previous->getCode(), $previous);
|
||||||
|
}
|
||||||
|
}
|
@ -36,11 +36,12 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get instance
|
* get instance
|
||||||
*
|
* @return Container
|
||||||
* @throws Exception
|
* @throws d3DicException
|
||||||
*/
|
*/
|
||||||
public static function getInstance(): Container
|
public static function getInstance(): Container
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
$caller = $trace[1];
|
$caller = $trace[1];
|
||||||
$functionName = $caller['function'];
|
$functionName = $caller['function'];
|
||||||
@ -53,17 +54,21 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
$oDicHandler = oxNew(d3DicHandler::class);
|
$oDicHandler = oxNew(d3DicHandler::class);
|
||||||
self::$_instance = $oDicHandler->buildContainer();
|
self::$_instance = $oDicHandler->buildContainer();
|
||||||
}
|
}
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
throw new d3DicException($exception);
|
||||||
|
}
|
||||||
|
|
||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get instance
|
* get instance
|
||||||
*
|
* @return Container
|
||||||
* @throws Exception
|
* @throws d3DicException
|
||||||
*/
|
*/
|
||||||
public static function getUncompiledInstance(): Container
|
public static function getUncompiledInstance(): Container
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
$caller = $trace[1];
|
$caller = $trace[1];
|
||||||
$functionName = $caller['function'];
|
$functionName = $caller['function'];
|
||||||
@ -74,6 +79,9 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
|
|
||||||
$oDicHandler = oxNew(d3DicHandler::class);
|
$oDicHandler = oxNew(d3DicHandler::class);
|
||||||
self::$_instance = $oDicHandler->buildContainer(false);
|
self::$_instance = $oDicHandler->buildContainer(false);
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
throw new d3DicException($exception);
|
||||||
|
}
|
||||||
|
|
||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
@ -112,6 +120,8 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param ContainerBuilder $container
|
||||||
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function loadFiles(ContainerBuilder $container): void
|
public function loadFiles(ContainerBuilder $container): void
|
||||||
@ -138,11 +148,13 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param bool $compileAndDump
|
||||||
|
* @return Container
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function buildContainer(bool $compileAndDump = true): Container
|
public function buildContainer(bool $compileAndDump = true): Container
|
||||||
{
|
{
|
||||||
if ((bool) Registry::get(ConfigFile::class)->getVar('iDebug')) {
|
if (Registry::get(ConfigFile::class)->getVar('iDebug')) {
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +180,7 @@ class d3DicHandler implements d3DicHandlerInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bool) Registry::get(ConfigFile::class)->getVar('iDebug')) {
|
if (Registry::get(ConfigFile::class)->getVar('iDebug')) {
|
||||||
stopProfile(__METHOD__);
|
stopProfile(__METHOD__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user