registry = $registry; $this->protectedModels = $protectedModels; } /** * Safeguard function that checks if item can be removed * * @param \Magento\Framework\Model\AbstractModel $model * @return bool */ public function isAllowed(AbstractModel $model) { $isAllowed = true; if ($this->registry->registry('isSecureArea')) { $isAllowed = true; } elseif (in_array($this->getBaseClassName($model), $this->protectedModels)) { $isAllowed = false; } return $isAllowed; } /** * Get clean model name without Interceptor and Proxy part and slashes * @param object $object * @return mixed */ protected function getBaseClassName($object) { $className = ltrim(get_class($object), "\\"); $className = str_replace(['\Interceptor', '\Proxy'], [''], $className); return $className; } }