[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?