Пример #1
0
 /**
  * Inserts the given tape.
  *
  * If an actual tape is provided, it is inserted directly.
  * If the name of a tape is provided, it will be fetched from the shelf, or created with the given name.
  *
  * @param Tape|string $tape
  *
  * @throws InvalidState If the tape could not be inserted.
  */
 public function insert($tape)
 {
     if ($this->tape) {
         throw new InvalidState(sprintf('Please eject the tape "%s" first.', $this->tape->getName()));
     }
     if (!$tape instanceof Tape) {
         try {
             $tape = $this->storage->fetch($tape);
         } catch (NotFound $e) {
             $tape = new Tape($tape);
         }
     }
     $this->tape = $tape;
 }
Пример #2
0
 public function store(Tape $tape)
 {
     $filePath = $this->getFilePathForName($tape->getName());
     file_put_contents($filePath, serialize($tape));
 }
Пример #3
0
 public function store(Tape $tape)
 {
     $key = $this->createKey($tape->getName());
     $this->tapes[$key] = $tape;
 }