Created
May 26, 2016 12:52
-
-
Save navarr/416aa8df188af274956f22bd47be861b to your computer and use it in GitHub Desktop.
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
<?php | |
array_walk($attributes, function($definition, $attribute) use ($defaults, $catalog) { | |
$definition = array_merge($defaults, $definition); | |
$catalog->addAttribute('catalog_product', $attribute, $definition); | |
}); | |
foreach($attributes as $definition => $attribute) { | |
$definition = array_merge($defaults, $definition); | |
$catalog->addAttribute('catalog_product', $attribute, $definition); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which one of these is "better"?
"Refactoring to Collections" would suggest that it's
array_walk
. Perhaps because array_walk specifically defines what it uses, it's better?$defaults
and$catalog
could, if so desired, be refactored out into a third parameter ofarray_walk
and the closure that would be an object type that would specifically define what those are.Where as
foreach
does not have that option.But is that really better?
And does it matter that this is an Install Script?