/** * Processes some extra objective calls: cloning and creating * new objects. * * @param string $action The action: 'new' or 'clone' * @param mixed $what The action argument * @param int $weight The action weight * @return SplFixedArray */ public function _objective($action, $what, $weight) { if (!$this->_tpl->allowObjects || !$this->_tpl->allowObjectCreation) { throw new Opt_NotSupported_Exception('object creation', 'disabled by the configuration'); } switch ($action) { case 'clone': $answer = $what; $answer[0] = 'clone ' . $answer[0]; $answer[1] += $weight; $answer[3] = 0; break; case 'new': if (($compiled = $this->_compiler->isClass($what[0])) === null) { throw new Opt_ItemNotAllowed_Exception('Class', $what[0]); } $answer = new SplFixedArray(4); $answer[0] = 'new ' . $compiled; $answer[1] = $weight; $answer[3] = 0; // Process the constructor arguments if (sizeof($what[1]) > 0) { $answer[0] .= '('; $first = true; foreach ($what[1] as $item) { if (!$first) { $answer[0] .= ','; } else { $first = false; } $answer[0] .= $item[0]; $answer[1] += $item[1]; } $answer[0] .= ')'; } } return $answer; }