-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from wimvds/feature/add-timestamps-on-nodetran…
…slations add created and updated timestamps to node translations
- Loading branch information
Showing
6 changed files
with
207 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
# Changelog | ||
|
||
### dev (2014-09-23) | ||
|
||
* Created and updated timestamps were added to node translations. The updated timestamp will only be modified when a | ||
change on the public version of a page is saved or a draft is published. | ||
|
||
* The kuma:nodes:fix-timestamps command was added to initialize the created and updated timestamps for existing sites. | ||
|
||
### dev (2012-08-30) | ||
|
||
* Support for ACL permissions instead of our own custom implementation. | ||
|
||
### dev (2012-08-24) | ||
|
||
* Added the functionality to configure the page action menus. (see Resources/doc/configurable_action_menu.md on how to use this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\NodeBundle\Command; | ||
|
||
use Doctrine\DBAL\DBALException; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class FixTimestampsCommand extends ContainerAwareCommand | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this->setName('kuma:nodes:fix-timestamps') | ||
->setDescription('Update timestamps for all node translations.') | ||
->setHelp("The <info>kuma:nodes:fix-timestamps</info> will loop over all node translation entries and update the timestamps for the entries."); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
|
||
$db = $em->getConnection(); | ||
$db->beginTransaction(); | ||
try { | ||
$sql = <<<SQL | ||
update kuma_node_translations nt | ||
set nt.created=(select MIN(created) from kuma_node_versions nv where nv.node_translation_id=nt.id AND nv.type='public'), | ||
nt.updated=(select MAX(updated) from kuma_node_versions nv where nv.node_translation_id=nt.id AND nv.type='public') | ||
SQL; | ||
|
||
$db->exec($sql); | ||
$db->commit(); | ||
$output->writeln('Updated all node translation timestamps'); | ||
} catch (DBALException $e) { | ||
$db->rollBack(); | ||
$output->writeln('<error>An error occured while updating the node translation timestamps</error>'); | ||
$output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.