public function getItemDirectory(core_kernel_classes_Resource $item, $language = '')
    {
        // Get file by language
        if ($language === '') {
            $files = $item->getPropertyValues($this->itemContentProperty);
        } else {
            $files = $item->getPropertyValuesByLg($this->itemContentProperty, $language)->toArray();
        }

        // If multiple files then throw exception
        if (count($files) > 1) {
            common_Logger::i(print_r($files, true));
            throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
        }

        // If there is one file then return directory
        if (count($files) == 1) {
            $file = reset($files);
            $file = is_object($file) && $file instanceof core_kernel_classes_Resource ? $file->getUri() : (string)$file;
            return $this->getFileReferenceSerializer()->unserializeDirectory($file);
        }

        // Otherwise there is no file, create one and return directory
        $model = $this->getItemModel($item);
        if (is_null($model)) {
            throw new common_Exception('Call to ' . __FUNCTION__ . ' for item without model');
        }

        // File does not exist, let's create it
        $actualLang = empty($language) ? $this->getSessionLg() : $language;
        $filePath = tao_helpers_Uri::getUniqueId($item->getUri())
            . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $actualLang;

        // Create item directory
        $itemDirectory = $this->getDefaultItemDirectory()->getDirectory($filePath);

        // Set uri file value as serial to item persistence
        $serial = $this->getFileReferenceSerializer()->serialize($itemDirectory);

        $item->setPropertyValueByLg($this->itemContentProperty, $serial, $actualLang);
        
        return $itemDirectory;
    }
public function getItemDirectory(core_kernel_classes_Resource $item, $language = '')
    {
        // Get file by language
        if ($language === '') {
            $files = $item->getPropertyValues($this->itemContentProperty);
        } else {
            $files = $item->getPropertyValuesByLg($this->itemContentProperty, $language)->toArray();
        }

        // If multiple files then throw exception
        if (count($files) > 1) {
            common_Logger::i(print_r($files, true));
            throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
        }

        // If there is one file then return directory
        if (count($files) == 1) {
            $file = reset($files);
            $file = is_object($file) && $file instanceof core_kernel_classes_Resource ? $file->getUri() : (string)$file;
            return $this->getFileReferenceSerializer()->unserializeDirectory($file);
        }

        // Otherwise there is no file, create one and return directory
        $model = $this->getItemModel($item);
        if (is_null($model)) {
            throw new common_Exception('Call to ' . __FUNCTION__ . ' for item without model');
        }

        // File does not exist, let's create it
        $actualLang = empty($language) ? $this->getSessionLg() : $language;
        $filePath = tao_helpers_Uri::getUniqueId($item->getUri())
            . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $actualLang;

        // Create item directory
        $itemDirectory = $this->getDefaultItemDirectory()->getDirectory($filePath);

        // Set uri file value as serial to item persistence
        $serial = $this->getFileReferenceSerializer()->serialize($itemDirectory);

        $item->setPropertyValueByLg($this->itemContentProperty, $serial, $actualLang);
        
        return $itemDirectory;
    }
public function getItemDirectory ( core_kernel_classes_Resource $ item , $ language = '' ) { // Get file by language if ( $ language === '' ) { $ files = $ item -> getPropertyValues ( $ this -> itemContentProperty ) ; } else { $ files = $ item -> getPropertyValuesByLg ( $ this -> itemContentProperty , $ language ) -> toArray ( ) ; } // If multiple files then throw exception if ( count ( $ files ) > 1 ) { common_Logger :: i ( print_r ( $ files , true ) ) ; throw new common_Exception ( __METHOD__ . ': Item ' . $ item -> getUri ( ) . ' has multiple.' ) ; } // If there is one file then return directory if ( count ( $ files ) == 1 ) { $ file = reset ( $ files ) ; $ file = is_object ( $ file ) && $ file instanceof core_kernel_classes_Resource ? $ file -> getUri ( ) : ( string ) $ file ; return $ this -> getFileReferenceSerializer ( ) -> unserializeDirectory ( $ file ) ; } // Otherwise there is no file, create one and return directory $ model = $ this -> getItemModel ( $ item ) ; if ( is_null ( $ model ) ) { throw new common_Exception ( 'Call to ' . __FUNCTION__ . ' for item without model' ) ; } // File does not exist, let's create it $ actualLang = empty ( $ language ) ? $ this -> getSessionLg ( ) : $ language ; $ filePath = tao_helpers_Uri :: getUniqueId ( $ item -> getUri ( ) ) . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $ actualLang ; // Create item directory $ itemDirectory = $ this -> getDefaultItemDirectory ( ) -> getDirectory ( $ filePath ) ; // Set uri file value as serial to item persistence $ serial = $ this -> getFileReferenceSerializer ( ) -> serialize ( $ itemDirectory ) ; $ item -> setPropertyValueByLg ( $ this -> itemContentProperty , $ serial , $ actualLang ) ; return $ itemDirectory ; }
Returns the items flysystem directory

@param core_kernel_classes_Resource $item
@param string $language
@return \oat\oatbox\filesystem\Directory
@throws Exception
@throws common_Exception
@throws core_kernel_persistence_Exception
Returns the items flysystem directory