public static function checkAlias($alias) { $v = $alias; do { list($v, $name) = NameSpaceHelper::splitAlias($v); StringDataTypeHandler::checkValueAsWord($name); } while ($v != NULL); }
public function findDataSourceByNamespacelessName($datasourceNamespacelessName) { $datasources = NULL; foreach ($this->datasources as $datasourceName => $datasource) { list($namespace, $datasourceNameOnly) = NameSpaceHelper::splitAlias($datasourceName); if ($datasourceNameOnly == $datasourceNamespacelessName) { $datasources[$datasourceName] = $datasource; } } return $datasources; }
protected static function generateFromReference($reference) { if (!isset($reference)) { return NULL; } $parts = ReferencePathHelper::splitReference($reference); $databaseColumnName = NULL; for ($i = 0, $count = count($parts); $i < $count; $i += 2) { $resource = $parts[$i]; $name = $parts[$i + 1]; $columnNameSegment = $name; if (isset($resource)) { list($namespace, $resourceName) = NameSpaceHelper::splitAlias($resource); $columnNameSegment .= '_'; if (isset($namespace)) { $columnNameSegment .= $namespace . '_'; } $columnNameSegment .= $resourceName; } if (isset($databaseColumnName)) { $databaseColumnName .= '_'; } $databaseColumnName .= $columnNameSegment; } // replacing non-word characters with '_' $databaseColumnName = preg_replace('#\W+#', '_', $databaseColumnName); // removing several subsequent instances of '_' $databaseColumnName = preg_replace('#_{2,}#', '_', $databaseColumnName); // fixing possibility for leading digits if ((strlen($databaseColumnName) > 0) && is_numeric(substr($databaseColumnName, 0, 1))) { $databaseColumnName = 'fix_' . $databaseColumnName; } $databaseColumnName = strtolower($databaseColumnName); return $databaseColumnName; }
public static function getDatasetName($contentTypeName) { // FIXME cache it somewhere list($namespace) = NameSpaceHelper::splitAlias(AbstractDrupalDataSourceQueryProxy::$DATASOURCE_NAME__DEFAULT); return NameSpaceHelper::addNameSpace($namespace, self::$DATASET__PREFIX . $contentTypeName); }
public static function generateDatabaseColumnName($reference) { $parts = self::splitReference($reference); $databaseColumnName = NULL; for ($i = 0, $count = count($parts); $i < $count; $i += 2) { $resource = $parts[$i]; $name = $parts[$i + 1]; $columnNameSegment = $name; if (isset($resource)) { list($namespace, $resourceName) = NameSpaceHelper::splitAlias($resource); $columnNameSegment .= ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE; if (isset($namespace)) { $columnNameSegment .= $namespace . ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE; } $columnNameSegment .= $resourceName; } if (isset($databaseColumnName)) { $databaseColumnName .= ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE; } $databaseColumnName .= $columnNameSegment; } // replacing non-word characters with ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE $databaseColumnName = preg_replace('/\\W+/', ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE, $databaseColumnName); // removing several subsequent instances of ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE $databaseColumnName = preg_replace('/' . ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE . '{2,}/', ParameterHelper::$COLUMN_NAME_DELIMITER__DATABASE, $databaseColumnName); $databaseColumnName = strtolower($databaseColumnName); return $databaseColumnName; }
public static function checkAlias($alias) { list($namespace, $name) = NameSpaceHelper::splitAlias($alias); StringDataTypeHandler::checkValueAsWord($namespace); StringDataTypeHandler::checkValueAsWord($name); }