<?php defined('BASEPATH') OR exit('No direct script access allowed');

require_once APPPATH . 'processors/Base_processor.php';

class Parent_processor extends Base_processor
{
	protected $children = array();

	public function addChild($processor)
	{
		$this->children[] = $processor;
	}

	public function init_save(&$postData)
	{
		// $this->init_save($postData);

		foreach($this->children as $child)
		{
			$child->init_save($postData);
		}

		parent::init_save($postData);
	}

	public function pre_save(&$postData)
	{
		foreach($this->children as $child)
		{
			$child->pre_save($postData);
		}

		parent::pre_save($postData);
	}

	public function post_save(&$postData, &$result)
	{
		// $this->on_after_save($postData, $result);

		foreach($this->children as $child)
		{
			$child->post_save($postData, $result);
		}

		parent::post_save($postData, $result);
	}

	public function post_commit(&$postData, &$result)
	{
		foreach($this->children as $child)
		{
			$child->post_commit($postData, $result);
		}

		parent::post_commit($postData, $result);
	}
}
