Welcome Guest, Not a member yet? Register   Sign In
Trouble extending CI library with a spark
#1

[eluser]Unknown[/eluser]
I'm trying to add a few functions to the CI_FTP FTP library by extending it. I'm doing this as part of a spark, but when I load the spark, my extensions don't seem to take.

I created this file in sparks/myspark/0.0.1/libraries/MY_Ftp.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* FTP Library Extensions
*
* Adding some useful functions to the built-in CI FTP library
*
* @package   CodeIgniter
* @subpackage Libraries
* @category  Library
*/

class MY_FTP extends CI_FTP {
public function __construct() {
     parent::__construct();
}

/**
  * Get remote file size
  *
  * @access public
  * @param  string
  * @return integer
  */
function file_size($filepath)
{
  if ( ! $this->_is_conn())
  {
   return FALSE;
  }

  return @ftp_size($this->conn_id, $filepath);
}

/**
  * Get remote file modification time
  *
  * @access public
  * @param  string
  * @return integer (time)
  */
function file_mdtm($filepath)
{
  if ( ! $this->_is_conn())
  {
   return FALSE;
  }

  return @ftp_mdtm($this->conn_id, $filepath);
}

}

But when I load the spark, and load the ftp library, my new methods aren't there:

Code:
$this->load->spark('myspark/0.0.1');
var_dump(method_exists($this->ftp, 'file_size'));
// bool(false)

When I copy MY_Ftp.php into my application/libraries folder instead, everything works as expected.

Can sparks not override/extend CI libraries? Am I doing it wrong?
#2

[eluser]sunset11[/eluser]
I've got the same issue exactly like for timchambers but with helpers.

Building a spark for language, I need to override site_url() which is only possible through
Quote:sparks/myspark/x.x.x/helpers/MY_url_helper.php
.

At running time it's just simply ignored.

If I copy MY_url_helper.php to application/helpers, it works perfectly.

It's not a big deal, but it seems that the CI override mechanism doesn't extend to sparks.

Maybye this will work with sparks integration planned for a next CI version ...






Theme © iAndrew 2016 - Forum software by © MyBB