9 class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract
22 return $modelClassName .
'_' . ucfirst(static::ENTITY_TYPE);
45 $body =
"\$this->___init();\n";
47 foreach ($constructor->getParameters() as $parameter) {
50 $body .= count($parameters)
51 ?
"parent::__construct({$this->_getParameterList($parameters)});" 52 :
"parent::__construct();";
55 'name' =>
'__construct',
56 'parameters' => $parameters,
72 foreach ($publicMethods as
$method) {
89 !in_array(
$method->getName(), [
'__sleep',
'__wakeup',
'__clone']);
101 foreach (
$method->getParameters() as $parameter) {
105 $returnType =
$method->getReturnType();
106 $returnTypeValue = $returnType
107 ? ($returnType->allowsNull() ?
'?' :
'') .$returnType->getName()
110 'name' => (
$method->returnsReference() ?
'& ' :
'') .
$method->getName(),
111 'parameters' => $parameters,
112 'body' => str_replace(
120 $returnTypeValue ===
'void' ?
'' :
' return',
124 $pluginInfo = $this->pluginList->getNext($this->subjectType,
'%methodName%');
126 %
return% parent::%methodName%(%parameters%);
128 %
return% $this->
___callPlugins(
'%methodName%', func_get_args(), $pluginInfo);
132 'returnType' => $returnTypeValue,
133 'docblock' => [
'shortDescription' =>
'{@inheritdoc}'],
150 if (
$item[
'variadic']) {
154 $output .=
"\${$item['name']}";
170 $reflection = new \ReflectionClass($typeName);
173 if ($reflection->isInterface()) {
174 $interfaces[] = $typeName;
176 $this->_classGenerator->setExtendedClass($typeName);
178 $this->_classGenerator->addTrait(
'\\'. \
Magento\Framework\Interception\Interceptor::class);
179 $interfaces[] =
'\\'. \Magento\Framework\Interception\InterceptorInterface::class;
180 $this->_classGenerator->setImplementedInterfaces($interfaces);
181 return parent::_generateCode();
189 $result = parent::_validateData();
195 if ($resultClassName !== $sourceClassName .
'\\Interceptor') {
197 'Invalid Interceptor class name [' .
_getMethodInfo(\ReflectionMethod $method)
_getDefaultConstructorDefinition()
_getParameterList(array $parameters)
isInterceptedMethod(\ReflectionMethod $method)
_getDefaultResultClassName($modelClassName)
___callPlugins($method, array $arguments, array $pluginInfo)
_getMethodParameterInfo(\ReflectionParameter $parameter)