-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add-ability-filter-images'
- Loading branch information
Showing
36 changed files
with
1,211 additions
and
116 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
File renamed without changes.
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,12 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="hshn.serializer_extra.vich_uploader.uri_resolver.apply_filter" class="Hshn\SerializerExtraBundle\VichUploader\UriResolver\ApplyFilterResolver" public="false"> | ||
<argument type="service" id="hshn.serializer_extra.vich_uploader.uri_resolver.storage" /> | ||
<argument type="service" id="liip_imagine.cache.manager" /> | ||
</service> | ||
</services> | ||
</container> |
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace Hshn\SerializerExtraBundle\VichUploader; | ||
|
||
use Hshn\SerializerExtraBundle\VichUploader\Configuration\File; | ||
|
||
/** | ||
* @author Shota Hoshino <[email protected]> | ||
*/ | ||
|
@@ -18,24 +20,22 @@ class Configuration | |
private $class; | ||
|
||
/** | ||
* @var array | ||
* @var File[] | ||
*/ | ||
private $attributes; | ||
private $files; | ||
|
||
/** | ||
* @param string $class | ||
* @param array $attributes | ||
* @param array $files | ||
* @param int $maxDepth | ||
*/ | ||
public function __construct($class, array $attributes = [], $maxDepth = -1) | ||
public function __construct($class, array $files = [], $maxDepth = -1) | ||
{ | ||
$this->class = $class; | ||
$this->attributes = []; | ||
$this->files = []; | ||
$this->maxDepth = $maxDepth; | ||
|
||
foreach ($attributes as $attribute => $vars) { | ||
$this->setAttribute($attribute, $vars['alias']); | ||
} | ||
$this->addFiles($files); | ||
} | ||
|
||
/** | ||
|
@@ -55,37 +55,42 @@ public function getMaxDepth() | |
} | ||
|
||
/** | ||
* @param string $attribute | ||
* @param string $alias | ||
* @param array $files | ||
* | ||
* @return Configuration | ||
* @return $this | ||
*/ | ||
public function setAttribute($attribute, $alias = null) | ||
public function addFiles(array $files) | ||
{ | ||
$this->attributes[$attribute] = $alias ?: $attribute; | ||
foreach ($files as $file) { | ||
$this->addFile($file); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
* @param File $file | ||
* | ||
* @return $this | ||
*/ | ||
public function getAttributes() | ||
public function addFile(File $file) | ||
{ | ||
return $this->attributes; | ||
foreach ($this->files as $f) { | ||
if ($f->getExportTo() === $file->getExportTo()) { | ||
throw new \InvalidArgumentException(sprintf('File destination "%s" has already been specified by others', $f->getExportTo())); | ||
} | ||
} | ||
|
||
$this->files[] = $file; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $attribute | ||
* | ||
* @return string | ||
* @return File[] | ||
*/ | ||
public function getAlias($attribute) | ||
public function getFiles() | ||
{ | ||
if (array_key_exists($attribute, $this->attributes)) { | ||
return $this->attributes[$attribute]; | ||
} | ||
|
||
throw new \LogicException('Invalid attribute "%s"'); | ||
return $this->files; | ||
} | ||
} |
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,62 @@ | ||
<?php | ||
|
||
|
||
namespace Hshn\SerializerExtraBundle\VichUploader\Configuration; | ||
|
||
|
||
/** | ||
* @author Shota Hoshino <[email protected]> | ||
*/ | ||
class File | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $property; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $exportTo; | ||
|
||
/** | ||
* @var null|string | ||
*/ | ||
private $filter; | ||
|
||
/** | ||
* @param string $property | ||
* @param string $exportTo | ||
* @param string $filter | ||
*/ | ||
public function __construct($property, $exportTo = null, $filter = null) | ||
{ | ||
$this->property = $property; | ||
$this->exportTo = $exportTo ?: $property; | ||
$this->filter = $filter; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getProperty() | ||
{ | ||
return $this->property; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getExportTo() | ||
{ | ||
return $this->exportTo; | ||
} | ||
|
||
/** | ||
* @return null|string | ||
*/ | ||
public function getFilter() | ||
{ | ||
return $this->filter; | ||
} | ||
} |
Oops, something went wrong.