/** @return FourSide */ public function getFourSide($key, $defaultValue = null) { $value = $this->getSoft($key, $defaultValue); if ($value === null || $value === Configuration::VALUE_UNSET) { $value = $defaultValue; } return Tools::decodeFourSide($value); }
private function extendSpriteSettings(Job $job, Sprite $sprite) { $spriteSettings = $job->configuration->getNode('sprites'); foreach ($spriteSettings as $spriteSetting) { if ($spriteSetting === null) { // Empty node continue; } if (isset($spriteSetting->filters)) { $matches = Tools::matches($spriteSetting->filters, $sprite->name) || Tools::matches($spriteSetting->filters, $sprite->originalName); } else { $matches = true; } if (!$matches) { continue; } $attributes = new \stdClass(); $passAttributes = ['name']; $passAttributes = array_flip($passAttributes); $excludeAttributes = ['filter']; $excludeAttributes = array_flip($excludeAttributes); foreach ($spriteSetting as $atbName => $atbValue) { if (array_key_exists($atbName, $excludeAttributes)) { continue; } elseif (array_key_exists($atbName, $passAttributes)) { $sprite->{$atbName} = $atbValue; } elseif ($atbName == 'margin') { $s = Tools::decodeFourSide($atbValue); if ($s) { $sprite->marginTop = $s->top; $sprite->marginRight = $s->right; $sprite->marginBottom = $s->bottom; $sprite->marginLeft = $s->left; } } elseif ($atbName == 'padding') { $s = Tools::decodeFourSide($atbValue); if ($s) { $sprite->paddingTop = $s->top; $sprite->paddingRight = $s->right; $sprite->paddingBottom = $s->bottom; $sprite->paddingLeft = $s->left; } } else { $attributes->{$atbName} = $atbValue; } } $sprite->configuration->extend($attributes); } }