Ejemplo n.º 1
0
 /**
  * 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'));
 }
Ejemplo n.º 2
0
Archivo: Yaml.php Proyecto: 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();
 }
Ejemplo n.º 3
0
Archivo: Ini.php Proyecto: 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();
 }
Ejemplo n.º 4
0
Archivo: Json.php Proyecto: 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;
 }
Ejemplo n.º 5
0
Archivo: Dir.php Proyecto: 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();
     }
 }
Ejemplo n.º 6
0
 /**
  * Test driver maxlength
  */
 public function testDriverMaxlength()
 {
     $transform = Transform::with('maxlength');
     $this->assertType('Q\\Validator_Maxlength', $transform);
 }