Flatten a categories structure.

@param  arr    $arrCategories  The structured array of categories.
@return  array  Returns the flattened array of categories.
546970
public static function flattenCategories(Array $arrCategories)
  {
    $arrFlattend = array();
    
    foreach ($arrCategories as $category)
    {
      $arrFlattend[] = $category;
      if ($category->hasSubCategories())
      {
        $arrFlattend = array_merge($arrFlattend, \DmsLoader::flattenCategories($category->subCategories));
      }
    }
    
    return $arrFlattend;
  }
37588
public static function targetConfigs(array $categories): array
    {
        $configs = [];

        foreach ($categories as $category) {
            $configs[$category] = static::targetConfig($category);
        }

        return array_filter($configs);
    }
556652
public function getChildrenCategories(
        CategoryInterface $parentCategory,
        $recursively = false
    ) {
        $categories = $this
            ->createQueryBuilder('c')
            ->where('c.parent = :parent_category')
            ->setParameters([
                'parent_category' => $parentCategory,
            ])
            ->getQuery()
            ->getResult();

        if ($recursively && !empty($categories)) {
            foreach ($categories as $category) {
                $categories = array_merge(
                    $categories,
                    $this->getChildrenCategories($category, true)
                );
            }
        }

        return $categories;
    }
908524
public static function flatten(array $values)
    {
        $results = [];

        array_walk_recursive(
            $values,
            function($value) use (&$results) {
                $results[] = $value;
            }
        );

        return $results;
    }
736994
public function getCategoryValues($asArray = null)
    {
        if (!$this->owner->getIsNewRecord() && $this->_categoryValues === null) {
            $this->_categoryValues = [];

            /* @var ActiveRecord $category */
            foreach ($this->owner->{$this->categoryRelation} as $category) {
                $this->_categoryValues[] = $category->getAttribute($this->categoryValueAttribute);
            }
        }

        if ($asArray === null) {
            $asArray = $this->categoryValuesAsArray;
        }

        if ($asArray) {
            return $this->_categoryValues === null ? [] : $this->_categoryValues;
        } else {
            return $this->_categoryValues === null ? '' : implode(', ', $this->_categoryValues);
        }
    }
440308
public function addCategorie(\Haven\CoreBundle\Entity\Category $categories)
    {
        $this->categories[] = $categories;
    
        return $this;
    }
514769
public function flatten(array $toFlat, $preserveKeys = self::NO_PRESERVE_KEYS)
    {
        if ($preserveKeys === self::PRESERVE_KEYS) {
            $flatten = $this->flattenPreservingKeys($toFlat);
        } elseif ($preserveKeys === self::PRESERVE_ASSOCIATIVE_KEYS) {
            $flatten = $this->flattenPreservingAssociativeKeys($toFlat);
        } else {
            $flatten = $this->flattenNotPreservingKeys($toFlat);
        }

        return $flatten;
    }
858366
private function loadCategoriesFromClassContentDirectories($directories)
    {
        $classcontents = [];
        foreach ($directories as $directory) {
            $classcontents = array_merge($classcontents, self::getClassContentClassnamesFromDir($directory));
        }

        foreach ($classcontents as $class) {
            try {
                if (class_exists($class)) {
                    $this->buildCategoryFromClassContent(new $class());
                }
            } catch (ClassNotFoundException $e) {
                // nothing to do
            }
        }
    }
693112
public function category($arCategoryIDList, $bWithChildren = false)
    {
        if (!is_array($arCategoryIDList)) {
            $arCategoryIDList = [$arCategoryIDList];
        }

        $arResultIDList = [];
        foreach ($arCategoryIDList as $iCategoryID) {
            $arResultIDList = array_merge($arResultIDList, (array) ProductListStore::instance()->category->get($iCategoryID));
            if ($bWithChildren) {
                $arResultIDList = array_merge($arResultIDList, (array) $this->getIDListChildrenCategory($iCategoryID));
            }
        }

        return $this->intersect($arResultIDList);
    }
612835
public function getTrailIds(NewsCategoryModel $category)
    {
        static $ids;

        if (!\is_array($ids)) {
            /** @var Database $db */
            $db = $this->framework->createInstance(Database::class);

            $ids = $db->getParentRecords($category->id, $category->getTable());
            $ids = \array_map('intval', \array_unique($ids));

            // Remove the current category
            unset($ids[\array_search($category->id, $ids, true)]);
        }

        return $ids;
    }
971829
public function flatten(array $array)
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (in_array($key, $this->exceptions)) {
                $return[$key] = $value;
            } else {
                $return[] = $value;
            }
        }

        return $return;
    }
552578
protected static function deepen($sections): array
    {
        foreach ($sections as $section => $paths) {
            $sections[$section] = static::convertToTree($paths);
        }

        return $sections;
    }
746069
function flatten (arr) {
  return arr.reduce(function (acc, curr) {
    return acc.concat(Array.isArray(curr) ? flatten(curr) : curr)
  }, [])
}
975658
public function setDisplayCategories($displayCategories) {
		$this->displayCategories = [];

		foreach ($displayCategories as $displayCategory) {
			$this->addDisplayCategory($displayCategory);
		}

		return $this;
	}
710945
public function setCategories($categories)
    {
        foreach ($categories as $category) {
            $category->setBlog($this);
        }
        $this->categories = $categories;

        return $this;
    }
828031
function flatten(arr) {
  if (!isArray(arr)) {
    return arr;
  }
  var result = [];
  each(arr, function (item) {
    if (isArray(item)) {
      each(item, function (subItem) {
        result.push(subItem);
      });
    } else {
      result.push(item);
    }
  });
  return result;
}
703436
public function makeChildrenTree($categories)
    {
        $tmp = [];
        foreach ($categories as $key => $category){
            if(!key_exists('children', $category)) {
                $category->children = [];
            }

            // get children
            $children = $this->getChildren($category->categoryID);

            // call self to get a loop until every category has his children
            $category->children = $this->makeChildrenTree($children);

            $tmp[] = $category;
        }

        return Language::filterRows($tmp, false);
    }