/** * (PHP 5 >= 5.0.0)<br/> * Return the current element * @link http://php.net/manual/en/iterator.current.php * @return mixed Can return any type. */ public function current() { $collection = clone $this->collectionInstance; $collection->writeAttributes((array) $this->cursor->current()); if ($this->fields) { $collection->setCursorFields($this->fields); } if ($collection::isLazyLoadingEnabled()) { $proxyClass = ProxyBuilder::getLazyLoadingClass(get_class($collection), Di::getDefault()); ProxyBuilder::assignProxyValues($proxyClass, $collection); $collection = $proxyClass; } else { $collection->map(); } return $collection; }
public function testShouldCheckValidUserClassName() { $proxy = ProxyBuilder::getLazyLoadingClass(Proxy::class, Di::getDefault()); $this->assertEquals(0, strpos(get_class($proxy), Helper::PROXY_NAMESPACE . Helper::PROXY_CONST . Helper::getUserClassName(Proxy::class))); }
/** * @param $value * @return mixed */ protected static function ensureMappingCache($value) { $calledClass = get_called_class(); $cacheKey = sprintf('%s:%s', $calledClass, $value); if (!isset(static::$lazyLoadingCache[$cacheKey])) { $collection = static::findById($value); if ($collection && isset(static::$lazyLoading[$calledClass]) && static::$lazyLoading[$calledClass] == true) { $proxyClass = ProxyBuilder::getLazyLoadingClass($calledClass, Di::getDefault()); ProxyBuilder::assignProxyValues($proxyClass, $collection); $collection = $proxyClass; } static::$lazyLoadingCache[$cacheKey] = $collection; } return static::$lazyLoadingCache[$cacheKey]; }