コード例 #1
0
ファイル: ObjectUtil.php プロジェクト: Silwereth/core
 /**
  * Post-process an object's expanded category data to generate relative paths.
  *
  * @param array   &$obj        The object we wish to post-process.
  * @param array   $rootCatsIDs The root category ID for the relative path creation.
  * @param boolean $includeRoot Whether or not to include the root folder in the relative path (optional) (default=false).
  *
  * @return The object with the additionally expanded category data is altered in place and returned
  */
 public static function postProcessExpandedObjectCategories(&$obj, $rootCatsIDs, $includeRoot = false)
 {
     if (!$obj) {
         throw new \Exception(__f('Invalid object in %s', 'postProcessExpandedObjectCategories'));
     }
     $rootCats = CategoryUtil::getCategoriesByRegistry($rootCatsIDs);
     if (empty($rootCats)) {
         return false;
     }
     // if the function was called to process the object categories
     if (isset($obj['__CATEGORIES__'])) {
         $ak = array_keys($obj['__CATEGORIES__']);
         foreach ($ak as $prop) {
             CategoryUtil::buildRelativePathsForCategory($rootCats[$prop], $obj['__CATEGORIES__'][$prop], $includeRoot);
         }
         self::makeBC($obj['__CATEGORIES__']);
         // else, if the function was called to process the categories array directly
     } else {
         $ak = array_keys($obj);
         foreach ($ak as $prop) {
             CategoryUtil::buildRelativePathsForCategory($rootCats[$prop], $obj[$prop], $includeRoot);
         }
         self::makeBC($obj);
     }
     return;
 }