/** * Loads the default schema for the provider of type. * * @param int $type * * @return array|null */ public static function loadDefaultSchema($type = ProviderConfigTypes::OAUTH) { $_schema = null; $_typeName = ProviderConfigTypes::nameOf($type); $_fileName = __DIR__ . '/Schemas/' . Inflector::neutralize($_typeName) . '.schema.php'; if (file_exists($_fileName) && is_readable($_fileName)) { /** @noinspection PhpIncludeInspection */ $_schema = @(include $_fileName); if (!empty($_schema)) { $_schema = array_merge(array('provider_type' => array('type' => 'text', 'class' => 'uneditable-input', 'label' => 'Provider Type', 'value' => str_ireplace('oauth', 'OAuth', ucfirst(Inflector::deneutralize(strtolower($_typeName)))))), $_schema); } } return $_schema; }
/** * Parses a provider ID spec ([generic:]providerId[:type]) * * @param string $providerId * * @return array * @throws \InvalidArgumentException */ protected static function _normalizeProviderId($providerId) { $_providerId = $_mapKey = $providerId; $_type = null; $_generic = false; if (false === strpos($_providerId, static::GENERIC_PROVIDER_PATTERN, 0)) { $_providerId = static::_cleanProviderId($_providerId); } else { $_parts = explode(':', $_providerId); if (empty($_parts) || 3 != sizeof($_parts)) { throw new \InvalidArgumentException('Invalid provider ID specified. Use predefined or generic "generic:providerId:type" format.'); } $_providerId = static::_cleanProviderId($_parts[1]); $_type = str_ireplace('oauth', 'OAuth', ProviderConfigTypes::nameOf($_parts[2])); $_mapKey = 'generic' . $_type; $_generic = ':' . $_providerId; } return array($_providerId, $_type, $_mapKey, $_generic); }