public function testScan()
 {
     $content = 'test';
     $path = __DIR__ . '/test/';
     $filePath = $path . 'test.txt';
     $this->manager->write($filePath, $content);
     $this->assertEquals($filePath, $this->manager->scan([$path], ['txt'], [__DIR__ . '/folder/'])[0]);
 }
Пример #2
0
 /**
  * Writes schema file from object or options.
  *
  * @param array|object $object Schema object or options array.
  * @param array $options Schema object properties to override object.
  * @return mixed False or string written to file.
  */
 public function write($object, $options = array())
 {
     if (is_object($object)) {
         $object = get_object_vars($object);
         $this->build($object);
     }
     if (is_array($object)) {
         $options = $object;
         unset($object);
     }
     extract(array_merge(get_object_vars($this), $options));
     $out = "class {$name}Schema extends CakeSchema {\n\n";
     if ($path !== $this->path) {
         $out .= "\tpublic \$path = '{$path}';\n\n";
     }
     if ($file !== $this->file) {
         $out .= "\tpublic \$file = '{$file}';\n\n";
     }
     if ($connection !== 'default') {
         $out .= "\tpublic \$connection = '{$connection}';\n\n";
     }
     $out .= "\tpublic function before(\$event = array()) {\n\t\treturn true;\n\t}\n\n\tpublic function after(\$event = array()) {\n\t}\n\n";
     if (empty($tables)) {
         $this->read();
     }
     foreach ($tables as $table => $fields) {
         if (!is_numeric($table) && $table !== 'missing') {
             $out .= $this->generateTable($table, $fields);
         }
     }
     $out .= "}\n";
     $file = new FileManager($path . DS . $file, true);
     $content = "<?php \n{$out}";
     if ($file->write($content)) {
         return $content;
     }
     return false;
 }
Пример #3
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//include whois class
include __DIR__ . '\\src\\FileManager.php';
$fileManager = new \FileManager();
$path = '/home/username/somedir/file.txt';
// or
// $path = 'C:\hello\test.txt';
$content = 'blablabla';
$result = $fileManager->write($path, $content);
var_dump($result);