how function getGenericObject of Factory class works

Discussion for TimeTrex open source community developers.
Post Reply
joshsard
Posts: 55
Joined: Sun Feb 14, 2016 6:09 pm

how function getGenericObject of Factory class works

Post by joshsard » Tue Feb 23, 2016 7:14 pm

Hi,

I'm in ScheduleFactory.class.php and I've would like to get 'other_id1' and 'other_id2' column values (aka data) of the Branch object/table, and I saw these codes below, inside the function getScheduleArray:

Code: Select all

'default_branch_id' => (int)$s_obj->getColumn('default_branch_id'),
'default_branch' => $s_obj->getColumn('default_branch'),
...
'job_branch_id' => (int)$s_obj->getColumn('job_branch_id'),
...
'branch_id' => (int)$s_obj->getBranch(),
'branch' => $s_obj->getColumn('branch'),
I wondered how to get the remaining values of the Branch object/table (to be shown as additional columns in the schedule table) with the above code but I did not figure it out.
However, I saw a function inside the same ScheduleFactory class called getBranchObject shown below:

Code: Select all

function getBranchObject() {
	return $this->getGenericObject( 'BranchListFactory', $this->getBranch(), 'branch_obj' );
}
which returns the branch object (probably), so I tried something like this:

Code: Select all

$branch_other_id1 = $s_obj->getBranchObject()->getOtherID1();
but there's no value returned inside $branch_other_id1.
Is my code above correct, or am I missing something?

And also does getGenericObject function of Factory class gets the whole object with all column values attached to it, not just its branch_id?
Thanks

joshsard
Posts: 55
Joined: Sun Feb 14, 2016 6:09 pm

Re: how function getGenericObject of Factory class works

Post by joshsard » Sun Feb 28, 2016 6:53 pm

Hi, I have found the solution, the code i showed before actually works, it's just the data having no object that's why there's no value for the getOtherID function. I now have it like below:

Code: Select all

($s_obj->getBranchObject() !== false) ? $s_obj->getBranchObject()->getOtherID1() : ''

Post Reply