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


PHP Filesystem::chown方法代码示例

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


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

示例1: _changeDirectoryOwner

 /**
  * Change directory owners.
  *
  * @param Domain $domain
  *
  * @return bool
  */
 protected function _changeDirectoryOwner(Domain $domain)
 {
     $fs = new Filesystem();
     try {
         $fs->chown($domain->getPath(), self::_root);
         // Domain Root
         $fs->chgrp($domain->getPath(), $domain->getUser()->getGroupname(), true);
         // Domain Root + Child
         // Child directories
         $fs->chown($this->_getDefaultDirs($domain->getPath()), $domain->getUser()->getName(), true);
     } catch (IOException $e) {
         return false;
     }
     return true;
 }
开发者ID:jeboehm,项目名称:lampcp,代码行数:22,代码来源:DirectoryBuilderService.php

示例2: testChownFail

 /**
  * @expectedException \Symfony\Component\Filesystem\Exception\IOException
  */
 public function testChownFail()
 {
     $this->markAsSkippedIfPosixIsMissing();
     $dir = $this->workspace . DIRECTORY_SEPARATOR . 'dir';
     mkdir($dir);
     $this->filesystem->chown($dir, 'user' . time() . mt_rand(1000, 9999));
 }
开发者ID:kadvani1,项目名称:symfony,代码行数:10,代码来源:FilesystemTest.php

示例3: checkDirectory

 public static function checkDirectory($path)
 {
     $fs = new Filesystem();
     if ($fs->exists($path) && !is_writeable($path)) {
         $fs->chown($path, 0700);
     } else {
         $fs->mkdir($path, 0700);
     }
 }
开发者ID:jmolivas,项目名称:backup_oop,代码行数:9,代码来源:File.php

示例4: chown

 /**
  * {@inheritdoc}
  */
 public function chown($paths, string $user, bool $recursive = false)
 {
     try {
         $this->filesystem->chown($paths, $user, $recursive);
     } catch (IOException $exception) {
         throw new FilesystemException($exception->getMessage(), $exception->getPath(), $exception);
     } catch (Exception $exception) {
         throw new FilesystemException($exception->getMessage(), null, $exception);
     }
 }
开发者ID:novuso,项目名称:common-bundle,代码行数:13,代码来源:SymfonyFilesystem.php

示例5: chown

 /**
  * {@inheritdoc}
  */
 public function chown($files, $user, $recursive = false)
 {
     try {
         $this->symfony_filesystem->chown($files, $user, $recursive);
     } catch (\Symfony\Component\Filesystem\Exception\IOException $e) {
         // Try to recover filename
         // By the time this is written that is at the end of the message
         $error = trim($e->getMessage());
         $file = substr($error, strrpos($error, ' '));
         throw new filesystem_exception('CANNOT_CHANGE_FILE_GROUP', $file, array(), $e);
     }
 }
开发者ID:VOLKERMORD,项目名称:phpbb,代码行数:15,代码来源:filesystem.php

示例6: _changeDirectoryOwner

 /**
  * Lighttpd writes logs as www-data, so we have to change the owner of the logs directory.
  *
  * @param Domain $domain
  *
  * @return bool
  */
 protected function _changeDirectoryOwner(Domain $domain)
 {
     $result = parent::_changeDirectoryOwner($domain);
     $fs = new Filesystem();
     if ($fs->exists($domain->getPath() . '/logs')) {
         try {
             $fs->chown($domain->getPath() . '/logs', self::_http_user, true);
         } catch (IOException $e) {
             return false;
         }
     }
     return $result;
 }
开发者ID:jeboehm,项目名称:lampcp,代码行数:20,代码来源:DirectoryBuilderService.php

示例7: prepareUploadsFolder

 /**
  * @return void
  */
 public static function prepareUploadsFolder($uploadsDirectory)
 {
     if (!$uploadsDirectory) {
         return false;
     }
     $fs = new Filesystem();
     $uploadsDirectory = 'web/assets/uploads';
     if (!$fs->exists($uploadsDirectory)) {
         $fs->mkdir($uploadsDirectory, 0777);
     }
     $user = PHP_OS == 'Darwin' ? get_current_user() : 'www-data';
     try {
         $fs->chown($uploadsDirectory, $user);
         $fs->chmod($uploadsDirectory, 0777);
     } catch (\Exception $e) {
         // Not sure If we need to show this errors. Let's think about that...
     }
 }
开发者ID:alexyigidey8,项目名称:web-application-starter-kit,代码行数:21,代码来源:Storage.php

示例8: checkEnvironmentConfiguration

 /**
  * Check environment variables and applies modifications
  * @deprecated
  */
 private function checkEnvironmentConfiguration()
 {
     $fs = new Filesystem();
     // Creating backup folder if not exists
     if (!$fs->exists($this->configFileBkpFolder)) {
         $fs->mkdir($this->configFileBkpFolder, 0755);
         $fs->chown($this->configFileBkpFolder, 'jenkins');
         $fs->chgrp($this->configFileBkpFolder, 'jenkins');
     }
     // Creating user configuration template if not exists
     if (!$fs->exists($this->userConfigFileTemplate)) {
         $xmlString = '<user><fullName>FULLNAME</fullName><properties><hudson.model.PaneStatusProperties><collapsed/></hudson.model.PaneStatusProperties><jenkins.security.ApiTokenProperty><apiToken></apiToken></jenkins.security.ApiTokenProperty><com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty plugin="credentials@1.24"><domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash"/></com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty><hudson.model.MyViewsProperty><views><hudson.model.AllView><owner class="hudson.model.MyViewsProperty" reference="../../.."/><name>All</name><filterExecutors>false</filterExecutors><filterQueue>false</filterQueue><properties class="hudson.model.View$PropertyList"/></hudson.model.AllView></views></hudson.model.MyViewsProperty><hudson.search.UserSearchProperty><insensitiveSearch>false</insensitiveSearch></hudson.search.UserSearchProperty><hudson.tasks.Mailer_-UserProperty plugin="mailer@1.15"><emailAddress>EMAIL</emailAddress></hudson.tasks.Mailer_-UserProperty><jenkins.security.LastGrantedAuthoritiesProperty><roles><string></string></roles><timestamp></timestamp></jenkins.security.LastGrantedAuthoritiesProperty></properties></user>';
         $xml = new \SimpleXMLElement($xmlString);
         $dom = dom_import_simplexml($xml)->ownerDocument;
         $dom->formatOutput = true;
         $fileToWrite = fopen($this->userConfigFileTemplate, "w");
         fwrite($fileToWrite, $dom->saveXML());
         fclose($fileToWrite);
         $fs->chmod($this->userConfigFileTemplate, 0644);
         $fs->chown($this->userConfigFileTemplate, 'jenkins');
         $fs->chgrp($this->userConfigFileTemplate, 'jenkins');
     }
 }
开发者ID:spirit-dev,项目名称:dbox-portal,代码行数:27,代码来源:JenkinsAPICore.php

示例9: setPermissions

 /**
  * @param OutputInterface $output
  * @param array $files
  * @param $permission
  * @param $user
  * @param $group
  * @param bool $listFiles
  * @return int
  */
 public function setPermissions(\Symfony\Component\Console\Output\OutputInterface $output, $files, $permission, $user, $group, $listFiles = true)
 {
     $dryRun = $this->getConfigurationHelper()->getDryRun();
     if (empty($files)) {
         $output->writeln('<comment>No files found.</comment>');
         return 0;
     }
     $fs = new Filesystem();
     try {
         if ($dryRun) {
             $output->writeln("<comment>Modifying files permission to: " . decoct($permission) . "</comment>");
             $output->writeln("<comment>user: " . $user . "</comment>");
             $output->writeln("<comment>group: " . $group . "</comment>");
             if ($listFiles) {
                 $output->writeln("<comment>Files: </comment>");
                 foreach ($files as $file) {
                     $output->writeln($file->getPathName());
                 }
             }
         } else {
             if (!empty($permission)) {
                 $output->writeln("<comment>Modifying files permission to: " . decoct($permission) . "</comment>");
             }
             if (!empty($user)) {
                 $output->writeln("<comment>Modifying file user: " . $user . "</comment>");
             }
             if (!empty($group)) {
                 $output->writeln("<comment>Modifying file group: " . $group . "</comment>");
             }
             if ($listFiles) {
                 $output->writeln("<comment>Files: </comment>");
                 foreach ($files as $file) {
                     $output->writeln($file->getPathName());
                 }
             } else {
                 $output->writeln("<comment>Skipping file list (too long)... </comment>");
             }
             if (!empty($permission)) {
                 $fs->chmod($files, $permission, 00, true);
             }
             if (!empty($user)) {
                 $fs->chown($files, $user, true);
             }
             if (!empty($group)) {
                 $fs->chgrp($files, $group, true);
             }
         }
     } catch (IOException $e) {
         echo "\n An error occurred while removing the directory: " . $e->getMessage() . "\n ";
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:60,代码来源:SetPermissionsAfterInstallCommand.php

示例10: uploadProfileImagePost

 public function uploadProfileImagePost($image, $entity)
 {
     $extension = pathinfo($image->getClientOriginalName(), PATHINFO_EXTENSION);
     $name = sha1(uniqid(mt_rand(), true));
     $imageName = $name . '.' . $extension;
     if ($image->move($this->getAbsolutePathProfile($entity->getId()), $imageName)) {
         $absPathImage = $this->getAbsolutePathProfile($entity->getId()) . $imageName;
         $thumPath = $this->getWebPath() . $this->parameters['upload_directory'] . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'profile' . DIRECTORY_SEPARATOR . $entity->getId() . DIRECTORY_SEPARATOR . 'thumbnail';
         if (!is_dir($thumPath)) {
             $fs = new Filesystem();
             $fs->mkdir($thumPath, 0777);
             $fs->chown($thumPath, 'www-data', true);
             $fs->chgrp($thumPath, 'www-data', true);
             $fs->chmod($thumPath, 0777, 00, true);
         }
         $this->resizeImage($absPathImage, $name . '_260', 260, 123, $this->getAbsolutePathProfile($entity->getId()));
         $this->resizeImage($absPathImage, $name . '_142', 142, 88, $this->getAbsolutePathProfile($entity->getId()));
         return $imageName;
     } else {
         return null;
     }
 }
开发者ID:sebardo,项目名称:core,代码行数:22,代码来源:CoreManager.php

示例11: createUser

 /**
  * Create User
  * @param User $user
  * @return mixed
  * @deprecated
  */
 public function createUser(User $user)
 {
     // Fast Return in case of server stopped
     if (!$this->isServerAvailable()) {
         return null;
     }
     // Initialize values
     $userPathFolder = $this->userBasePath . $user->getUsername();
     $fs = new Filesystem();
     // Create user dir
     try {
         $fs->mkdir($userPathFolder, 0755);
         $fs->chown($userPathFolder, 'jenkins');
         $fs->chgrp($userPathFolder, 'jenkins');
     } catch (IOExceptionInterface $e) {
         //            dump("An error occurred while creating your directory at " . $e->getPath());
     }
     // Updating return values
     $retval['userPath'] = $userPathFolder;
     $retval['userPathCreated'] = $fs->exists($userPathFolder);
     // Creating config file
     $userConfigFile = $userPathFolder . "/config.xml";
     if ($fs->exists($this->userConfigFileTemplate) && $fs->exists($userPathFolder)) {
         // Opening config template
         $xmlTemplate = simplexml_load_file($this->userConfigFileTemplate);
         // Overriding some values
         $xmlTemplate->fullName = $user->getCommonName();
         $xmlTemplate->properties->{'hudson.tasks.Mailer_-UserProperty'}->emailAddress = $user->getEmail();
         // Writing new file in user space
         $dom = dom_import_simplexml($xmlTemplate)->ownerDocument;
         $dom->formatOutput = true;
         $fileToWrite = fopen($userConfigFile, "w");
         fwrite($fileToWrite, $dom->saveXML());
         fclose($fileToWrite);
         $fs->chmod($userConfigFile, 0644);
         $fs->chown($userConfigFile, 'jenkins');
         $fs->chgrp($userConfigFile, 'jenkins');
         // Updating return values
         $retval['templateExists'] = true;
         $retval['userConfFile'] = $fs->exists($userConfigFile);
     } else {
         $retval['userConfFile'] = false;
         $retval['templateExists'] = false;
     }
     // Updating Jenkins global rights
     if (file_exists($this->configFile)) {
         // Config file backup
         $retval['confFileBackuped'] = $this->backupConfigFile();
         // Opening config file
         $xmlFile = simplexml_load_file($this->configFile);
         // Overriding some values
         $authorizations = $xmlFile->authorizationStrategy;
         $authorizations->addChild("permission", "hudson.model.Hudson.Read:" . $user->getUsername());
         // Overriding config file
         $dom = dom_import_simplexml($xmlFile)->ownerDocument;
         $dom->formatOutput = true;
         $fileToWrite = fopen($this->configFile, "w");
         fwrite($fileToWrite, $dom->saveXML());
         fclose($fileToWrite);
         // Updating return values
         $retval['confFileUpdated'] = $fs->exists($this->configFile);
     } else {
         $retval['confFileBackuped'] = false;
         $retval['confFileUpdated'] = false;
     }
     // Restarting jenkins
     $retval['hostRestarted'] = $this->reloadHost();
     // Return values
     if ($retval['userPathCreated'] && $retval['confFileUpdated'] && $retval['userConfFile']) {
         return true;
     } else {
         return false;
     }
     //        return $retval;
 }
开发者ID:spirit-dev,项目名称:dbox-portal,代码行数:81,代码来源:JenkinsAPI.php

示例12: _chown

 /**
  * @param string|string[]|\Traversable $file
  * @param string $user
  * @param bool $recursive
  */
 protected function _chown($file, $user, $recursive = null)
 {
     $this->fs->chown($file, $user, $recursive);
 }
开发者ID:jjok,项目名称:Robo,代码行数:9,代码来源:FilesystemStack.php


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