fixes for crash during the installation
This commit is contained in:
parent
48c92c3e2b
commit
a26a801798
7 changed files with 41 additions and 4 deletions
|
@ -1,5 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/servicelocator.php';
|
||||
require_once __DIR__ . '/../../lib/service/utils.php';
|
||||
|
||||
class RCrmActions
|
||||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
|
@ -227,7 +234,7 @@ class RCrmActions
|
|||
public static function clearArr($arr)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->clearArray($arr);
|
||||
}
|
||||
|
||||
|
@ -240,7 +247,7 @@ class RCrmActions
|
|||
public static function toJSON($str)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->toUTF8($str);
|
||||
}
|
||||
|
||||
|
@ -253,7 +260,7 @@ class RCrmActions
|
|||
public static function fromJSON($str)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->fromUTF8($str);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/configprovider.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/constants.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/dependencyloader.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
|
|
@ -156,7 +156,8 @@ trait CustomersTrait
|
|||
*
|
||||
* @return CustomerChangeResponse|null
|
||||
*/
|
||||
public function customersEdit(CustomersEditRequest $request): ?CustomerChangeResponse {
|
||||
public function customersEdit(CustomersEditRequest $request): ?CustomerChangeResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->customersEdit($serialized['customer'], $request->by, $request->site);
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
*/
|
||||
namespace Intaro\RetailCrm\Component;
|
||||
|
||||
use CModule;
|
||||
use RCrmActions;
|
||||
|
||||
/**
|
||||
* Class DependencyLoader
|
||||
*
|
||||
|
|
|
@ -85,7 +85,27 @@ class ServiceLocator
|
|||
{
|
||||
return static::$services[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create service (instantiates service if it wasn't created earlier; $name must be FQN).
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getOrCreate(string $name)
|
||||
{
|
||||
$service = static::$services[$name];
|
||||
|
||||
if (null === $service) {
|
||||
static::$services[$name] = new $name();
|
||||
return static::$services[$name];
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets service into ServiceContainer.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue