Skip to content

Commit

Permalink
行业调整
Browse files Browse the repository at this point in the history
  • Loading branch information
Janson committed Jul 28, 2017
1 parent 0f9e5c9 commit 0f7c954
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Vocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,26 @@ public static function getName($id) {
/**
* 获取包含的旧项
*
* @param int $id
* @param string|array $ids
* @param bool $withSelf 是否包含自身
* @return array
*/
public static function getInclude($id, $withSelf = true) {
$include = isset(self::$vocations[$id]['include']) ? self::$vocations[$id]['include'] : [];
public static function getInclude($ids, $withSelf = true) {
if (!is_array($ids)) {
$ids = explode(',', $ids);
}

if ($withSelf) {
array_push($include, $id);
$include = [];
foreach ($ids as $id) {
if (isset(self::$vocations[$id])) {
if (isset(self::$vocations[$id]['include'])) {
$include = array_merge($include, self::$vocations[$id]['include']);
}

if ($withSelf) {
array_push($include, $id);
}
}
}

return $include;
Expand Down

0 comments on commit 0f7c954

Please sign in to comment.