public function getContentTypesList($repositoryName) { $contentTypes = array(); if ($this->hasRepository($repositoryName)) { $path = $this->getCMDLDirectory() . '/' . $repositoryName; $path = realpath($path); if (is_dir($path)) { $results = scandir($path); foreach ($results as $result) { if ($result === '.' || $result === '..') { continue; } if (!is_dir($path . '/' . $result)) { if (pathinfo($result, PATHINFO_EXTENSION) == 'cmdl') { $filestats = stat($path . '/' . $result); $contentTypeName = pathinfo($result, PATHINFO_FILENAME); try { $contentTypeDefinition = $this->getContentTypeDefinition($repositoryName, $contentTypeName); if ($contentTypeDefinition) { $info = new ContentTypeInfo(); $info->setName($contentTypeName); $info->setLastchangecmdl(@$filestats['mtime']); $info->setTitle((string) $contentTypeDefinition->getTitle()); $info->setDescription((string) $contentTypeDefinition->getDescription()); $contentTypes[$contentTypeName] = $info; } } catch (\CMDLParserException $e) { } } } } } } return $contentTypes; }
public function getContentTypesList($repositoryName) { $contentTypes = array(); /** @var PDO $db */ $dbh = $this->app['db']->getConnection(); $sql = 'SELECT name, cmdl, lastchange_timestamp FROM _cmdl_ WHERE repository = ? AND data_type = "content" ORDER BY name'; $stmt = $dbh->prepare($sql); try { $stmt->execute(array($repositoryName)); $result = $stmt->fetchAll(); foreach ($result as $row) { $contentTypeDefinition = $this->getContentTypeDefinition($repositoryName, $row['name']); if ($contentTypeDefinition) { $info = new ContentTypeInfo(); $info->setName($contentTypeDefinition->getName()); $info->setLastchangecmdl($row['lastchange_timestamp']); $info->setTitle((string) $contentTypeDefinition->getTitle()); $info->setDescription((string) $contentTypeDefinition->getDescription()); $contentTypes[$row['name']] = $info; } } } catch (\PDOException $e) { } return $contentTypes; }