Add providers plugin.

This commit is contained in:
David Molineus
2014-12-29 16:19:43 +01:00
parent 633be6a2bc
commit 9059c74e62
4 changed files with 266 additions and 4 deletions

View File

@@ -169,7 +169,10 @@ abstract class AbstractMapper implements Mapper
*
* @return void
*/
abstract protected function initialize();
protected function initialize()
{
}
/**
* Use for specific build methods.
@@ -271,12 +274,18 @@ abstract class AbstractMapper implements Mapper
* @param Definition $definition The definition being built.
* @param \Model $model The model.
*/
private function applyOptions($options, $definition, $model)
protected function applyOptions($options, $definition, $model)
{
foreach ($options as $option => $mapping) {
$setter = 'set' . ucfirst($option);
$setter = 'set' . ucfirst($option);
$default = $this->getDefaultOption($option, $definition);
if ($model->$option != $this->getDefaultOption($option, $definition)) {
if ($model->$mapping === '1' || $model->$mapping === '') {
if (((bool) $model->$option) !== $default) {
$definition->$setter($model->$mapping);
}
}
elseif ($model->$mapping !== $default) {
$definition->$setter($model->$mapping);
}
}