-
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 pull request #2 from syzygypl/feature/predefined-types
Allow configuring media set definitions via Symfony config
- Loading branch information
Showing
10 changed files
with
122 additions
and
11 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
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,18 @@ | ||
<?php | ||
|
||
namespace ArsThanea\PageMediaSetBundle\Service; | ||
|
||
interface MediaSetDefinitionInterface | ||
{ | ||
/** | ||
* @param HasMediaSetInterface $object | ||
* @return array | ||
*/ | ||
public function getMediaSetDefinition(HasMediaSetInterface $object); | ||
|
||
/** | ||
* @param string $type | ||
* @return array | ||
*/ | ||
public function getDefaultMediaSetDefinition($type); | ||
} |
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,46 @@ | ||
<?php | ||
|
||
namespace ArsThanea\PageMediaSetBundle\Service; | ||
|
||
class MediaSetDefinitionService implements MediaSetDefinitionInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $types; | ||
|
||
/** | ||
* @param array $types | ||
*/ | ||
public function __construct(array $types) | ||
{ | ||
$this->types = array_map(function ($v) { return (array)$v; }, $types); | ||
} | ||
|
||
|
||
/** | ||
* @param HasMediaSetInterface $object | ||
* @return array | ||
*/ | ||
public function getMediaSetDefinition(HasMediaSetInterface $object) | ||
{ | ||
if (isset($this->types[$object->getType()])) { | ||
return (array)$this->types[$object->getType()]; | ||
} | ||
|
||
return $object->getMediaSetDefinition(); | ||
} | ||
|
||
/** | ||
* @param string $type | ||
* @return array | ||
*/ | ||
public function getDefaultMediaSetDefinition($type) | ||
{ | ||
if (isset($this->types[$type])) { | ||
return $this->types[$type]; | ||
} | ||
|
||
return []; | ||
} | ||
} |
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