Source of file ReaderWriterBase.php
Size: 2,018 Bytes - Last Modified: 2021-12-23T10:29:05+00:00
/var/www/docs.ssmods.com/process/src/code/content/ReaderWriterBase.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | <?php /** * Base class that manages the identifier stuff for readers and writers * * @author <marcus@symbiote.com.au> * @license BSD License http://www.silverstripe.org/bsd-license */ abstract class ReaderWriterBase { /** * @var sets the identifier of this content. */ protected $sourceIdentifier; /** * The actual unique id that represents this content * * @var string */ protected $id; public function __construct($id, $sourceId = null) { $this->id = $id; $this->sourceIdentifier = $sourceId; } /** * @param string $sourceId */ public function setSourceIdentifier($sourceId) { $this->sourceIdentifier = $sourceId; } /** * A signature for this content store. For example, filesystem might return * * FILESYSTEM * * This only needs to be unique with respect to other content stores */ public function getSourceIdentifier() { return $this->sourceIdentifier ? $this->sourceIdentifier : str_replace(array('ContentWriter', 'ContentReader'), '', get_class($this)); } /** * Gets the underlying id if this item * * @return mixed */ public function getId() { return $this->id; } /** * Allow external code to focerfully change where we're accessing this content from */ public function setId($id) { $this->id = $id; } /** * Get content identifier that can be used to retrieve this content at a * later point in timer */ public function getContentId() { if (!$this->id) { throw new Exception("Null content identifier; content must be written before retrieving id"); } return $this->getSourceIdentifier() . ContentService::SEPARATOR . $this->id; } /** * Could this reader/writer be the source for the passed in URL? * * Useful for seeing if a content source is the provider for the given URL * * Returns a ContentReader if the URL can be resolved to an actual reader directly * * @param string $url * @return ContentReader */ public function providerOfUrl($url) { return false; } } |