Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Commit

Permalink
Media: merge with NetteAddons\Media
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrtak-CZ committed Sep 9, 2012
1 parent 8500efc commit 8c40506
Show file tree
Hide file tree
Showing 54 changed files with 475 additions and 475 deletions.
20 changes: 10 additions & 10 deletions Nella/Config/Extensions/MediaExtension.php
Expand Up @@ -18,7 +18,7 @@
*
* @author Patrik Votoček
*/
class MediaExtension extends \Nella\NetteAddons\Media\Config\Extension
class MediaExtension extends \Nella\Media\Config\Extension
{
/** @var array */
public $defaults = array(
Expand Down Expand Up @@ -52,7 +52,7 @@ public function loadConfiguration()
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('listener'))
->setClass('Nella\Media\Model\Listener')
->setClass('Nella\Media\Doctrine\Listener')
->addTag('doctrineListener')
->setAutowired(FALSE);

Expand All @@ -71,22 +71,22 @@ protected function processFile($storageDir, $routeMask = NULL)

$builder->addDefinition($this->prefix('fileRepository'))
->setClass('Nella\Doctrine\Repository')
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Model\FileEntity'))
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Doctrine\FileEntity'))
->setAutowired(FALSE);

if ($builder->hasDefinition($this->prefix('fileDao'))) {
$builder->removeDefinition($this->prefix('fileDao'));
}
$builder->addDefinition($this->prefix('fileDao'))
->setClass('Nella\Media\Model\FileDao', array(
->setClass('Nella\Media\Doctrine\FileDao', array(
$this->prefix('@entityManager'), $this->prefix('@fileRepository')
))
->addSetup('setStorage', array($this->prefix('@fileStorage')))
->setAutowired(FALSE);

if ($routeMask) {
$builder->getDefinition($this->prefix('fileRoute'))
->setClass('Nella\NetteAddons\Media\Routes\FileRoute', array(
->setClass('Nella\Media\Routes\FileRoute', array(
$routeMask, $this->prefix('@fileDao'), $this->prefix('@filePresenterCallback'), '<file>'
));
}
Expand All @@ -106,19 +106,19 @@ protected function processImage($storageDir, $path, array $formats, $routeMask =

$builder->addDefinition($this->prefix('imageRepository'))
->setClass('Nella\Doctrine\Repository')
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Model\ImageEntity'))
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Doctrine\ImageEntity'))
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('imageFormatRepository'))
->setClass('Nella\Doctrine\Repository')
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Model\ImageFormatEntity'))
->setFactory($this->prefix('@entityManager::getRepository'), array('Nella\Media\Doctrine\ImageFormatEntity'))
->setAutowired(FALSE);

if ($builder->hasDefinition($this->prefix('imageDao'))) {
$builder->removeDefinition($this->prefix('imageDao'));
}
$builder->addDefinition($this->prefix('imageDao'))
->setClass('Nella\Media\Model\ImageDao', array(
->setClass('Nella\Media\Doctrine\ImageDao', array(
$this->prefix('@entityManager'), $this->prefix('@imageRepository')
))
->addSetup('setStorage', array($this->prefix('@imageStorage')))
Expand All @@ -129,15 +129,15 @@ protected function processImage($storageDir, $path, array $formats, $routeMask =
$builder->removeDefinition($this->prefix('imageFormatDao'));
}
$builder->addDefinition($this->prefix('imageFormatDao'))
->setClass('Nella\Media\Model\ImageFormatDao', array(
->setClass('Nella\Media\Doctrine\ImageFormatDao', array(
$this->prefix('@entityManager'), $this->prefix('@imageFormatRepository')
))
->addSetup('setCacheStorage', array($this->prefix('@imageCacheStorage')))
->setAutowired(FALSE);

if ($routeMask) {
$builder->getDefinition($this->prefix('imageRoute'))
->setClass('Nella\NetteAddons\Media\Routes\ImageRoute', array(
->setClass('Nella\Media\Routes\ImageRoute', array(
$routeMask,
$this->prefix('@imageDao'),
$this->prefix('@imageFormatDao'),
Expand Down
Expand Up @@ -4,35 +4,35 @@
*
* Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
*
* For the full copyright and license information,
* For the full copyright and license information,
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\NetteAddons\Media\Callbacks;
namespace Nella\Media\Callbacks;

/**
* File presenter callback (convert request to response)
*
* @author Patrik Votoček
*/
class FilePresenterCallback extends \Nette\Object implements \Nella\NetteAddons\Media\IFilePresenterCallback
class FilePresenterCallback extends \Nette\Object implements \Nella\Media\IFilePresenterCallback
{
/** @var \Nella\NetteAddons\Media\IStorage */
/** @var \Nella\Media\IStorage */
private $storage;

/**
* @param \Nella\NetteAddons\Media\IStorage
* @param \Nella\Media\IStorage
*/
public function __construct(\Nella\NetteAddons\Media\IStorage $storage)
public function __construct(\Nella\Media\IStorage $storage)
{
$this->storage = $storage;
}

/**
* @param \Nella\NetteAddons\Media\IFile
* @param \Nella\Media\IFile
* @return \Nette\Application\Responses\FileResponse
*/
public function __invoke(\Nella\NetteAddons\Media\IFile $file)
public function __invoke(\Nella\Media\IFile $file)
{
$path = $this->storage->load($file);
if (!$path) {
Expand Down
Expand Up @@ -4,41 +4,41 @@
*
* Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
*
* For the full copyright and license information,
* For the full copyright and license information,
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\NetteAddons\Media\Callbacks;
namespace Nella\Media\Callbacks;

use Nette\Image,
Nella\NetteAddons\Media\IImage,
Nella\NetteAddons\Media\IImageFormat;
Nella\Media\IImage,
Nella\Media\IImageFormat;

/**
* Image presenter callback (convert request to response)
*
* @author Patrik Votoček
*/
class ImagePresenterCallback extends \Nette\Object implements \Nella\NetteAddons\Media\IImagePresenterCallback
class ImagePresenterCallback extends \Nette\Object implements \Nella\Media\IImagePresenterCallback
{
/** @var \Nella\NetteAddons\Media\IStorage */
/** @var \Nella\Media\IStorage */
private $storage;
/** @var \Nella\NetteAddons\Media\IImageCacheStorage */
/** @var \Nella\Media\IImageCacheStorage */
private $cacheStorage;

/**
* @param \Nella\NetteAddons\Media\IStorage
* @param \Nella\NetteAddons\Media\IImageCacheStorage
* @param \Nella\Media\IStorage
* @param \Nella\Media\IImageCacheStorage
*/
public function __construct(\Nella\NetteAddons\Media\IStorage $storage, \Nella\NetteAddons\Media\IImageCacheStorage $cacheStorage)
public function __construct(\Nella\Media\IStorage $storage, \Nella\Media\IImageCacheStorage $cacheStorage)
{
$this->storage = $storage;
$this->cacheStorage = $cacheStorage;
}

/**
* @param \Nella\NetteAddons\Media\IImage
* @param \Nella\NetteAddons\Media\IImageFormat
* @param \Nella\Media\IImage
* @param \Nella\Media\IImageFormat
* @param string
* @return \Nette\Application\Responses\FileResponse
*/
Expand All @@ -53,7 +53,7 @@ public function __invoke(IImage $image, IImageFormat $format, $type)
if (!$img) {
throw new \Nette\Application\BadRequestException('Image not found', 404);
}
return new \Nella\NetteAddons\Media\Responses\ImageResponse($img);
return new \Nella\Media\Responses\ImageResponse($img);
}

/**
Expand Down
Expand Up @@ -8,7 +8,7 @@
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\NetteAddons\Media\Config;
namespace Nella\Media\Config;

use Nette\Config\Configurator,
Nette\Config\Compiler,
Expand Down Expand Up @@ -70,7 +70,7 @@ public function loadConfiguration()

if ($builder->hasDefinition('nette.latte')) {
$builder->getDefinition('nette.latte')
->addSetup('Nella\NetteAddons\Media\Latte\MediaMacros::factory', array('@self'));
->addSetup('Nella\Media\Latte\MediaMacros::factory', array('@self'));
}

$this->registerRoutes();
Expand All @@ -85,21 +85,21 @@ protected function processFile($storageDir, $routeMask = NULL)
$builder = $this->getContainerBuilder();

$builder->addDefinition($this->prefix('fileStorage'))
->setClass('Nella\NetteAddons\Media\Storages\File', array($storageDir))
->setClass('Nella\Media\Storages\File', array($storageDir))
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('filePresenterCallback'))
->setClass('Nella\NetteAddons\Media\Callbacks\FilePresenterCallback', array(
->setClass('Nella\Media\Callbacks\FilePresenterCallback', array(
$this->prefix('@fileStorage')
));

$builder->addDefinition($this->prefix('fileDao'))
->setClass('Nella\NetteAddons\Media\Model\FileDao')
->setClass('Nella\Media\Model\FileDao')
->setAutowired(FALSE);

if ($routeMask) {
$builder->addDefinition($this->prefix('fileRoute'))
->setClass('Nella\NetteAddons\Media\Routes\FileRoute', array(
->setClass('Nella\Media\Routes\FileRoute', array(
$routeMask, $this->prefix('@fileDao'), $this->prefix('@filePresenterCallback')
))
->setAutowired(FALSE);
Expand All @@ -117,28 +117,28 @@ protected function processImage($storageDir, $path, array $formats, $routeMask =
$builder = $this->getContainerBuilder();

$builder->addDefinition($this->prefix('imageStorage'))
->setClass('Nella\NetteAddons\Media\Storages\File', array($storageDir))
->setClass('Nella\Media\Storages\File', array($storageDir))
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('imageCacheStorage'))
->setClass('Nella\NetteAddons\Media\ImageCacheStorages\File', array($path, '@cacheStorage'));
->setClass('Nella\Media\ImageCacheStorages\File', array($path, '@cacheStorage'));

$builder->addDefinition($this->prefix('imagePresenterCallback'))
->setClass('Nella\NetteAddons\Media\Callbacks\ImagePresenterCallback', array(
->setClass('Nella\Media\Callbacks\ImagePresenterCallback', array(
$this->prefix('@imageStorage'), $this->prefix('@imageCacheStorage')
));

$builder->addDefinition($this->prefix('imageDao'))
->setClass('Nella\NetteAddons\Media\Model\ImageDao')
->setClass('Nella\Media\Model\ImageDao')
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('imageFormatDao'))
->setClass('Nella\NetteAddons\Media\Model\ImageFormatDao', array($formats))
->setClass('Nella\Media\Model\ImageFormatDao', array($formats))
->setAutowired(FALSE);

if ($routeMask) {
$builder->addDefinition($this->prefix('imageRoute'))
->setClass('Nella\NetteAddons\Media\Routes\ImageRoute', array(
->setClass('Nella\Media\Routes\ImageRoute', array(
$routeMask, $this->prefix('@imageDao'), $this->prefix('@imageFormatDao'),
$this->prefix('@imagePresenterCallback')
))
Expand Down
Expand Up @@ -8,7 +8,7 @@
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\Media\Model;
namespace Nella\Media\Doctrine;

use Doctrine\ORM\Mapping as orm;

Expand All @@ -19,22 +19,22 @@
*/
abstract class BaseDao extends \Nella\Model\Facade
{
/** @var \Nella\NetteAddons\Media\IStorage */
/** @var \Nella\Media\IStorage */
protected $storage;

/**
* @param \Nella\NetteAddons\Media\IStorage
* @param \Nella\Media\IStorage
* @return ImageDao
*/
public function setStorage(\Nella\NetteAddons\Media\IStorage $storage)
public function setStorage(\Nella\Media\IStorage $storage)
{
$this->storage = $storage;
return $this;
}

/**
* @param string
* @return \Nella\Media\Model\FileEntity|\Nella\Media\Model\ImageEntity|NULL
* @return \Nella\Media\Doctrine\FileEntity|\Nella\Media\Doctrine\ImageEntity|NULL
*/
public function findOneByFullSlug($fullSlug)
{
Expand Down
Expand Up @@ -4,11 +4,11 @@
*
* Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
*
* For the full copyright and license information,
* For the full copyright and license information,
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\Media\Model;
namespace Nella\Media\Doctrine;

use Doctrine\ORM\Mapping as orm;

Expand All @@ -25,7 +25,7 @@
* @property string $slug
* @property-read string $fullSlug
*/
abstract class BaseFileEntity extends \Nella\Doctrine\Entity implements \Nella\NetteAddons\Media\IFile
abstract class BaseFileEntity extends \Nella\Doctrine\Entity implements \Nella\Media\IFile
{
/** @var string */
public static $fullSlugFormat = '<id>-<slug>';
Expand Down
31 changes: 31 additions & 0 deletions Nella/Media/Doctrine/FileDao.php
@@ -0,0 +1,31 @@
<?php
/**
* This file is part of the Nella Framework (http://nellafw.org).
*
* Copyright (c) 2006, 2012 Patrik Votoček (http://patrik.votocek.cz)
*
* For the full copyright and license information,
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\Media\Doctrine;

use Doctrine\ORM\Mapping as orm;

/**
* File DAO
*
* @author Patrik Votoček
*/
class FileDao extends BaseDao implements \Nella\Media\Model\IFileDao
{
/**
* @param string
* @return \Nella\Media\Doctrine\FileEntity|NULL
*/
public function findOneByFullSlug($fullSlug)
{
return parent::findOneByFullSlug($fullSlug);
}
}

Expand Up @@ -8,7 +8,7 @@
* please view the file LICENSE.txt that was distributed with this source code.
*/

namespace Nella\Media\Model;
namespace Nella\Media\Doctrine;

use Doctrine\ORM\Mapping as orm;

Expand Down

0 comments on commit 8c40506

Please sign in to comment.