move() публичный Метод

public move ( $source, $target )
Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function move($pk, $targetPk, $position = 'first', $targetObjectKey = null, $overwrite = false)
 {
     if ($pk) {
         $path = $this->getPathFromPK($pk);
     } else {
         $path = '/';
     }
     $target = is_numeric($targetPk['id']) ? $this->webFilesystem->getPath($targetPk['id']) : $targetPk['id'];
     $target = $target . '/' . basename($path);
     if (!$overwrite && $this->webFilesystem->has($target)) {
         return ['targetExists' => true];
     }
     $this->checkAccess($path);
     $this->checkAccess($target);
     return $this->webFilesystem->move($path, $target);
 }
Пример #2
0
 /**
  * @ApiDoc(
  *  section="File Manager",
  *  description="Moves a file in /web to $target in /web"
  * )
  *
  * @Rest\RequestParam(name="path", requirements=".+", strict=true, description="The file path")
  * @Rest\RequestParam(name="target", requirements=".*", strict=true, description="The target file path")
  * @Rest\RequestParam(name="overwrite", requirements=".*", default="false", description="If the target should be overwritten")
  *
  * @Rest\Post("/admin/file/move")
  *
  * @param ParamFetcher $paramFetcher
  *
  * @return array|bool returns [targetExists => true] when the target exists and $overwrite=false, otherwise true/false.
  */
 public function moveFileAction(ParamFetcher $paramFetcher)
 {
     $path = trim($paramFetcher->get('path'));
     $target = trim($paramFetcher->get('target'));
     $overwrite = filter_var($paramFetcher->get('overwrite'), FILTER_VALIDATE_BOOLEAN);
     if (!$overwrite && $this->webFilesystem->has($target)) {
         return ['targetExists' => true];
     }
     //are we allowed to update the old file?
     $aclRequest = ACLRequest::create('jarves/file', ['path' => $path])->onlyAddMode();
     $this->checkOrThrow($aclRequest);
     //are we allowed to create this type of file?
     $newFile = $this->webFilesystem->getFile($path)->toArray();
     $newFile['path'] = $target;
     $aclRequest = ACLRequest::create('jarves/file', $newFile)->setPrimaryObjectItem($newFile)->onlyAddMode();
     $this->checkOrThrow($aclRequest);
     $this->newFeed($path, 'moved', sprintf('from %s to %s', $path, $target));
     $result = $this->webFilesystem->move($path, $target);
     return $result;
 }