/** * {@inheritdoc} * * @param FlowQuery $flowQuery The FlowQuery object * @param array $arguments None * @return integer The cache lifetime in seconds or NULL if either no content collection was given or no child node had a "hiddenBeforeDateTime" or "hiddenAfterDateTime" property set */ public function evaluate(FlowQuery $flowQuery, array $arguments) { $minimumDateTime = null; foreach ($flowQuery->getContext() as $contextNode) { $hiddenBeforeDateTime = $contextNode->getHiddenBeforeDateTime(); if ($hiddenBeforeDateTime !== null && $hiddenBeforeDateTime > $this->now && ($minimumDateTime === null || $hiddenBeforeDateTime < $minimumDateTime)) { $minimumDateTime = $hiddenBeforeDateTime; } $hiddenAfterDateTime = $contextNode->getHiddenAfterDateTime(); if ($hiddenAfterDateTime !== null && $hiddenAfterDateTime > $this->now && ($minimumDateTime === null || $hiddenAfterDateTime < $minimumDateTime)) { $minimumDateTime = $hiddenAfterDateTime; } } if ($minimumDateTime !== null) { $maximumLifetime = $minimumDateTime->getTimestamp() - $this->now->getTimestamp(); if ($maximumLifetime > 0) { return $maximumLifetime; } } return null; }
/** * @test */ public function setStatusCodeSetStatusAndLastModificationDate() { $redirect = new Redirect('/source/path/', '/target/path/', 303, 'www.host.com'); $now = new Now(); $redirect->setStatusCode(301); $this->assertSame(301, $redirect->getStatusCode()); $this->assertSame($now->getTimestamp(), $redirect->getLastModificationDateTime()->getTimestamp()); }