class ProxyGenerator (View source)

deprecated The Doctrine\Common\Proxy component is deprecated, please use ocramius/proxy-manager instead.

This factory is used to generate proxy classes.

It builds proxies from given parameters, a template and class metadata.

Constants

PATTERN_MATCH_ID_METHOD

Used to match very simple id methods that don't need to be decorated since the identifier is known.

Properties

protected string[]|callable[] $placeholders Map of callables used to fill in placeholders set in the template.
protected string $proxyClassTemplate Template used as a blueprint to generate proxies.

Methods

__construct(string $proxyDirectory, string $proxyNamespace)

Initializes a new instance of the ProxyFactory class that is connected to the given EntityManager.

setPlaceholder(string $name, string|callable $placeholder)

Sets a placeholder to be replaced in the template.

setProxyClassTemplate(string $proxyClassTemplate)

Sets the base template used to create proxy classes.

generateProxyClass(ClassMetadata $class, string|bool $fileName = false)

Generates a proxy class file.

string
getProxyFileName(string $className, string $baseDirectory = null)

Generates the Proxy file name.

Details

__construct(string $proxyDirectory, string $proxyNamespace)

Initializes a new instance of the ProxyFactory class that is connected to the given EntityManager.

Parameters

string $proxyDirectory The directory to use for the proxy classes. It must exist.
string $proxyNamespace The namespace to use for the proxy classes.

Exceptions

InvalidArgumentException

setPlaceholder(string $name, string|callable $placeholder)

Sets a placeholder to be replaced in the template.

Parameters

string $name
string|callable $placeholder

Exceptions

InvalidArgumentException

setProxyClassTemplate(string $proxyClassTemplate)

Sets the base template used to create proxy classes.

Parameters

string $proxyClassTemplate

generateProxyClass(ClassMetadata $class, string|bool $fileName = false)

Generates a proxy class file.

Parameters

ClassMetadata $class Metadata for the original class.
string|bool $fileName Filename (full path) for the generated class. If none is given, eval() is used.

Exceptions

InvalidArgumentException
UnexpectedValueException

string getProxyFileName(string $className, string $baseDirectory = null)

Generates the Proxy file name.

Parameters

string $className
string $baseDirectory Optional base directory for proxy file name generation. If not specified, the directory configured on the Configuration of the EntityManager will be used by this factory.

Return Value

string