コード例 #1
0
ファイル: StorageTestCase.php プロジェクト: valisj/transfer
 /**
  * Tests all() method.
  */
 public function testAll()
 {
     $this->assertTrue($this->storage->add('value', 'id'));
     $this->assertCount(1, $this->storage->all());
     $this->assertTrue($this->storage->removeById('id'));
     $this->assertFalse($this->storage->containsId('id'));
     $this->assertCount(0, $this->storage->all());
 }
コード例 #2
0
 /**
  * Merges local storage with global storage.
  *
  * @param StorageInterface $storage Local storage
  */
 protected function mergeStorage(StorageInterface $storage)
 {
     foreach ($storage->all() as $id => $object) {
         $this->stack->getScope('global')->add($object);
     }
 }
コード例 #3
0
ファイル: Processor.php プロジェクト: valisj/transfer
 /**
  * Handles worker.
  *
  * @param WorkerInterface  $worker  Worker
  * @param mixed            $object  Object to handle
  * @param StorageInterface $storage Associated storage
  */
 protected function handleWorker(WorkerInterface $worker, $object, StorageInterface $storage)
 {
     $this->injectDependencies($worker);
     $modifiedObject = $worker->handle($object);
     if ($modifiedObject === null) {
         $storage->remove($object);
     } elseif ($modifiedObject !== $object) {
         $storage->remove($object);
         $storage->add($modifiedObject);
     }
     return $modifiedObject;
 }