public static function getChildren($postRepository, $language, $postId, $activeId = 0, $getUnpublished = true)
	{
		$menuObject = array();

		$requirements = array(
			'lang' => $language,
			'parent' => $postId,
		);

		if (!$getUnpublished) {
			$requirements['is_public'] = 1;
		}

		$subItems = $postRepository->findBy($requirements, 'priority DESC, version DESC');

		foreach ($subItems as $item) {

			$menuItem = new TreeItem($item->id, $item->id, $item->title, $item->is_public, $item->lang, $item->is_unfolded);

			if ((int)$item->id == (int)$activeId) {
				$menuItem->setActive(true);
			} else {
				$menuItem->setActive(false);
			}


			if (self::hasChildren($postRepository, $language, $item->id)) {
				$children = (array)self::getChildren($postRepository, $language, $item->id, $activeId, $getUnpublished);
				$menuItem->addChildren($children);
			}

			$menuObject[] = $menuItem;
		}

		return $menuObject;
	}
public static function getChildren($postRepository, $language, $postId, $activeId = 0, $getUnpublished = true)
	{
		$menuObject = array();

		$requirements = array(
			'lang' => $language,
			'parent' => $postId,
		);

		if (!$getUnpublished) {
			$requirements['is_public'] = 1;
		}

		$subItems = $postRepository->findBy($requirements, 'priority DESC, version DESC');

		foreach ($subItems as $item) {

			$menuItem = new TreeItem($item->id, $item->id, $item->title, $item->is_public, $item->lang, $item->is_unfolded);

			if ((int)$item->id == (int)$activeId) {
				$menuItem->setActive(true);
			} else {
				$menuItem->setActive(false);
			}


			if (self::hasChildren($postRepository, $language, $item->id)) {
				$children = (array)self::getChildren($postRepository, $language, $item->id, $activeId, $getUnpublished);
				$menuItem->addChildren($children);
			}

			$menuObject[] = $menuItem;
		}

		return $menuObject;
	}
public static function getChildren ( $ postRepository , $ language , $ postId , $ activeId = 0 , $ getUnpublished = true ) { $ menuObject = array ( ) ; $ requirements = array ( 'lang' => $ language , 'parent' => $ postId , ) ; if ( ! $ getUnpublished ) { $ requirements [ 'is_public' ] = 1 ; } $ subItems = $ postRepository -> findBy ( $ requirements , 'priority DESC, version DESC' ) ; foreach ( $ subItems as $ item ) { $ menuItem = new TreeItem ( $ item -> id , $ item -> id , $ item -> title , $ item -> is_public , $ item -> lang , $ item -> is_unfolded ) ; if ( ( int ) $ item -> id == ( int ) $ activeId ) { $ menuItem -> setActive ( true ) ; } else { $ menuItem -> setActive ( false ) ; } if ( self :: hasChildren ( $ postRepository , $ language , $ item -> id ) ) { $ children = ( array ) self :: getChildren ( $ postRepository , $ language , $ item -> id , $ activeId , $ getUnpublished ) ; $ menuItem -> addChildren ( $ children ) ; } $ menuObject [ ] = $ menuItem ; } return $ menuObject ; }
Returns array filled with MenuItem objects
@param $postRepository
@param $language
@param $postId
@return bool
Returns array filled with MenuItem objects