コード例 #1
0
ファイル: Transform.php プロジェクト: jasny/Q
 /**
  * Class constructor
  *
  * @param Transform $transform  Transform interface or DSN string
  * @param int       $opt        Output handler options
  */
 public function __construct($transform, $opt = 0)
 {
     if (!$transform instanceof Transform) {
         $transform = Transform::with($this->transform);
     }
     $this->transform = $transform;
     $this->opt = $opt;
     ob_start(array($this, 'callback'));
 }
コード例 #2
0
ファイル: Yaml.php プロジェクト: jasny/Q
 /**
  * Load a config file or dir (no caching)
  * 
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     if ($file_object instanceof Fs_File) {
         return Transform::with('unserialize-yaml')->process($file_object->path());
     } elseif ($file_object instanceof Fs_Dir) {
         return $this->loadDir($file_object);
     }
     return array();
 }
コード例 #3
0
ファイル: Ini.php プロジェクト: jasny/Q
 /**
  * Load a config file or dir
  *
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     if ($file_object instanceof Fs_File) {
         return Transform::with('unserialize-ini')->process($file_object->path());
     } elseif (!empty($this->_options['recursive']) && $file_object instanceof Fs_Dir) {
         return $this->loadDir($file_object);
     }
     return array();
 }
コード例 #4
0
ファイル: Json.php プロジェクト: jasny/Q
 /**
  * Load a config file or dir (no caching)
  *
  * @param Fs_Item $file_object
  * @param string $group
  * @return array
  */
 protected function loadFile($file_object, $group = null)
 {
     $settings = array();
     if ($file_object instanceof Fs_File) {
         $settings = Transform::with('unserialize-json')->process($file_object->path());
         if (!isset($settings)) {
             trigger_error("Failed to parse json file '{$file}'.", E_USER_WARNING);
         }
     } elseif (!empty($this->_options['recursive']) && $file_object instanceof Fs_Dir) {
         $settings = $this->loadDir($file_object);
     }
     return $settings;
 }
コード例 #5
0
ファイル: Dir.php プロジェクト: jasny/Q
 /**
  * Class constructor
  * 
  * @param array $options
  */
 public function __construct($path, $options = array())
 {
     if (is_array($path)) {
         $options = $path + $options;
         $path = null;
         if (isset($options['driver'])) {
             if (isset($options[0])) {
                 if (!isset($options['path'])) {
                     $options['path'] = $options[0];
                 }
                 if (!isset($options['ext'])) {
                     $options['ext'] = $options['driver'];
                 }
                 unset($options[0]);
             } else {
                 $options[0] = $options['driver'];
             }
         }
     }
     if (isset($options[0])) {
         if (strpos($options[0], ':') !== false) {
             list($options['ext'], $options['path']) = explode(':', $options[0], 2);
         } else {
             $key = !isset($options['ext']) && strpos($options[0], '.') === false && strpos($options[0], '/') === false ? 'ext' : 'path';
             if (!isset($options[$key])) {
                 $options[$key] = $options[0];
             }
         }
     }
     $this->_path = isset($path) ? Fs::dir($path) : (isset($options['path']) ? Fs::dir($options['path']) : null);
     if (isset($options['transformer'])) {
         $this->_transformer = $options['transformer'] instanceof Transformer ? $options['transformer'] : Transform::with($options['transformer']);
     }
     $this->_ext = isset($options['ext']) ? $options['ext'] : (isset($this->_transformer) ? $this->_transformer->ext : null);
     if (!isset($this->_transformer) && !empty($this->_ext)) {
         $this->_transformer = Transform::from($this->_ext);
     }
     \ArrayObject::__construct(array(), \ArrayObject::ARRAY_AS_PROPS);
     if (!empty($options['loadall'])) {
         $this->loadAll();
     }
 }
コード例 #6
0
ファイル: CreationTest.php プロジェクト: jasny/Q
 /**
  * Test driver maxlength
  */
 public function testDriverMaxlength()
 {
     $transform = Transform::with('maxlength');
     $this->assertType('Q\\Validator_Maxlength', $transform);
 }