@param ProxyGenerator $proxy

Ensure the search index is kept up to date by monitoring SilverStripe database manipulations
495929
public function updateProxy(ProxyGenerator &$proxy)
    {
        $proxy = $proxy->addMethod('manipulate', function ($args, $next) {
            $manipulation = $args[0];
            SearchUpdater::handle_manipulation($manipulation);
            return $next(...$args);
        });
    }
285269
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = [])
    {
        CanProxyAssertion::assertClassCanBeProxied($originalClass, false);

        $filteredProperties = Properties::fromReflectionClass($originalClass)
            ->filter($proxyOptions['skippedProperties'] ?? []);

        $publicProperties    = new PublicPropertiesMap($filteredProperties);
        $privateProperties   = new PrivatePropertiesMap($filteredProperties);
        $protectedProperties = new ProtectedPropertiesMap($filteredProperties);

        $classGenerator->setExtendedClass($originalClass->getName());
        $classGenerator->setImplementedInterfaces([GhostObjectInterface::class]);
        $classGenerator->addPropertyFromGenerator($initializer           = new InitializerProperty());
        $classGenerator->addPropertyFromGenerator($initializationTracker = new InitializationTracker());
        $classGenerator->addPropertyFromGenerator($publicProperties);
        $classGenerator->addPropertyFromGenerator($privateProperties);
        $classGenerator->addPropertyFromGenerator($protectedProperties);

        $init = new CallInitializer($initializer, $initializationTracker, $filteredProperties);

        array_map(
            static function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator) : void {
                ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod);
            },
            array_merge(
                $this->getAbstractProxiedMethods($originalClass),
                [
                    $init,
                    new StaticProxyConstructor($initializer, $filteredProperties),
                    new MagicGet(
                        $originalClass,
                        $initializer,
                        $init,
                        $publicProperties,
                        $protectedProperties,
                        $privateProperties,
                        $initializationTracker
                    ),
                    new MagicSet(
                        $originalClass,
                        $initializer,
                        $init,
                        $publicProperties,
                        $protectedProperties,
                        $privateProperties
                    ),
                    new MagicIsset(
                        $originalClass,
                        $initializer,
                        $init,
                        $publicProperties,
                        $protectedProperties,
                        $privateProperties
                    ),
                    new MagicUnset(
                        $originalClass,
                        $initializer,
                        $init,
                        $publicProperties,
                        $protectedProperties,
                        $privateProperties
                    ),
                    new MagicClone($originalClass, $initializer, $init),
                    new MagicSleep($originalClass, $initializer, $init),
                    new SetProxyInitializer($initializer),
                    new GetProxyInitializer($initializer),
                    new InitializeProxy($initializer, $init),
                    new IsProxyInitialized($initializer),
                ]
            )
        );
    }
825406
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('limitation');

        $generator->startAttribute('identifier', $data->getIdentifier());
        $generator->endAttribute('identifier');

        $generator->startObjectElement('values');
        $generator->startList('values');

        foreach ($data->limitationValues as $limitationValue) {
            $generator->startObjectElement('ref');
            $generator->startAttribute('href', $limitationValue);
            $generator->endAttribute('href');
            $generator->endObjectElement('ref');
        }

        $generator->endList('values');
        $generator->endObjectElement('values');

        $generator->endObjectElement('limitation');
    }
1315016
private function setProxy($proxy, $onlyProtocol = null)
    {
        $proxy = trim($proxy);
        if (null == $onlyProtocol) {
            $this->proxySettings['http'] = $proxy;
            $this->proxySettings['https'] = $proxy;
        } else {
            $this->proxySettings[$onlyProtocol] = $proxy;
        }
    }
1180658
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
    {
        CanProxyAssertion::assertClassCanBeProxied($originalClass);

        $publicProperties = new PublicPropertiesMap(Properties::fromReflectionClass($originalClass));
        $interfaces       = [AccessInterceptorValueHolderInterface::class];

        if ($originalClass->isInterface()) {
            $interfaces[] = $originalClass->getName();
        } else {
            $classGenerator->setExtendedClass($originalClass->getName());
        }

        $classGenerator->setImplementedInterfaces($interfaces);
        $classGenerator->addPropertyFromGenerator($valueHolder        = new ValueHolderProperty($originalClass));
        $classGenerator->addPropertyFromGenerator($prefixInterceptors = new MethodPrefixInterceptors());
        $classGenerator->addPropertyFromGenerator($suffixInterceptors = new MethodSuffixInterceptors());
        $classGenerator->addPropertyFromGenerator($publicProperties);

        array_map(
            static function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator) : void {
                ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod);
            },
            array_merge(
                array_map(
                    $this->buildMethodInterceptor($prefixInterceptors, $suffixInterceptors, $valueHolder),
                    ProxiedMethodsFilter::getProxiedMethods($originalClass)
                ),
                [
                    Constructor::generateMethod($originalClass, $valueHolder),
                    new StaticProxyConstructor($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors),
                    new GetWrappedValueHolderValue($valueHolder),
                    new SetMethodPrefixInterceptor($prefixInterceptors),
                    new SetMethodSuffixInterceptor($suffixInterceptors),
                    new MagicGet(
                        $originalClass,
                        $valueHolder,
                        $prefixInterceptors,
                        $suffixInterceptors,
                        $publicProperties
                    ),
                    new MagicSet(
                        $originalClass,
                        $valueHolder,
                        $prefixInterceptors,
                        $suffixInterceptors,
                        $publicProperties
                    ),
                    new MagicIsset(
                        $originalClass,
                        $valueHolder,
                        $prefixInterceptors,
                        $suffixInterceptors,
                        $publicProperties
                    ),
                    new MagicUnset(
                        $originalClass,
                        $valueHolder,
                        $prefixInterceptors,
                        $suffixInterceptors,
                        $publicProperties
                    ),
                    new MagicClone($originalClass, $valueHolder, $prefixInterceptors, $suffixInterceptors),
                    new MagicSleep($originalClass, $valueHolder),
                    new MagicWakeup($originalClass),
                ]
            )
        );
    }
53245
public function setProxy($proxyString = '')
    {
        if (empty($proxyString)) {
            $this->proxySettings = [];
            return $this;
        }

        $this->proxySettings = [
            CURLOPT_PROXY => $proxyString,
            CURLOPT_HTTPPROXYTUNNEL => true,
        ];
        return $this;
    }
637230
public function setFixtures($table, $fixtures, $generator = null, $baseIndex = 0)
    {
        $loading = $this->currentSession->into($table);
        if ($generator) {
            $loading = $loading->with($generator);
        }
        return $loading->load($fixtures, $baseIndex);
    }
1266610
public static function createProxyGenerator(
        CacheHandlerInterface $cacheHandler,
        Configuration $proxyConfig = null,
        Reader $annotationReader = null
    ) : ProxyGenerator {
        $proxyConfig = $proxyConfig ?? new Configuration();
        $annotationReader = $annotationReader ?? new AnnotationReader();
        $proxyFactory = new AccessInterceptorValueHolderFactory($proxyConfig);

        return new ProxyGenerator($proxyFactory, $annotationReader, $cacheHandler);
    }
1072831
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        parent::visit($visitor, $generator, $data->content);
        $visitor->setHeader(
            'Location',
            $this->router->generate(
                'ezpublish_rest_loadContent',
                array('contentId' => $data->content->contentInfo->id)
            )
        );
        $visitor->setStatus(201);
    }
226517
public void setProxy(Proxy proxy) {
        if (verifiers.removeIf(verifier -> verifier instanceof SkillRequestSignatureVerifier)) {
            verifiers.add(new SkillRequestSignatureVerifier(proxy));
        }
    }
644886
protected function addProxy($proxy, $id, $target)
    {
        $callee = $target instanceof \Closure ? null : $target;
        $closure = $callee ? null : $target;

        $this->registry[$proxy] = array(
            'id' => $id,
            'target' => $callee,
            'closure' => $closure
        );
    }
488053
function setProxy($proxyHost, $proxyPort) {
      $this->useProxy = true;
      $this->proxyHost = $proxyHost;
      $this->proxyPort = $proxyPort;
    }
583004
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('Policy');
        $visitor->setHeader('Content-Type', $generator->getMediaType($data instanceof PolicyDraft ? 'PolicyDraft' : 'Policy'));
        $visitor->setHeader('Accept-Patch', $generator->getMediaType('PolicyUpdate'));
        $this->visitPolicyAttributes($visitor, $generator, $data);
        $generator->endObjectElement('Policy');
    }
1013647
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('View');
        $visitor->setHeader('Content-Type', $generator->getMediaType('View'));

        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_views_load', array('viewId' => $data->identifier))
        );
        $generator->endAttribute('href');

        $generator->startValueElement('identifier', $data->identifier);
        $generator->endValueElement('identifier');

        // BEGIN Query
        $generator->startObjectElement('Query');
        $generator->endObjectElement('Query');
        // END Query

        // BEGIN Result
        $generator->startObjectElement('Result', 'ViewResult');
        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_views_load_results', array('viewId' => $data->identifier))
        );
        $generator->endAttribute('href');

        // BEGIN Result metadata
        $generator->startValueElement('count', $data->searchResults->totalCount);
        $generator->endValueElement('count');

        $generator->startValueElement('time', $data->searchResults->time);
        $generator->endValueElement('time');

        $generator->startValueElement('timedOut', $generator->serializeBool($data->searchResults->timedOut));
        $generator->endValueElement('timedOut');

        $generator->startValueElement('maxScore', $data->searchResults->maxScore);
        $generator->endValueElement('maxScore');
        // END Result metadata

        // BEGIN searchHits
        $generator->startHashElement('searchHits');
        $generator->startList('searchHit');

        foreach ($data->searchResults->searchHits as $searchHit) {
            $generator->startObjectElement('searchHit');

            $generator->startAttribute('score', (float)$searchHit->score);
            $generator->endAttribute('score');

            $generator->startAttribute('index', (string)$searchHit->index);
            $generator->endAttribute('index');

            $generator->startObjectElement('value');

            // @todo Refactor
            if ($searchHit->valueObject instanceof ApiValues\Content) {
                /** @var \eZ\Publish\API\Repository\Values\Content\Content $searchHit->valueObject */
                $contentInfo = $searchHit->valueObject->contentInfo;
                $valueObject = new RestContentValue(
                    $contentInfo,
                    $this->locationService->loadLocation($contentInfo->mainLocationId),
                    $searchHit->valueObject,
                    $searchHit->valueObject->getContentType(),
                    $this->contentService->loadRelations($searchHit->valueObject->getVersionInfo())
                );
            } elseif ($searchHit->valueObject instanceof ApiValues\Location) {
                $valueObject = $searchHit->valueObject;
            } elseif ($searchHit->valueObject instanceof ApiValues\ContentInfo) {
                $valueObject = new RestContentValue($searchHit->valueObject);
            } else {
                throw new Exceptions\InvalidArgumentException('Unhandled object type');
            }

            $visitor->visitValueObject($valueObject);
            $generator->endObjectElement('value');
            $generator->endObjectElement('searchHit');
        }

        $generator->endList('searchHit');

        $generator->endHashElement('searchHits');
        // END searchHits

        $generator->endObjectElement('Result');
        // END Result

        $generator->endObjectElement('View');
    }
956043
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('Version');

        $visitor->setHeader('Content-Type', $generator->getMediaType('Version'));
        $visitor->setHeader('Accept-Patch', $generator->getMediaType('VersionUpdate'));
        $this->visitVersionAttributes($visitor, $generator, $data);
        $generator->endObjectElement('Version');
    }
1163737
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $versionInfo = $data->getVersionInfo();
        if (empty($versionInfo->languageCodes)) {
            return;
        }

        $generator->startObjectElement('VersionTranslationInfo');
        $this->visitVersionTranslationInfoAttributes($visitor, $generator, $data);
        $generator->endObjectElement('VersionTranslationInfo');
    }
584635
public function visit(Visitor $visitor, Generator $generator, $data)
    {
        $generator->startObjectElement('Location');
        $visitor->setHeader('Content-Type', $generator->getMediaType('Location'));
        $visitor->setHeader('Accept-Patch', $generator->getMediaType('LocationUpdate'));

        $location = $data->location;
        $contentInfo = $location->getContentInfo();

        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadLocation',
                array('locationPath' => trim($location->pathString, '/'))
            )
        );
        $generator->endAttribute('href');

        $generator->startValueElement('id', $location->id);
        $generator->endValueElement('id');

        $generator->startValueElement('priority', $location->priority);
        $generator->endValueElement('priority');

        $generator->startValueElement(
            'hidden',
            $this->serializeBool($generator, $location->hidden)
        );
        $generator->endValueElement('hidden');

        $generator->startValueElement(
            'invisible',
            $this->serializeBool($generator, $location->invisible)
        );
        $generator->endValueElement('invisible');

        $generator->startObjectElement('ParentLocation', 'Location');
        if (trim($location->pathString, '/') !== '1') {
            $generator->startAttribute(
                'href',
                $this->router->generate(
                    'ezpublish_rest_loadLocation',
                    array(
                        'locationPath' => implode('/', array_slice($location->path, 0, count($location->path) - 1)),
                    )
                )
            );
            $generator->endAttribute('href');
        }
        $generator->endObjectElement('ParentLocation');

        $generator->startValueElement('pathString', $location->pathString);
        $generator->endValueElement('pathString');

        $generator->startValueElement('depth', $location->depth);
        $generator->endValueElement('depth');

        $generator->startValueElement('childCount', $data->childCount);
        $generator->endValueElement('childCount');

        $generator->startValueElement('remoteId', $location->remoteId);
        $generator->endValueElement('remoteId');

        $generator->startObjectElement('Children', 'LocationList');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadLocationChildren',
                array(
                    'locationPath' => trim($location->pathString, '/'),
                )
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Children');

        $generator->startObjectElement('Content');
        $generator->startAttribute(
            'href',
            $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id))
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('Content');

        $generator->startValueElement('sortField', $this->serializeSortField($location->sortField));
        $generator->endValueElement('sortField');

        $generator->startValueElement('sortOrder', $this->serializeSortOrder($location->sortOrder));
        $generator->endValueElement('sortOrder');

        $generator->startObjectElement('UrlAliases', 'UrlAliasRefList');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_listLocationURLAliases',
                array('locationPath' => trim($location->pathString, '/'))
            )
        );
        $generator->endAttribute('href');
        $generator->endObjectElement('UrlAliases');

        $generator->startObjectElement('ContentInfo', 'ContentInfo');
        $generator->startAttribute(
            'href',
            $this->router->generate(
                'ezpublish_rest_loadContent',
                array('contentId' => $contentInfo->id)
            )
        );
        $generator->endAttribute('href');
        $visitor->visitValueObject(new RestContentValue($contentInfo));
        $generator->endObjectElement('ContentInfo');

        $generator->endObjectElement('Location');
    }