getExtensionInformation = $getExtensionInformation; $this->scopeConfig = $scopeConfig; $this->systemXmlStructure = $configStructureData; } /** * Check if the extension is paid. * * @param string $moduleName * @return bool */ public function execute(string $moduleName): bool { $extensionInformation = $this->getExtensionInformation->execute($moduleName); return $this->hasSerialKey($extensionInformation) || $this->hasDeclaredSerialKeyField($extensionInformation); } /** * Check if the extension has empty or not serial key value. * * @param \Plumrocket\Base\Api\Data\ExtensionInformationInterface $extensionInformation * @return bool */ private function hasSerialKey(ExtensionInformationInterface $extensionInformation): bool { $generalConfigurations = $this->scopeConfig->getValue( "{$extensionInformation->getConfigSection()}/general", ScopeInterface::SCOPE_STORE, 0 ); return is_array($generalConfigurations) && array_key_exists('serial', $generalConfigurations); } /** * Check if the serial key field is exists in system.xml * * @param \Plumrocket\Base\Api\Data\ExtensionInformationInterface $extensionInformation * @return bool */ private function hasDeclaredSerialKeyField(ExtensionInformationInterface $extensionInformation): bool { return (bool) $this->systemXmlStructure->get( "sections/{$extensionInformation->getConfigSection()}/children/general/children/serial" ); } }