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


PHP PersistenceManagerInterface::remove方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Persistence\PersistenceManagerInterface::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP PersistenceManagerInterface::remove方法的具体用法?PHP PersistenceManagerInterface::remove怎么用?PHP PersistenceManagerInterface::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Persistence\PersistenceManagerInterface的用法示例。


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

示例1: deleteById

 /**
  * @param string $identifier
  */
 public function deleteById($identifier)
 {
     $object = $this->findById($identifier);
     // todo: check if we want to throw an exception here
     if ($object !== NULL) {
         $this->persistenceManager->remove($object);
         $this->persistenceManager->persistAll();
     }
 }
开发者ID:flow2lab,项目名称:eventsourcing,代码行数:12,代码来源:AbstractModelProjector.php

示例2: remove

 /**
  * Removes an object from this repository.
  *
  * @param object $object The object to remove
  * @return void
  * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  * @api
  */
 public function remove($object)
 {
     if (!is_object($object) || !$object instanceof $this->entityClassName) {
         $type = is_object($object) ? get_class($object) : gettype($object);
         throw new \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException('The value given to remove() was ' . $type . ' , however the ' . get_class($this) . ' can only handle ' . $this->entityClassName . ' instances.', 1298403442);
     }
     $this->persistenceManager->remove($object);
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:16,代码来源:Repository.php

示例3: cleanCommand

 /**
  * Clean up resource registry
  *
  * This command checks the resource registry (that is the database tables) for orphaned resource objects which don't
  * seem to have any corresponding data anymore (for example: the file in Data/Persistent/Resources has been deleted
  * without removing the related Resource object).
  *
  * If the TYPO3.Media package is active, this command will also detect any assets referring to broken resources
  * and will remove the respective Asset object from the database when the broken resource is removed.
  *
  * This command will ask you interactively what to do before deleting anything.
  *
  * @return void
  */
 public function cleanCommand()
 {
     $this->outputLine('Checking if resource data exists for all known resource objects ...');
     $this->outputLine();
     $mediaPackagePresent = $this->packageManager->isPackageActive('TYPO3.Media');
     $resourcesCount = $this->resourceRepository->countAll();
     $this->output->progressStart($resourcesCount);
     $brokenResources = array();
     $relatedAssets = new \SplObjectStorage();
     foreach ($this->resourceRepository->findAll() as $resource) {
         $this->output->progressAdvance(1);
         /* @var \TYPO3\Flow\Resource\Resource $resource */
         $stream = $resource->getStream();
         if (!is_resource($stream)) {
             $brokenResources[] = $resource;
         }
     }
     $this->output->progressFinish();
     $this->outputLine();
     if ($mediaPackagePresent && count($brokenResources) > 0) {
         $assetRepository = $this->objectManager->get('TYPO3\\Media\\Domain\\Repository\\AssetRepository');
         /* @var \TYPO3\Media\Domain\Repository\AssetRepository $assetRepository */
         foreach ($brokenResources as $resource) {
             $assets = $assetRepository->findByResource($resource);
             if ($assets !== NULL) {
                 $relatedAssets[$resource] = $assets;
             }
         }
     }
     if (count($brokenResources) > 0) {
         $this->outputLine('<b>Found %s broken resource(s):</b>', array(count($brokenResources)));
         $this->outputLine();
         foreach ($brokenResources as $resource) {
             $this->outputLine('%s (%s) %s', array($resource->getFilename(), $resource->getSha1(), $resource->getCollectionName()));
             if (isset($relatedAssets[$resource])) {
                 foreach ($relatedAssets[$resource] as $asset) {
                     $this->outputLine(' -> %s (%s)', array(get_class($asset), $asset->getIdentifier()));
                 }
             }
         }
         $response = NULL;
         while (!in_array($response, array('y', 'n', 'c'))) {
             $response = $this->output->ask('<comment>Do you want to remove all broken resource objects and related assets from the database? (y/n/c) </comment>');
         }
         switch ($response) {
             case 'y':
                 foreach ($brokenResources as $resource) {
                     $resource->disableLifecycleEvents();
                     $this->persistenceManager->remove($resource);
                     if (isset($relatedAssets[$resource])) {
                         foreach ($relatedAssets[$resource] as $asset) {
                             $assetRepository->remove($asset);
                         }
                     }
                 }
                 $this->outputLine('Removed %s resource object(s) from the database.', array(count($brokenResources)));
                 break;
             case 'n':
                 $this->outputLine('Did not delete any resource objects.');
                 break;
             case 'c':
                 $this->outputLine('Stopping. Did not delete any resource objects.');
                 $this->quit(0);
                 break;
         }
     }
 }
开发者ID:sakona999,项目名称:flow-login,代码行数:81,代码来源:ResourceCommandController.php


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