Hello, I've been using PHP in an amateurish way for a little while, never really gotten my head around classes etc, but I wrote one for a basic site. I want to make several instances of a site, and link them all to the same Processwire install.
So I'm loading Processwire like so in index.php:
require('/home/centralsite/public_html/wire/core/ProcessWire.php');
$site = new \ProcessWire\ProcessWire('/home/centralsite/public_html/site/', 'http://example.com');
Works fine
Then I'm loading my class
include "submissions.class.php";
$submissions = new Submissions;
My class does a variety of things
<?php
class Submissions {
private function fields($id=1015) {
// load some cms fields
}
function insert($data) {
// foobar
}
function validate($value,$type) {
// foobar
}
}
These functions (redacted) all work fine but... now lets say I want to use some fields etc from my Processwire install inside my class, how do I do it? Eg, if inside $submissions->insert(), I want to get something from $site->pages() or similar.
I tried putting it as a method at the top of my class, and then loading it with $this->connect(); however, if I try to do that more than once, I get errors for redefining a class. So, I think I need to extend the Processwire class somehow?