Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support an optional service to build the image instance in the Controller #21

Closed
lsmith77 opened this issue Jun 22, 2011 · 5 comments
Closed

Comments

@lsmith77
Copy link

we dont store our images in the file system, instead we store it in a content repository. it would help us therefore if the controller could be refactored a bit to make it possible to optionally define a service that creates the imagine instance, rather than the hardcoded file system approach.

@petrjaros
Copy link
Contributor

You can use your own controller. It is possible to set it in service container:

parameters:
    imagine.controller.class: Company\AnyBundle\Controller\ImagineController

The controller can look like this:

<?php

namespace Company\AnyBundle\Controller;

use Avalanche\Bundle\ImagineBundle\Imagine\CachePathResolver;
use Avalanche\Bundle\ImagineBundle\Imagine\Filter\FilterManager;
use Imagine\ImagineInterface;
use Symfony\Component\HttpKernel\Util\Filesystem;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class ImagineController extends \Avalanche\Bundle\ImagineBundle\Controller\ImagineController
{
    /**
     * @var Symfony\Component\HttpFoundation\Request
     */
    private $request;

    /**
     * @var Avalanche\Bundle\ImagineBundle\Imagine\CachePathResolver
     */
    private $cachePathResolver;

    /**
     * @var Imagine\ImagineInterface
     */
    private $imagine;

    /**
     * @var Avalanche\Bundle\ImagineBundle\Imagine\FilterManager
     */
    private $filterManager;

    /**
     * @var Symfony\Component\HttpKernel\Util\Filesystem
     */
    private $filesystem;

    /**
     * @var string
     */
    private $webRoot;

    /**
     * Constructs by setting $cachePathResolver
     *
     * @param Symfony\Component\HttpFoundation\Request                 $request
     * @param Avalanche\Bundle\ImagineBundle\Imagine\CachePathResolver $cachePathResolver
     * @param Imagine\ImagineInterface                                 $imagine
     * @param Avalanche\Bundle\ImagineBundle\Imagine\FilterManager     $filterManager
     * @param string                                                   $webRoot
     */
    public function __construct(
        Request $request,
        CachePathResolver $cachePathResolver,
        ImagineInterface $imagine,
        FilterManager $filterManager,
        Filesystem $filesystem,
        $webRoot
    )
    {
        parent::__construct($request, $cachePathResolver, $imagine, $filterManager, $filesystem, $webRoot);
        $this->request           = $request;
        $this->cachePathResolver = $cachePathResolver;
        $this->imagine           = $imagine;
        $this->filterManager     = $filterManager;
        $this->filesystem        = $filesystem;
        $this->webRoot           = $webRoot;
    }

    public function filter($path, $filter)
    {
        Your code...
    }


}

@lsmith77
Copy link
Author

sure you can .. but it would be better to refactor the existing controller to be more extensible

@lsmith77
Copy link
Author

@avalanche123: is there an ETA for this? IIRC you said you would have a go at this, if not i will try to find time to get on this during this week.

@lsmith77
Copy link
Author

FYI .. i am working on a rather large refactoring that includes this feature among several others.

@lsmith77
Copy link
Author

lsmith77 commented Sep 2, 2011

closed in favor of #25

@lsmith77 lsmith77 closed this as completed Sep 2, 2011
Bluestart83 pushed a commit to Bluestart83/AvalancheImagineBundle that referenced this issue Jun 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants