config = $config; $this->url = $url; $this->cache = $cache; $this->container=$container; } public function getCallbackSandbox() { if(null === $this->sandbox){ $sandboxCacheDir =$this->container->has('config.params.dirs.runtime.cache') ? rtrim($this->container->get('config.params.dirs.runtime.cache'), DIRECTORY_SEPARATOR) .DIRECTORY_SEPARATOR .'sbxp-parsed-php-vm-scripts'.DIRECTORY_SEPARATOR : @getenv('FRDL_WORKSPACE') .DIRECTORY_SEPARATOR. 'runtime' .DIRECTORY_SEPARATOR . 'cache' .DIRECTORY_SEPARATOR. 'sbxp-parsed-php-vm-scripts' .DIRECTORY_SEPARATOR; $this->sandbox = (new Webfan\Transform\TransformCallbacks()) ->setupCachepath($sandboxCacheDir) ->setupSandbox( $this->container->has('runtime.context.sandbox.containers') ? $this->container->get('runtime.context.sandbox.containers') : [ 'container'=>$this->container, ], $this->container->has('config.runtime.security.sandbox.allowed-functions') ? $this->container->get('config.runtime.security.sandbox.allowed-functions') : [], $this->container->has('config.sandbox.runtime.security.allowed-classes') ? $this->container->get('config.sandbox.runtime.security.allowed-classes') : [] ) ->overwriteTokenCallback([$this, 'sk']); } return $this->sandbox; } public function setTimeout(int $timeout): self { $this->timeout=$timeout; return $this; } public function sk($id) { return static::scriptKey($id); } public static function scriptKey($id) { return 'containerDefinitionCallback'.preg_replace("/([^A-Za-z0-9])/", '', $id).'S'.strlen($id).'H'.sha1($id); } protected function proxy($func) { switch($func){ case 'get' : if(null === $this->_proxy_get){ $factory = new ProxyManager\Factory\RemoteObjectFactory( new ProxyManager\Factory\RemoteObject\Adapter\JsonRpc( new Laminas\Json\Server\Client($this->url, //['timeout' => 60,] new Laminas\Http\Client( $this->url, [ 'timeout' => $this->timeout, ] ) ) ), $this->config ); $this->_proxy_get = $factory->createProxy(IO4FallbackContainer::class); } return $this->_proxy_get; break; case 'has' : if(null === $this->_proxy_has){ $factory = new ProxyManager\Factory\RemoteObjectFactory( new ProxyManager\Factory\RemoteObject\Adapter\JsonRpc( new Laminas\Json\Server\Client($this->url, //['timeout' => 60,] new Laminas\Http\Client( $this->url, [ 'timeout' => $this->timeout, ] ) ) ), $this->config ); $this->_proxy_has = $factory->createProxy(IO4FallbackContainer::class); } return $this->_proxy_has; break; } } public function transform($payload, string $id) { $payloadRAW = $payload; try { $payload = -1!==(new Webfan\Transform\UrlsafeBinaryTransform)->detect($payload) ? $payload : (new Webfan\Transform\UrlsafeBinaryTransform)->down($payload); } catch (Exception $error) { $payload = $payloadRAW; } try { $payload = -1!==(new Webfan\Transform\OpisTranform)->detect($payload) ? $payload : (new Webfan\Transform\OpisTranform)->down($payload); } catch (Exception $error) { $payload = $payloadRAW; } $payload = -1!==$this->getCallbackSandbox( )->detect($payload) ? $payload : $this->getCallbackSandbox( )->down(call_user_func(function($payload) use($id){ $payload['token']=$id; return $payload; },$payload)); /* if(!is_null($payload) && is_object($payload) && $payload instanceof Opis\Closure\SerializableClosure && null !== $this->container && is_callable([$this->container, 'createInvoker']) ){ // $invoker= $this->container->get('container')->createInvoker( ); // $payload =$invoker->call($payload, ['container'=>$this->container->get('container')]); $payload=call_user_func_array($payload , [$this->container]); }else*/if(!is_null($payload) && is_object($payload) && $payload instanceof Opis\Closure\SerializableClosure && null !== $this->container ){ $payload=call_user_func_array($payload , [$this->container]); } return $payload; } public function get($id) { if(isset($this->resolved[$id])){ return $this->resolved[$id]; } $key = 'IO4FallbackContainerClient.get.'.sha1($id).'.'.strlen($id); $remoteResult = $this->cache->get($key); /* try { $remoteResult = isset($remoteResult) ? $remoteResult : $this->proxy(__FUNCTION__)->containerGetHas('get', $id); } catch (\Laminas\Http\Client\Adapter\Exception\RuntimeException $error) { throw $error; } */ if(!$remoteResult){ $remoteResult = $this->proxy(__FUNCTION__)->containerGetHas('get', $id); if($remoteResult){ $this->cache->set($key, $remoteResult, 3 * 60 * 60); } } if($remoteResult){ $this->resolved[$id] = $this->transform($remoteResult, $id); }else{ } /* if(null !== $this->container && is_object($this->resolved[$id]) && !is_null($this->resolved[$id]) && \method_exists($this->resolved[$id],'setContainer') ){ $class = new \ReflectionObject($this->resolved[$id]); $method = $class->getMethod('setContainer'); $params = $method->getParameters(); $returnType = $method->getReturnType(); $isWithContainerSetter = isset($params[0]) && \Psr\Container\ContainerInterface::class === (string) $params[0]->getType() ? true : false; if(true === $isWithContainerSetter){ \call_user_func_array([$this->resolved[$id], 'setContainer'], [$this->container]); } }//$isWithContainerSetter */ return $this->resolved[$id]; } public function has($id) { if(isset($this->resolved[$id]) && false !== $this->resolved[$id]){ return true; } if(isset($this->_has[$id])){ return is_array($this->_has[$id]) && isset($this->_has[$id]['has']) ? $this->_has[$id]['has'] : $this->_has[$id]; } try { $this->_has[$id] = $this->proxy('get')->containerGetHas('has', $id); } catch (Laminas\Http\Client\Adapter\Exception\RuntimeException $error) { throw $error; } $this->_has[$id] = is_array($this->_has[$id]) && isset($this->_has[$id]['has']) ? $this->_has[$id]['has'] : $this->_has[$id]; return isset($this->_has[$id]['has']) ? $this->_has[$id]['has'] : $this->_has[$id]; } } __halt_compiler();----SIGNATURE:----HONIqDTOYSeehav5QT6lFoi40Rk0c2XLn9EvF8RgxeX6IxkTNdQlVAocTQL6xxLHe2MNkZEGxXxQ3CR1gXOt/xmUGXdS/fiQCZ4gbz9QA8R47Mf0juLua++JFGeFAcBK3OnJshUbAMvQX3lNLYdRYewYGg9FYPYnOZKIOLDSHyzUxOdoIvSNtOF10fDTaJ5/3OLaG/vfFc09FKVrtOQWM+x6g2uiOaDOvJM6q4EtX4qBQsWQuH9lLTFIBl66IoHK7E/861arN/3WrPqWwuZJWwvVF+uplBIRtv8woAV7b8zNrfgoYsCe46JjuPt/eEBRebaJfUqx9k9/bFS9hTCT3JAbjuXlXDblnj9J4E+f1yck/aoqAJO9/yI/vFuLQeh5u//TovQm5Ox3q38DQlVlbgrjo6NASDNYP2k7UxS7o3J9GSZMu3CBIr0KqS9m6NdtD/kh2IXHfBBmTTV82W2HevAtVdOZ0gSr8SUUZ1YnQfKCdlyImmj8U06pqf0y/dhUTaGXkDdrwqp/UsTHjNU14kTzq1dn/kT0q/tLCpt6VGbvzIMQ85MfdHTWhDnRJ5Ym9vTVYkU17LjsQYO/ezIVcNAq1mSzB8zygmXcsH9+kFwpWIvnzy5os165ueLp4hWNu8QLiBZ0ZUZyyNANRJLn5H2s6sQgmEIwzI2hmxgqhVI=----ATTACHMENT:----OTk4ODQ0ODIzNzI1ODY2NiA5MDYzNTg0MDk2MDA4MzM2IDI3MjAxMTU4ODU0NzM5MTg=