当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage\Storage类代码示例

本文整理汇总了PHP中OC\Files\Storage\Storage的典型用法代码示例。如果您正苦于以下问题:PHP Storage类的具体用法?PHP Storage怎么用?PHP Storage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  * @throws \RuntimeException
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
     $result = \OC_DB::executeAudited($sql, array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $connection = \OC_DB::getConnection();
         if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) {
             $this->numericId = \OC_DB::insertid('*PREFIX*storages');
         } else {
             $result = \OC_DB::executeAudited($sql, array($this->storageId));
             if ($row = $result->fetchRow()) {
                 $this->numericId = $row['numeric_id'];
             } else {
                 throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
             }
         }
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:30,代码来源:storage.php

示例2: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:11,代码来源:permissions.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->remoteUser = $this->getUniqueID('remoteuser');
     $this->storage = $this->getMockBuilder('\\OCA\\Files_Sharing\\External\\Storage')->disableOriginalConstructor()->getMock();
     $this->storage->expects($this->any())->method('getId')->will($this->returnValue('dummystorage::'));
     $this->cache = new \OCA\Files_Sharing\External\Cache($this->storage, 'http://example.com/owncloud', $this->remoteUser);
     $this->cache->put('test.txt', array('mimetype' => 'text/plain', 'size' => 5, 'mtime' => 123));
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:9,代码来源:cache.php

示例4: testGetPermissions

 /**
  * Test that the permissions of shared directory are returned correctly
  */
 function testGetPermissions()
 {
     $sharedDirPerms = $this->sharedStorage->getPermissions('shareddir');
     $this->assertEquals(31, $sharedDirPerms);
     $sharedDirPerms = $this->sharedStorage->getPermissions('shareddir/textfile.txt');
     $this->assertEquals(31, $sharedDirPerms);
     $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted');
     $this->assertEquals(7, $sharedDirRestrictedPerms);
     $sharedDirRestrictedPerms = $this->sharedStorageRestrictedShare->getPermissions('shareddirrestricted/textfile.txt');
     $this->assertEquals(7, $sharedDirRestrictedPerms);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:14,代码来源:permissions.php

示例5: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     if (strlen($this->storageId) > 64) {
         $this->storageId = md5($this->storageId);
     }
     $this->storageCache = new Storage($storage);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:15,代码来源:cache.php

示例6: getStorageMock

	/**
	 * Returns a storage mock that returns the given value as
	 * free space
	 *
	 * @param int $freeSpace free space value
	 * @return \OC\Files\Storage\Storage
	 */
	private function getStorageMock($freeSpace = 12) {
		$this->storageMock = $this->getMock(
			'\OC\Files\Storage\Temporary',
			array('free_space'),
			array('')
		);


		$this->storageMock->expects($this->once())
			->method('free_space')
			->will($this->returnValue(12));
		return $this->storageMock;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:20,代码来源:helperstorage.php

示例7: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     if (strlen($this->storageId) > 64) {
         $this->storageId = md5($this->storageId);
     }
     $this->storageCache = new Storage($storage);
     $this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:16,代码来源:cache.php

示例8: setUp

 public function setUp()
 {
     // remember files_encryption state
     $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     // we want to tests with the encryption app disabled
     \OC_App::disable('files_encryption');
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $textData = "dummy file data\n";
     $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
     $this->storage->mkdir('folder');
     $this->storage->file_put_contents('foo.txt', $textData);
     $this->storage->file_put_contents('foo.png', $imgData);
     $this->storage->file_put_contents('folder/bar.txt', $textData);
     $this->storage->file_put_contents('folder/bar2.txt', $textData);
     $this->scanner = $this->storage->getScanner();
     $this->scanner->scan('');
     $this->cache = $this->storage->getCache();
     \OC\Files\Filesystem::tearDown();
     if (!self::$user) {
         self::$user = uniqid();
     }
     \OC_User::createUser(self::$user, 'password');
     \OC_User::setUserId(self::$user);
     \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
     Filesystem::clearMounts();
     Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
     \OC_Hook::clear('OC_Filesystem');
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:28,代码来源:updater.php

示例9: tearDown

 protected function tearDown()
 {
     \OC_User::setUserId($this->user);
     foreach ($this->storages as $storage) {
         $cache = $storage->getCache();
         $ids = $cache->getAll();
         $cache->clear();
     }
     if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
         system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
     }
     $this->logout();
     parent::tearDown();
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:14,代码来源:view.php

示例10: setUp

	protected function setUp() {
		parent::setUp();

		$this->storage = new \OC\Files\Storage\Temporary(array());
		$textData = "dummy file data\n";
		$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
		$this->storage->mkdir('folder');
		$this->storage->file_put_contents('foo.txt', $textData);
		$this->storage->file_put_contents('foo.png', $imgData);
		$this->storage->file_put_contents('folder/bar.txt', $textData);
		$this->storage->file_put_contents('folder/bar2.txt', $textData);

		$this->scanner = $this->storage->getScanner();
		$this->scanner->scan('');
		$this->cache = $this->storage->getCache();

		if (!self::$user) {
			self::$user = $this->getUniqueID();
		}

		\OC_User::createUser(self::$user, 'password');
		$this->loginAsUser(self::$user);

		Filesystem::init(self::$user, '/' . self::$user . '/files');

		Filesystem::clearMounts();
		Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');

		\OC_Hook::clear('OC_Filesystem');
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:30,代码来源:updaterlegacy.php

示例11: tearDown

 protected function tearDown()
 {
     \OC_User::setUserId($this->user);
     foreach ($this->storages as $storage) {
         $cache = $storage->getCache();
         $ids = $cache->getAll();
         $cache->clear();
     }
     if ($this->tempStorage && !\OC_Util::runningOnWindows()) {
         system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir()));
     }
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:15,代码来源:view.php

示例12: commitBatch

 /**
  * Commit the active propagation batch
  */
 public function commitBatch()
 {
     if (!$this->inBatch) {
         throw new \BadMethodCallException('Not in batch');
     }
     $this->inBatch = false;
     $this->connection->beginTransaction();
     $query = $this->connection->getQueryBuilder();
     $storageId = (int) $this->storage->getStorageCache()->getNumericId();
     $query->update('filecache')->set('mtime', $query->createFunction('GREATEST(`mtime`, ' . $query->createParameter('time') . ')'))->set('etag', $query->expr()->literal(uniqid()))->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')));
     $sizeQuery = $this->connection->getQueryBuilder();
     $sizeQuery->update('filecache')->set('size', $sizeQuery->createFunction('`size` + ' . $sizeQuery->createParameter('size')))->where($query->expr()->eq('storage', $query->expr()->literal($storageId, IQueryBuilder::PARAM_INT)))->andWhere($query->expr()->eq('path_hash', $query->createParameter('hash')))->andWhere($sizeQuery->expr()->gt('size', $sizeQuery->expr()->literal(-1, IQueryBuilder::PARAM_INT)));
     foreach ($this->batch as $item) {
         $query->setParameter('time', $item['time'], IQueryBuilder::PARAM_INT);
         $query->setParameter('hash', $item['hash']);
         $query->execute();
         if ($item['size']) {
             $sizeQuery->setParameter('size', $item['size'], IQueryBuilder::PARAM_INT);
             $sizeQuery->setParameter('hash', $item['hash']);
             $sizeQuery->execute();
         }
     }
     $this->batch = [];
     $this->connection->commit();
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:28,代码来源:Propagator.php

示例13: correctParentStorageMtime

 /**
  * update the storage_mtime of the direct parent in the cache to the mtime from the storage
  *
  * @param string $internalPath
  */
 private function correctParentStorageMtime($internalPath)
 {
     $parentId = $this->cache->getParentId($internalPath);
     $parent = dirname($internalPath);
     if ($parentId != -1) {
         $this->cache->update($parentId, array('storage_mtime' => $this->storage->filemtime($parent)));
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:13,代码来源:updater.php

示例14: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
     $result = \OC_DB::executeAudited($sql, array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $sql = 'INSERT INTO `*PREFIX*storages` (`id`) VALUES(?)';
         \OC_DB::executeAudited($sql, array($this->storageId));
         $this->numericId = \OC_DB::insertid('*PREFIX*storages');
     }
 }
开发者ID:Combustible,项目名称:core,代码行数:21,代码来源:storage.php

示例15: cleanFolder

 /**
  * remove deleted files in $path from the cache
  *
  * @param string $path
  */
 public function cleanFolder($path)
 {
     $cachedContent = $this->cache->getFolderContents($path);
     foreach ($cachedContent as $entry) {
         if (!$this->storage->file_exists($entry['path'])) {
             $this->cache->remove($entry['path']);
         }
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:14,代码来源:watcher.php


注:本文中的OC\Files\Storage\Storage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。