/** * Finds archive dates * * @param Type $type This page type is queried for archived pages only * * @return Date[] */ public function findByPageType(Type $type) { $query = $this->createQuery(); $sql = "\n SELECT\n FROM_UNIXTIME(lastUpdated) as archive_date\n FROM\n pages\n WHERE\n doktype = ?\n AND deleted = 0\n AND hidden = 0\n GROUP BY\n DATE_FORMAT(FROM_UNIXTIME(lastUpdated), '%Y-%m')\n ORDER BY\n archive_date DESC\n "; $query->statement($this->objectManager->get(PreparedStatement::class, $sql, 'pages'), [$type->getValue()]); $rawResults = $query->execute(true); return $this->hydrate($rawResults); }
/** * Returns the persistence layer query criteria * * @return array */ public function getCriteria() { return [$this->pageType->getValue(), $this->dateRange->getStartDate()->getTimestamp(), $this->dateRange->getEndDate()->getTimestamp()]; }
/** * Returns the page type label reference for the configured page type. * * @param Type $pageType Set page type * * @return string */ private function getPageTypeLabelReference(Type $pageType) { $registeredTypes = ArrayUtility::getValueByPath($GLOBALS, 'TCA/pages/columns/doktype/config/items'); $typeConfigurations = array_filter($registeredTypes, function ($configuration) use($pageType) { return (int) $configuration[1] === $pageType->getValue(); }); $typeConfiguration = array_shift($typeConfigurations); return array_shift($typeConfiguration); }
/** * Finds last updated pages of type $pageType * * @param Type $type Page type to query * @param int $offset Start here * @param int $limit Limit to this * * @return Page[] */ public function findLastUpdated(Type $type, $offset = 0, $limit = 1) { $query = $this->createQuery(); $sql = ' SELECT *, FROM_UNIXTIME(crdate) as created_at, FROM_UNIXTIME(lastUpdated) as last_updated_at FROM pages WHERE doktype = ? AND deleted = 0 AND hidden = 0 ORDER BY lastUpdated DESC LIMIT ' . $offset . ', ' . $limit . ' '; $query->statement($this->objectManager->get(PreparedStatement::class, $sql, 'pages'), [$type->getValue()]); $rawResults = $query->execute(true); return $this->hydrate($rawResults); }