Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent PHP Error on $this->load->spark(array('spark1', 'spark2')); #15

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 49 additions & 46 deletions application/core/MY_Loader.php
Expand Up @@ -94,53 +94,56 @@ function spark($spark, $autoload = array())
$this->spark($s); $this->spark($s);
} }
} }

else
$spark = ltrim($spark, '/');
$spark = rtrim($spark, '/');

$spark_path = SPARKPATH . $spark . '/';
$parts = explode('/', $spark);
$spark_slug = strtolower($parts[0]);

# If we've already loaded this spark, bail
if(array_key_exists($spark_slug, $this->_ci_loaded_sparks))
{
return true;
}

# Check that it exists. CI Doesn't check package existence by itself
if(!file_exists($spark_path))
{
show_error("Cannot find spark path at $spark_path");
}

if(count($parts) == 2)
{
$this->_ci_loaded_sparks[$spark_slug] = $spark;
}

$this->add_package_path($spark_path);

foreach($autoload as $type => $read)
{ {
if($type == 'library')
$this->library($read); $spark = ltrim($spark, '/');
elseif($type == 'model') $spark = rtrim($spark, '/');
$this->model($read);
elseif($type == 'config') $spark_path = SPARKPATH . $spark . '/';
$this->config($read); $parts = explode('/', $spark);
elseif($type == 'helper') $spark_slug = strtolower($parts[0]);
$this->helper($read);
elseif($type == 'view') # If we've already loaded this spark, bail
$this->view($read); if(array_key_exists($spark_slug, $this->_ci_loaded_sparks))
else {
show_error ("Could not autoload object of type '$type' ($read) for spark $spark"); return true;
} }


// Looks for a spark's specific autoloader # Check that it exists. CI Doesn't check package existence by itself
$this->ci_autoloader($spark_path); if(!file_exists($spark_path))

{
return true; show_error("Cannot find spark path at $spark_path");
}

if(count($parts) == 2)
{
$this->_ci_loaded_sparks[$spark_slug] = $spark;
}

$this->add_package_path($spark_path);

foreach($autoload as $type => $read)
{
if($type == 'library')
$this->library($read);
elseif($type == 'model')
$this->model($read);
elseif($type == 'config')
$this->config($read);
elseif($type == 'helper')
$this->helper($read);
elseif($type == 'view')
$this->view($read);
else
show_error ("Could not autoload object of type '$type' ($read) for spark $spark");
}

// Looks for a spark's specific autoloader
$this->ci_autoloader($spark_path);

return true;
}
} }


/** /**
Expand Down