From e91fd430e0400044020ecdf404ae99bc550f7497 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 2 May 2019 16:33:49 +0200 Subject: [PATCH] [Core] remove unused helper classes --- .../Component/Core/Helper/ArrayHelper.php | 116 ------------------ .../Component/Core/Helper/StringHelper.php | 40 ------ 2 files changed, 156 deletions(-) delete mode 100644 src/CoreShop/Component/Core/Helper/ArrayHelper.php delete mode 100644 src/CoreShop/Component/Core/Helper/StringHelper.php diff --git a/src/CoreShop/Component/Core/Helper/ArrayHelper.php b/src/CoreShop/Component/Core/Helper/ArrayHelper.php deleted file mode 100644 index bb33d016c2..0000000000 --- a/src/CoreShop/Component/Core/Helper/ArrayHelper.php +++ /dev/null @@ -1,116 +0,0 @@ - $val) { - for ($i = 0, $j = 0, $tmp = [$val], $count = count($args); $i < $count; $i++) { - if (is_array($val)) { - if (!isset($args[$i][$key]) || !is_array($args[$i][$key]) || empty($args[$i][$key])) { - $j++; - } else { - $tmp[] = $args[$i][$key]; - } - } elseif (!array_key_exists($key, $args[$i]) || $args[$i][$key] !== $val) { - $j++; - } - } - if (is_array($val)) { - $tmp = call_user_func_array([__CLASS__, __FUNCTION__], $tmp); - if (!empty($tmp)) { - $diff[$key] = $tmp; - } elseif ($j == $count) { - $diff[$key] = $val; - } - } elseif ($j == $count && $count) { - $diff[$key] = $val; - } - } - - return $diff; - } - - /** - * @param Concrete $object - * @param null $fieldDefintions - * - * @return array|false - */ - public static function objectToArray(Concrete $object, $fieldDefintions = null) - { - //if the given object is an array then loop through each element - if (is_array($object)) { - $collections = []; - foreach ($object as $o) { - $collections[] = static::objectToArray($o, $fieldDefintions); - } - - return $collections; - } - if (!is_object($object)) { - return false; - } - - //Custom list field definitions - if (null === $fieldDefintions) { - $fieldDefintions = $object->getClass()->getFieldDefinitions(); - } - - $collection = []; - foreach ($fieldDefintions as $fd) { - $fieldName = $fd->getName(); - $getter = 'get' . ucfirst($fieldName); - $value = $object->$getter(); - - switch ($fd->getFieldtype()) { - case 'fieldcollections': - if (($value instanceof Fieldcollection) && is_array($value->getItems())) { - /* @var $value Fieldcollection */ - $def = $value->getItemDefinitions(); - if (method_exists($def['children'], 'getFieldDefinitions')) { - $collection[$fieldName] = static::objectToArray($value->getItems(), $def['children']->getFieldDefinitions()); - } - } - - break; - - case 'date': - /* @var $value \Pimcore\Date */ - $collection[$fieldName] = ($value instanceof Carbon) ? $value->getTimestamp() : 0; - - break; - default: - /* @var $value string */ - $collection[$fieldName] = $value; - } - } - - //Parent class properties - $collection['id'] = $object->o_id; - $collection['key'] = $object->o_key; - - return $collection; - } -} diff --git a/src/CoreShop/Component/Core/Helper/StringHelper.php b/src/CoreShop/Component/Core/Helper/StringHelper.php deleted file mode 100644 index 0547e9ac88..0000000000 --- a/src/CoreShop/Component/Core/Helper/StringHelper.php +++ /dev/null @@ -1,40 +0,0 @@ -= 0 && strpos($haystack, $needle, $temp) !== false); - } -}