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


PHP Folder::slashTerm方法代码示例

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


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

示例1: pwd

 /**
  * Returns the full path of the file.
  *
  * @return string Full path to the file
  */
 public function pwd()
 {
     if ($this->path === null) {
         $dir = $this->Folder->pwd();
         if (is_dir($dir)) {
             $this->path = $this->Folder->slashTerm($dir) . $this->name;
         }
     }
     return $this->path;
 }
开发者ID:wepbunny,项目名称:cake2,代码行数:15,代码来源:File.php

示例2: runjobs

 /**
  * Process the tasks when they need to run
  *
  * @access private
  * @return void
  */
 private function runjobs()
 {
     $dir = new Folder(TMP);
     // set processing flag so function takes place only once at any given time
     $processing = count($dir->find('\\.scheduler_running_flag'));
     $processingFlag = new File($dir->slashTerm($dir->pwd()) . '.scheduler_running_flag');
     if ($processing && time() - $processingFlag->lastChange() < $this->processingTimeout) {
         $this->out("Scheduler already running! Exiting.");
         return false;
     } else {
         $processingFlag->delete();
         $processingFlag->create();
     }
     if (!$this->storePath) {
         $this->storePath = TMP;
     }
     // look for a store of the previous run
     $store = "";
     $storeFilePath = $this->storePath . $this->storeFile;
     if (file_exists($storeFilePath)) {
         $store = file_get_contents($storeFilePath);
     }
     $this->out('Reading from: ' . $storeFilePath);
     // build or rebuild the store
     if ($store != '') {
         $store = json_decode($store, true);
     } else {
         $store = $this->schedule;
     }
     // run the jobs that need to be run, record the time
     foreach ($this->schedule as $name => $job) {
         $now = new DateTime();
         $task = $job['task'];
         $action = $job['action'];
         // if the job has never been run before, create it
         if (!isset($store[$name])) {
             $store[$name] = $job;
         }
         // figure out the last run date
         $tmptime = $store[$name]['lastRun'];
         if ($tmptime == null) {
             $tmptime = new DateTime("1969-01-01 00:00:00");
         } elseif (is_array($tmptime)) {
             $tmptime = new DateTime($tmptime['date'], new DateTimeZone($tmptime['timezone']));
         } elseif (is_string($tmptime)) {
             $tmptime = new DateTime($tmptime);
         }
         // determine the next run time based on the last
         if (substr($job['interval'], 0, 1) === 'P') {
             $tmptime->add(new DateInterval($job['interval']));
             // "P10DT4H" http://www.php.net/manual/en/class.dateinterval.php
         } else {
             $tmptime->modify($job['interval']);
             // "next day 10:30" http://www.php.net/manual/en/datetime.formats.relative.php
         }
         // is it time to run? has it never been run before?
         if ($tmptime <= $now) {
             $this->hr();
             $this->out("Running {$name}");
             $this->hr();
             if (!isset($this->{$task})) {
                 $this->{$task} = $this->Tasks->load($task);
                 // load models if they aren't already
                 // foreach ($this->$task->uses as $mk => $mv) {
                 // 	if (!isset($this->$task->$mv)) {
                 // 		App::uses('AppModel', 'Model');
                 // 		App::uses($mv, 'Model');
                 // 		$this->$task->$mv = new $mv();
                 // 	}
                 // }
             }
             // grab the entire schedule record incase it was updated..
             $store[$name] = $this->schedule[$name];
             // execute the task and store the result
             $store[$name]['lastResult'] = call_user_func_array(array($this->{$task}, $action), $job['args']);
             // assign it the current time
             $now = new DateTime();
             $store[$name]['lastRun'] = $now->format('Y-m-d H:i:s');
         }
     }
     // write the store back to the file
     file_put_contents($this->storePath . $this->storeFile, json_encode($store));
     // remove processing flag
     $processingFlag->delete();
 }
开发者ID:kajas90,项目名称:cakephp-scheduler,代码行数:91,代码来源:SchedulerShell.php

示例3: realpath

 /**
  * Get the real path (taking ".." and such into account)
  *
  * @param string $path Path to resolve
  * @return string The resolved path
  */
 public function realpath($path)
 {
     if (strpos($path, '..') === false) {
         if (!Folder::isAbsolute($path)) {
             $path = Folder::addPathElement($this->path, $path);
         }
         return $path;
     }
     $path = str_replace('/', DIRECTORY_SEPARATOR, trim($path));
     $parts = explode(DIRECTORY_SEPARATOR, $path);
     $newparts = [];
     $newpath = '';
     if ($path[0] === DIRECTORY_SEPARATOR) {
         $newpath = DIRECTORY_SEPARATOR;
     }
     while (($part = array_shift($parts)) !== null) {
         if ($part === '.' || $part === '') {
             continue;
         }
         if ($part === '..') {
             if (!empty($newparts)) {
                 array_pop($newparts);
                 continue;
             }
             return false;
         }
         $newparts[] = $part;
     }
     $newpath .= implode(DIRECTORY_SEPARATOR, $newparts);
     return Folder::slashTerm($newpath);
 }
开发者ID:tgr0ss,项目名称:cakephp,代码行数:37,代码来源:Folder.php

示例4: testSlashTerm

 /**
  * testStatic method
  *
  * @return void
  */
 public function testSlashTerm()
 {
     $result = Folder::slashTerm('/path/to/file');
     $this->assertEquals('/path/to/file/', $result);
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:10,代码来源:FolderTest.php


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