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


PHP IOHelper::isReadable方法代码示例

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


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

示例1: isReadable

 /**
  * @return mixed
  */
 public function isReadable()
 {
     if (!$this->_isReadable) {
         $this->_isReadable = IOHelper::isReadable($this->getRealPath());
     }
     return $this->_isReadable;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:10,代码来源:BaseIO.php

示例2: getSource

 /**
  * Gets the source code of a template.
  *
  * @param  string $name The name of the template to load, or a StringTemplate object.
  *
  * @throws Exception
  * @return string The template source code.
  */
 public function getSource($name)
 {
     if (is_string($name)) {
         $template = $this->_findTemplate($name);
         if (IOHelper::isReadable($template)) {
             return IOHelper::getFileContents($template);
         } else {
             throw new Exception(Craft::t('Tried to read the template at {path}, but could not. Check the permissions.', array('path' => $template)));
         }
     } else {
         return $name->template;
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:21,代码来源:TemplateLoader.php

示例3: add

 /**
  * @inheritDoc IZip::add()
  *
  * @param string $sourceZip
  * @param string $pathToAdd
  * @param string $basePath
  * @param null   $pathPrefix
  *
  * @return bool
  */
 public function add($sourceZip, $pathToAdd, $basePath, $pathPrefix = null)
 {
     $zip = new \ZipArchive();
     $zipContents = $zip->open($sourceZip);
     if ($zipContents !== true) {
         Craft::log('Unable to open zip file: ' . $sourceZip, LogLevel::Error);
         return false;
     }
     if (IOHelper::fileExists($pathToAdd)) {
         $folderContents = array($pathToAdd);
     } else {
         $folderContents = IOHelper::getFolderContents($pathToAdd, true);
     }
     foreach ($folderContents as $itemToZip) {
         if (IOHelper::isReadable($itemToZip)) {
             // Figure out the relative path we'll be adding to the zip.
             $relFilePath = mb_substr($itemToZip, mb_strlen($basePath));
             if ($pathPrefix) {
                 $pathPrefix = IOHelper::normalizePathSeparators($pathPrefix);
                 $relFilePath = $pathPrefix . $relFilePath;
             }
             if (IOHelper::folderExists($itemToZip)) {
                 if (IOHelper::isFolderEmpty($itemToZip)) {
                     $zip->addEmptyDir($relFilePath);
                 }
             } elseif (IOHelper::fileExists($itemToZip)) {
                 // We can't use $zip->addFile() here but it's a terrible, horrible, POS method that's buggy on Windows.
                 $fileContents = IOHelper::getFileContents($itemToZip);
                 if (!$zip->addFromString($relFilePath, $fileContents)) {
                     Craft::log('There was an error adding the file ' . $itemToZip . ' to the zip: ' . $itemToZip, LogLevel::Error);
                 }
             }
         }
     }
     $zip->close();
     return true;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:47,代码来源:ZipArchive.php

示例4: add

 /**
  * Will add either a file or a folder to an existing zip file.  If it is a folder, it will add the contents recursively.
  *
  * @param string $sourceZip     The zip file to be added to.
  * @param string $pathToAdd     A file or a folder to add.  If it is a folder, it will recursively add the contents of the folder to the zip.
  * @param string $basePath      The root path of the file(s) to be added that will be removed before adding.
  * @param string $pathPrefix    A path to be prepended to each file before it is added to the zip.
  * @return bool
  */
 public function add($sourceZip, $pathToAdd, $basePath, $pathPrefix = null)
 {
     $zip = new \PclZip($sourceZip);
     if (IOHelper::fileExists($pathToAdd)) {
         $folderContents = array($pathToAdd);
     } else {
         $folderContents = IOHelper::getFolderContents($pathToAdd, true);
     }
     $filesToAdd = array();
     foreach ($folderContents as $itemToZip) {
         if (IOHelper::isReadable($itemToZip)) {
             if (IOHelper::folderExists($itemToZip) && IOHelper::isFolderEmpty($itemToZip) || IOHelper::fileExists($itemToZip)) {
                 $filesToAdd[] = $itemToZip;
             }
         }
     }
     if (!$pathPrefix) {
         $pathPrefix = '';
     }
     $result = $zip->add($filesToAdd, PCLZIP_OPT_ADD_PATH, $pathPrefix, PCLZIP_OPT_REMOVE_PATH, $basePath);
     if ($result == 0) {
         Craft::log('Unable to add to zip file: ' . $sourceZip, LogLevel::Error);
         return false;
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:35,代码来源:PclZip.php

示例5: getNewMigrations

 /**
  * Gets migrations that have no been applied yet AND have a later timestamp than the current Craft release.
  *
  * @param $plugin
  *
  * @return array
  */
 public function getNewMigrations($plugin = null)
 {
     $migrations = array();
     $migrationPath = $this->getMigrationPath($plugin);
     if (IOHelper::folderExists($migrationPath) && IOHelper::isReadable($migrationPath)) {
         $applied = array();
         foreach ($this->getMigrationHistory($plugin) as $migration) {
             $applied[] = $migration['version'];
         }
         $handle = opendir($migrationPath);
         while (($file = readdir($handle)) !== false) {
             if ($file[0] === '.') {
                 continue;
             }
             $path = IOHelper::normalizePathSeparators($migrationPath . $file);
             $class = IOHelper::getFileName($path, false);
             // Have we already run this migration?
             if (in_array($class, $applied)) {
                 continue;
             }
             if (preg_match('/^m(\\d\\d)(\\d\\d)(\\d\\d)_(\\d\\d)(\\d\\d)(\\d\\d)_\\w+\\.php$/', $file, $matches)) {
                 $migrations[] = $class;
             }
         }
         closedir($handle);
         sort($migrations);
     }
     return $migrations;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:36,代码来源:MigrationsService.php

示例6: getNewMigrations

 /**
  * Gets migrations that have no been applied yet AND have a later timestamp than the current Craft release.
  *
  * @param $plugin
  *
  * @return array
  */
 public function getNewMigrations($plugin = null)
 {
     $migrations = array();
     $migrationPath = $this->getMigrationPath($plugin);
     if (IOHelper::folderExists($migrationPath) && IOHelper::isReadable($migrationPath)) {
         $applied = array();
         foreach ($this->getMigrationHistory($plugin) as $migration) {
             $applied[] = $migration['version'];
         }
         $handle = opendir($migrationPath);
         if ($plugin) {
             $pluginInfo = craft()->plugins->getPluginInfo($plugin);
             $storedDate = $pluginInfo['installDate']->getTimestamp();
         } else {
             $storedDate = Craft::getReleaseDate()->getTimestamp();
         }
         while (($file = readdir($handle)) !== false) {
             if ($file[0] === '.') {
                 continue;
             }
             $path = IOHelper::normalizePathSeparators($migrationPath . $file);
             $class = IOHelper::getFileName($path, false);
             // Have we already run this migration?
             if (in_array($class, $applied)) {
                 continue;
             }
             if (preg_match('/^m(\\d\\d)(\\d\\d)(\\d\\d)_(\\d\\d)(\\d\\d)(\\d\\d)_\\w+\\.php$/', $file, $matches)) {
                 // Check the migration timestamp against the Craft release date
                 $time = strtotime('20' . $matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] . ':' . $matches[6]);
                 if ($time > $storedDate) {
                     $migrations[] = $class;
                 }
             }
         }
         closedir($handle);
         sort($migrations);
     }
     return $migrations;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:46,代码来源:MigrationsService.php


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