public function fetch($identifier, $version=null)
    {
        $portableElements = $this->getAllVersions($identifier);

        // No version, return latest version
        if (is_null($version)) {
            $this->krsortByVersion($portableElements);
            return $this->getModel()->createDataObject(reset($portableElements));
        }

        // Version is set, return associated record
        if (isset($portableElements[$version])) {
            return $this->getModel()->createDataObject($portableElements[$version]);
        }

        // Version is set, no record found
        throw new PortableElementNotFoundException(
            $this->getModel()->getId() . ' with identifier ' . $identifier. ' found, '
            . 'but version "' . $version . '" does not exist.'
        );
    }
public function fetch($identifier, $version=null)
    {
        $portableElements = $this->getAllVersions($identifier);

        // No version, return latest version
        if (is_null($version)) {
            $this->krsortByVersion($portableElements);
            return $this->getModel()->createDataObject(reset($portableElements));
        }

        // Version is set, return associated record
        if (isset($portableElements[$version])) {
            return $this->getModel()->createDataObject($portableElements[$version]);
        }

        // Version is set, no record found
        throw new PortableElementNotFoundException(
            $this->getModel()->getId() . ' with identifier ' . $identifier. ' found, '
            . 'but version "' . $version . '" does not exist.'
        );
    }
public function fetch ( $ identifier , $ version = null ) { $ portableElements = $ this -> getAllVersions ( $ identifier ) ; // No version, return latest version if ( is_null ( $ version ) ) { $ this -> krsortByVersion ( $ portableElements ) ; return $ this -> getModel ( ) -> createDataObject ( reset ( $ portableElements ) ) ; } // Version is set, return associated record if ( isset ( $ portableElements [ $ version ] ) ) { return $ this -> getModel ( ) -> createDataObject ( $ portableElements [ $ version ] ) ; } // Version is set, no record found throw new PortableElementNotFoundException ( $ this -> getModel ( ) -> getId ( ) . ' with identifier ' . $ identifier . ' found, ' . 'but version "' . $ version . '" does not exist.' ) ; }
Fetch a portable element with identifier & version

@param $identifier
@param null $version
@return PortableElementObject
@throws PortableElementNotFoundException
Fetch a portable element with identifier & version