-
Notifications
You must be signed in to change notification settings - Fork 14
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 #157 from wimvds/master
Folder tree & client requests
- Loading branch information
Showing
66 changed files
with
2,548 additions
and
795 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Changelog | ||
|
||
### dev (2014-08-13) | ||
|
||
* The originalFilename property has been added to Media, to store the original filename (so the name property can | ||
be used to add a meaningful name for use in the backend) | ||
* The Folder entity has been converted to a nested tree for performance reasons. | ||
* A command 'kuma:media:rebuild-folder-tree' was added to (re)build the folder tree. | ||
* Preview images for PDF documents will be created when you upload them (if you have PDF support |
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,44 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\MediaBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class CreatePdfPreviewCommand extends ContainerAwareCommand | ||
{ | ||
|
||
protected function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this | ||
->setName('kuma:media:create-pdf-previews') | ||
->setDescription('Create preview images for PDFs that have already been uploaded') | ||
->setHelp( | ||
"The <info>kuma:media:create-pdf-previews</info> command can be used to create preview images for PDFs that have already been uploaded." | ||
); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln('Creating PDF preview images...'); | ||
|
||
$pdfTransformer = $this->getContainer()->get('kunstmaan_media.pdf_transformer'); | ||
$webPath = realpath($this->getContainer()->get('kernel')->getRootDir() . '/../web') . DIRECTORY_SEPARATOR; | ||
|
||
/** | ||
* @var EntityManager | ||
*/ | ||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
$medias = $em->getRepository('KunstmaanMediaBundle:Media')->findBy( | ||
array('contentType' => 'application/pdf', 'deleted' => false) | ||
); | ||
/** @var Media $media */ | ||
foreach ($medias as $media) { | ||
$pdfTransformer->apply($webPath . $media->getUrl()); | ||
} | ||
$output->writeln('<info>PDF preview images have been created.</info>'); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\MediaBundle\Command; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
use Kunstmaan\MediaBundle\Entity\Media; | ||
use Kunstmaan\MediaBundle\Repository\FolderRepository; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class MigrateNameCommand extends ContainerAwareCommand | ||
{ | ||
/** @var EntityManager $em */ | ||
protected $em; | ||
|
||
protected function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this | ||
->setName('kuma:media:migrate-name') | ||
->setDescription('Migrate media name to new column.') | ||
->setHelp( | ||
"The <info>kuma:media:migrate-name</info> command can be used to migrate the media name to the newly added column." | ||
); | ||
} | ||
|
||
public function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$output->writeln('Migrating media name...'); | ||
/** | ||
* @var EntityManager | ||
*/ | ||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
|
||
$medias = $em->getRepository('KunstmaanMediaBundle:Media')->findAll(); | ||
$updates = 0; | ||
try { | ||
$em->beginTransaction(); | ||
/** @var Media $media */ | ||
foreach ($medias as $media) { | ||
$filename = $media->getOriginalFilename(); | ||
if (empty($filename)) { | ||
$media->setOriginalFilename($media->getName()); | ||
$em->persist($media); | ||
$updates++; | ||
} | ||
} | ||
$em->flush(); | ||
$em->commit(); | ||
} catch (\Exception $e) { | ||
$em->rollback(); | ||
$output->writeln('An error occured while migrating media name : <error>' . $e->getMessage() . '</error>'); | ||
} | ||
$output->writeln('<info>' . $updates . ' media files have been migrated.</info>'); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace Kunstmaan\MediaBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class RebuildFolderTreeCommand extends ContainerAwareCommand | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this->setName('kuma:media:rebuild-folder-tree') | ||
->setDescription('Rebuild the media folder tree.') | ||
->setHelp("The <info>kuma:media:rebuild-folder-tree</info> will loop over all media folders and update the media folder tree."); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$em = $this->getContainer()->get('doctrine.orm.entity_manager'); | ||
$em->getRepository('KunstmaanMediaBundle:Folder')->rebuildTree(); | ||
$output->writeln('Updated all folders'); | ||
} | ||
} |
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.