private function loadItemData($itemRef, $path)
    {
        $cacheKey = $itemRef . $path;
        if(! empty($cacheKey) && isset($this->dataCache[$itemRef . $path])) {
            return $this->dataCache[$itemRef . $path];
        }

        $directoryIds = explode('|', $itemRef);
        if (count($directoryIds) < 3) {
            if (is_scalar($itemRef)) {
                $itemRefInfo = gettype($itemRef) . ': ' . strval($itemRef);
            } elseif (is_object($itemRef)) {
                $itemRefInfo = gettype($itemRef) . ': ' . get_class($itemRef);
            } else {
                $itemRefInfo = gettype($itemRef);
            }

            throw new \common_exception_InconsistentData("The itemRef (value = '${itemRefInfo}') is not formatted correctly.");
        }

        $itemUri = $directoryIds[0];
        $userDataLang = \common_session_SessionManager::getSession()->getDataLanguage();
        $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[2]);

        if ($directory->has($userDataLang))
        {
            $lang = $userDataLang;
        } elseif ($directory->has(DEFAULT_LANG)) {
            \common_Logger::d(
                $userDataLang . ' is not part of compilation directory for item : ' . $itemUri . ' use ' . DEFAULT_LANG
            );
            $lang = DEFAULT_LANG;
        } else {
            throw new \common_Exception(
                'item : ' . $itemUri . 'is neither compiled in ' . $userDataLang . ' nor in ' . DEFAULT_LANG
            );
        }
        try {
            $content = $directory->read($lang.DIRECTORY_SEPARATOR.$path);
            /** @var ItemAssetsReplacement $assetService */
            $assetService = $this->getServiceManager()->get(ItemAssetsReplacement::SERVICE_ID);
            $jsonContent = json_decode($content, true);
            $jsonAssets = [];
            if(isset($jsonContent['assets'])){
                foreach ($jsonContent['assets'] as $type => $assets){
                    foreach ($assets as $key => $asset){
                        $jsonAssets[$type][$key] = $assetService->postProcessAssets($asset);
                    }
                }
                $jsonContent["assets"] = $jsonAssets;
            }

            $this->dataCache[$cacheKey] = $jsonContent;
            return $this->dataCache[$cacheKey];
        } catch (\FileNotFoundException $e) {
            throw new \tao_models_classes_FileNotFoundException(
                $path . ' for item reference ' . $itemRef
            );
        } catch (\League\Flysystem\FileNotFoundException $e) {
            throw new \tao_models_classes_FileNotFoundException(
                $path . ' for item reference ' . $itemRef
            );
        }
    }
private function loadItemData($itemRef, $path)
    {
        $cacheKey = $itemRef . $path;
        if(! empty($cacheKey) && isset($this->dataCache[$itemRef . $path])) {
            return $this->dataCache[$itemRef . $path];
        }

        $directoryIds = explode('|', $itemRef);
        if (count($directoryIds) < 3) {
            if (is_scalar($itemRef)) {
                $itemRefInfo = gettype($itemRef) . ': ' . strval($itemRef);
            } elseif (is_object($itemRef)) {
                $itemRefInfo = gettype($itemRef) . ': ' . get_class($itemRef);
            } else {
                $itemRefInfo = gettype($itemRef);
            }

            throw new \common_exception_InconsistentData("The itemRef (value = '${itemRefInfo}') is not formatted correctly.");
        }

        $itemUri = $directoryIds[0];
        $userDataLang = \common_session_SessionManager::getSession()->getDataLanguage();
        $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[2]);

        if ($directory->has($userDataLang))
        {
            $lang = $userDataLang;
        } elseif ($directory->has(DEFAULT_LANG)) {
            \common_Logger::d(
                $userDataLang . ' is not part of compilation directory for item : ' . $itemUri . ' use ' . DEFAULT_LANG
            );
            $lang = DEFAULT_LANG;
        } else {
            throw new \common_Exception(
                'item : ' . $itemUri . 'is neither compiled in ' . $userDataLang . ' nor in ' . DEFAULT_LANG
            );
        }
        try {
            $content = $directory->read($lang.DIRECTORY_SEPARATOR.$path);
            /** @var ItemAssetsReplacement $assetService */
            $assetService = $this->getServiceManager()->get(ItemAssetsReplacement::SERVICE_ID);
            $jsonContent = json_decode($content, true);
            $jsonAssets = [];
            if(isset($jsonContent['assets'])){
                foreach ($jsonContent['assets'] as $type => $assets){
                    foreach ($assets as $key => $asset){
                        $jsonAssets[$type][$key] = $assetService->postProcessAssets($asset);
                    }
                }
                $jsonContent["assets"] = $jsonAssets;
            }

            $this->dataCache[$cacheKey] = $jsonContent;
            return $this->dataCache[$cacheKey];
        } catch (\FileNotFoundException $e) {
            throw new \tao_models_classes_FileNotFoundException(
                $path . ' for item reference ' . $itemRef
            );
        } catch (\League\Flysystem\FileNotFoundException $e) {
            throw new \tao_models_classes_FileNotFoundException(
                $path . ' for item reference ' . $itemRef
            );
        }
    }
private function loadItemData ( $ itemRef , $ path ) { $ cacheKey = $ itemRef . $ path ; if ( ! empty ( $ cacheKey ) && isset ( $ this -> dataCache [ $ itemRef . $ path ] ) ) { return $ this -> dataCache [ $ itemRef . $ path ] ; } $ directoryIds = explode ( '|' , $ itemRef ) ; if ( count ( $ directoryIds ) < 3 ) { if ( is_scalar ( $ itemRef ) ) { $ itemRefInfo = gettype ( $ itemRef ) . ': ' . strval ( $ itemRef ) ; } elseif ( is_object ( $ itemRef ) ) { $ itemRefInfo = gettype ( $ itemRef ) . ': ' . get_class ( $ itemRef ) ; } else { $ itemRefInfo = gettype ( $ itemRef ) ; } throw new \ common_exception_InconsistentData ( "The itemRef (value = '${itemRefInfo}') is not formatted correctly." ) ; } $ itemUri = $ directoryIds [ 0 ] ; $ userDataLang = \ common_session_SessionManager :: getSession ( ) -> getDataLanguage ( ) ; $ directory = \ tao_models_classes_service_FileStorage :: singleton ( ) -> getDirectoryById ( $ directoryIds [ 2 ] ) ; if ( $ directory -> has ( $ userDataLang ) ) { $ lang = $ userDataLang ; } elseif ( $ directory -> has ( DEFAULT_LANG ) ) { \ common_Logger :: d ( $ userDataLang . ' is not part of compilation directory for item : ' . $ itemUri . ' use ' . DEFAULT_LANG ) ; $ lang = DEFAULT_LANG ; } else { throw new \ common_Exception ( 'item : ' . $ itemUri . 'is neither compiled in ' . $ userDataLang . ' nor in ' . DEFAULT_LANG ) ; } try { $ content = $ directory -> read ( $ lang . DIRECTORY_SEPARATOR . $ path ) ; /** @var ItemAssetsReplacement $assetService */ $ assetService = $ this -> getServiceManager ( ) -> get ( ItemAssetsReplacement :: SERVICE_ID ) ; $ jsonContent = json_decode ( $ content , true ) ; $ jsonAssets = [ ] ; if ( isset ( $ jsonContent [ 'assets' ] ) ) { foreach ( $ jsonContent [ 'assets' ] as $ type => $ assets ) { foreach ( $ assets as $ key => $ asset ) { $ jsonAssets [ $ type ] [ $ key ] = $ assetService -> postProcessAssets ( $ asset ) ; } } $ jsonContent [ "assets" ] = $ jsonAssets ; } $ this -> dataCache [ $ cacheKey ] = $ jsonContent ; return $ this -> dataCache [ $ cacheKey ] ; } catch ( \ FileNotFoundException $ e ) { throw new \ tao_models_classes_FileNotFoundException ( $ path . ' for item reference ' . $ itemRef ) ; } catch ( \ League \ Flysystem \ FileNotFoundException $ e ) { throw new \ tao_models_classes_FileNotFoundException ( $ path . ' for item reference ' . $ itemRef ) ; } }
Get the data folder from a given item definition
@param string $itemRef - formatted as itemURI|publicFolderURI|privateFolderURI
@return array the path
@throws \common_Exception
Get the data folder from a given item definition