3
Tại sao các phương pháp được bảo vệ không thể bị chặn?
Tôi đã tự hỏi tại sao không thể tạo plugin cho protectedcác phương thức. Có đoạn mã này trong Magento\Framework\Interception\Code\Generator\Interceptor: protected function _getClassMethods() { $methods = [$this->_getDefaultConstructorDefinition()]; $reflectionClass = new \ReflectionClass($this->getSourceClassName()); $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($publicMethods as $method) { if ($this->isInterceptedMethod($method)) { $methods[] = $this->_getMethodInfo($method); } } return $methods; } …
14
magento2