-
Notifications
You must be signed in to change notification settings - Fork 379
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 #388 from formapro-forks/resolve-events
[WIP] Added resolve events to cache manager
- Loading branch information
Showing
7 changed files
with
440 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
namespace Liip\ImagineBundle\Events; | ||
|
||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
class CacheResolveEvent extends Event | ||
{ | ||
/** | ||
* Resource path | ||
* @var string | ||
*/ | ||
protected $path; | ||
|
||
/** | ||
* Filter name | ||
* @var string | ||
*/ | ||
protected $filter; | ||
|
||
/** | ||
* Resource url | ||
* @var null | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* Init default event state | ||
* | ||
* @param string $path | ||
* @param string $filter | ||
* @param null|string $url | ||
*/ | ||
public function __construct($path, $filter, $url = null) | ||
{ | ||
$this->path = $path; | ||
$this->filter = $filter; | ||
$this->url = $url; | ||
} | ||
|
||
/** | ||
* Sets resource path | ||
* | ||
* @param $path | ||
*/ | ||
public function setPath($path) | ||
{ | ||
$this->path = $path; | ||
} | ||
|
||
/** | ||
* Returns resource path | ||
* | ||
* @return string | ||
*/ | ||
public function getPath() | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* Sets filter name | ||
* | ||
* @param $filter | ||
*/ | ||
public function setFilter($filter) | ||
{ | ||
$this->filter = $filter; | ||
} | ||
|
||
/** | ||
* Returns filter name | ||
* | ||
* @return string | ||
*/ | ||
public function getFilter() | ||
{ | ||
return $this->filter; | ||
} | ||
|
||
/** | ||
* Sets resource url | ||
* | ||
* @param $url | ||
*/ | ||
public function setUrl($url) | ||
{ | ||
$this->url = $url; | ||
} | ||
|
||
/** | ||
* Returns resource url | ||
* | ||
* @return null | ||
*/ | ||
public function getUrl() | ||
{ | ||
return $this->url; | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
namespace Liip\ImagineBundle; | ||
|
||
|
||
final class ImagineEvents | ||
{ | ||
const PRE_RESOLVE = 'liip_imagine.pre_resolve'; | ||
|
||
const POST_RESOLVE = 'liip_imagine.post_resolve'; | ||
|
||
private function __construct() | ||
{ | ||
} | ||
} |
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,105 @@ | ||
<?php | ||
namespace Liip\ImagineBundle\Tests\Events; | ||
|
||
use Liip\ImagineBundle\Events\CacheResolveEvent; | ||
|
||
/** | ||
* Test class for CacheResolveEvent. | ||
*/ | ||
class CacheResolveEventTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
|
||
} | ||
|
||
public function testShouldAllowSetPathInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
|
||
$this->assertAttributeEquals('default_path', 'path', $event); | ||
} | ||
|
||
public function testShouldAllowSetPathByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setPath('new_path'); | ||
|
||
$this->assertAttributeEquals('new_path', 'path', $event); | ||
} | ||
|
||
public function testShouldAllowGetPathWhichWasSetInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
|
||
$this->assertEquals('default_path', $event->getPath()); | ||
} | ||
|
||
public function testShouldAllowGetPathWhichWasSetByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setPath('new_path'); | ||
|
||
$this->assertEquals('new_path', $event->getPath()); | ||
} | ||
|
||
public function testShouldAllowSetFilterInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
|
||
$this->assertAttributeEquals('default_filter', 'filter', $event); | ||
} | ||
|
||
public function testShouldAllowSetFilterByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setFilter('new_filter'); | ||
|
||
$this->assertAttributeEquals('new_filter', 'filter', $event); | ||
} | ||
|
||
public function testShouldAllowGetFilterWhichWasSetInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
|
||
$this->assertEquals('default_filter', $event->getFilter()); | ||
} | ||
|
||
public function testShouldAllowGetFilterWhichWasSetByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setFilter('new_filter'); | ||
|
||
$this->assertEquals('new_filter', $event->getFilter()); | ||
} | ||
|
||
public function testShouldAllowSetUrlInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter', 'default_url'); | ||
|
||
$this->assertAttributeEquals('default_url', 'url', $event); | ||
} | ||
|
||
public function testShouldAllowSetUrlByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setUrl('new_url'); | ||
|
||
$this->assertAttributeEquals('new_url', 'url', $event); | ||
} | ||
|
||
public function testShouldAllowGetUrlWhichWasSetInConstruct() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter', 'default_url'); | ||
|
||
$this->assertEquals('default_url', $event->getUrl()); | ||
} | ||
|
||
public function testShouldAllowGetUrlWhichWasSetByMethod() | ||
{ | ||
$event = new CacheResolveEvent('default_path', 'default_filter'); | ||
$event->setUrl('new_url'); | ||
|
||
$this->assertEquals('new_url', $event->getUrl()); | ||
} | ||
} |
Oops, something went wrong.