Cache::callPoolOffset

@param string $method
@param array  $args

@return bool|mixed
974145
public function callPoolOffset($method, array $args = [])
    {
        $poolOffset = $this->poolOffset;

        if ( ! $this->exists($poolOffset)) {
            $poolOffset = 'default';
        }

        $itemPool = $this->getItemPool($poolOffset);

        if ($itemPool instanceof AbstractItemPool) {
            if (method_exists($itemPool, $method)) {
                return call_user_func_array([&$itemPool, $method], $args);
            }
        }

        return false;
    }
448115
public static function convertArgsToKV($class, $method, $args, $keepNotExistArgs = true)
    {
        $methodRef = new \ReflectionMethod($class, $method);

        $result = [];
    
        foreach($methodRef->getParameters() as $i => $param)
        {
            if(isset($args[$i]))
            {
                $result[$param->name] = $args[$i];
            }
            else if($keepNotExistArgs)
            {
                $result[$param->name] = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
            }
            else
            {
                break;
            }
        }

        if($param && $param->isVariadic())
        {
            $result[$param->name] = [$result[$param->name]];
            if(isset($args[$i + 1]))
            {
                $count = count($args);
                for($i += 1; $i < $count; ++$i)
                {
                    $result[$param->name][] = $args[$i];
                }
            }
        }
    
        return $result;
    }
547292
public static function callStatic($class, $method, $args = null)
    {
        $args   = \func_get_args();
        $class  = \array_shift($args);
        $method = \array_shift($args);

        $refl = new \ReflectionClass($class);
        $reflMethod = $refl->getMethod($method);
        $reflMethod->setAccessible(true);

        return $reflMethod->invokeArgs(null, $args);
    }
181370
private function extract(string $method, array $arguments)
    {
        try {
            $serializedArguments = serialize($arguments);
        } catch (\Exception $exception) {
            // If arguments are not serializable, skip the cache
            return $this->propertyInfoExtractor->{$method}(...$arguments);
        }

        // Calling rawurlencode escapes special characters not allowed in PSR-6's keys
        $encodedMethod = \rawurlencode($method);
        if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) {
            return $this->arrayCache[$encodedMethod][$serializedArguments];
        }

        $item = $this->cacheItemPool->getItem($encodedMethod);

        $data = $item->get();
        if ($item->isHit()) {
            $this->arrayCache[$encodedMethod] = $data[$encodedMethod];
            // Only match if the specific arguments have been cached.
            if (\array_key_exists($serializedArguments, $data[$encodedMethod])) {
                return $this->arrayCache[$encodedMethod][$serializedArguments];
            }
        }

        // It's possible that the method has been called, but with different
        // arguments, in which case $data will already be initialized.
        if (!$data) {
            $data = [];
        }

        $value = $this->propertyInfoExtractor->{$method}(...$arguments);
        $data[$encodedMethod][$serializedArguments] = $value;
        $this->arrayCache[$encodedMethod][$serializedArguments] = $value;
        $item->set($data);
        $this->cacheItemPool->save($item);

        return $this->arrayCache[$encodedMethod][$serializedArguments];
    }
87182
protected function proxy($method, $args)
    {

        // logic before executing the method
        //
        $this->beforeProxy($method, $args);
        
        // executing the domain method
        $result = call_user_func_array(array($this, $method), $args);


        // logic after executin the method
        //
        $this->afterProxy($method, $args, $result);

        // return the result of domain method
        return $result;
    }
1106966
public function callMethod($class, $method, array $args = array())
    {
        $method = $this->findMethod($class, $method);
        $method->setAccessible(true);

        return $method->invokeArgs(
            is_object($class) ? $class : null,
            $args
        );
    }
994923
public function cacheCallback($method, $args, Closure $callback, $time = null)
    {
        // Cache disabled, just execute query & return result
        if ($this->skippedCache() === true) {
            return call_user_func($callback);
        }

        // Use the called class name as the tag
        $tag = get_called_class();

        return self::getCacheInstance()->tags(['repositories', $tag])->remember(
            $this->getCacheKey($method, $args, $tag),
            $this->getCacheExpiresTime($time),
            $callback
        );
    }
820530
protected function callOnceAfterHooks($classInstance, $method, array $args = [])
    {
        $return = $this->callOnceAfterAllHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }

        $return = $this->callOnceAfterMethodHooks($classInstance, $method, $args);

        if ($return !== null) {
            return $return;
        }
    }
1207954
public function each($method, ...$args)
    {
        if ($this->count() === 0) {
            return 0;
        }
        $n = 0;
        foreach ($this as $obj) {
            $obj->$method(...$args);
            ++$n;
        }
        return $n;
    }
879144
protected function callWithRelation($method, $args, $entity)
    {
        $relation = $entity->callWith($method, $args, $entity, true);

        if (!$relation && prod()) {
            return null;
        }

        if ($this instanceof Collection) {
            $relation->fillCollection($this);
        } else if ($this instanceof Record) {
            $relation->fillRecord($this);
        }

        return $relation;
    }
63989
protected function payloadExec($method, $args = []) {
        $this->getPayloadInstance();
        if (method_exists($this->instance, $method)) {
            return $this->di->call([$this->instance, $method], $args);
        }
        return null;
    }
443292
public function cachedHelperCall($helper, $method, $cachedValue, $args = array())
    {
        if ($this->isActive() && !$this->getIsInternal()) {
            return $cachedValue;
        }
        
        $helper = Mage::helper($helper);
        
        if (!empty($args)) {
            return call_user_func_array(array($helper, $method), $args);
        }
        
        return $helper->$method();
    }
1136062
public function tryCall($method, $arguments)
    {
        if (isset($this->_hookTrait) && $ret = $this->hook('method-'.$method, $arguments)) {
            return $ret;
        }

        if (isset($this->_appScopeTrait) && isset($this->app->_hookTrait)) {
            array_unshift($arguments, $this);
            if ($ret = $this->app->hook('global-method-'.$method, $arguments)) {
                return $ret;
            }
        }
    }
1244536
public function apply($method, array $args = [])
    {
        $result = new Map;
        $this->walk(function ($object, $key) use ($method, $args, $result) {
            $result[$key] = call_user_func_array([$object, $method], $args);
        });
        return $result;
    }
1226188
protected function executeCallback($class, $method, $args, Closure $closure)
    {
        $skipUri = $this->getContainer('config')->get('rinvex.repository.cache.skip_uri');

        // Check if cache is enabled
        if ($this->getCacheLifetime() && ! $this->getContainer('request')->has($skipUri)) {
            return $this->cacheCallback($class, $method, $args, $closure);
        }

        // Cache disabled, just execute qurey & return result
        $result = call_user_func($closure);

        // We're done, let's clean up!
        $this->resetRepository();

        return $result;
    }
1300126
protected function cacheCallback($class, $method, $args, Closure $closure)
    {
        $repositoryId = $this->getRepositoryId();
        $lifetime     = $this->getCacheLifetime();
        $hash         = $this->generateCacheHash($args);
        $cacheKey     = $class.'@'.$method.'.'.$hash;

        // Switch cache driver on runtime
        if ($driver = $this->getCacheDriver()) {
            $this->getContainer('cache')->setDefaultDriver($driver);
        }

        // We need cache tags, check if default driver supports it
        if (method_exists($this->getContainer('cache')->getStore(), 'tags')) {
            $result = $lifetime === -1
                ? $this->getContainer('cache')->tags($repositoryId)->rememberForever($cacheKey, $closure)
                : $this->getContainer('cache')->tags($repositoryId)->remember($cacheKey, $lifetime, $closure);

            // We're done, let's clean up!
            $this->resetRepository();

            return $result;
        }

        // Default cache driver doesn't support tags, let's do it manually
        $this->storeCacheKeys($class, $method, $hash);

        $result = $lifetime === -1
            ? $this->getContainer('cache')->rememberForever($cacheKey, $closure)
            : $this->getContainer('cache')->remember($cacheKey, $lifetime, $closure);

        // We're done, let's clean up!
        $this->resetCachedRepository();

        return $result;
    }
663501
private function parseBefore($method, &$args)
    {
        $this->doAspect($method, 'before', function($aspectClassName, $methodName) use($method, &$args){
            $joinPoint = new JoinPoint('before', $method, $args, $this->object, $this);
            call_user_func([new $aspectClassName, $methodName], $joinPoint);
        });
    }