/** * Pops the form from a stack. If the stack is empty, the method * throws an exception. * * @internal * @static * @param Opf_Form $form The form to be popped. * @return Opf_Form */ public static function popFromStack(Opf_Form $form) { if (self::$_stack === null) { self::$_stack = new SplStack(); } $element = self::$_stack->pop(); if ($element !== $form) { throw new Opf_Exception('Invalid form ' . $form->getName() . ' on stack ' . $element->getName()); } return $element; }
/** * Adds a form to the list of forms to make it available for the * templates. You do not have to use this method manually, as the * forms register themselves in templates automatically. * * @static * @param Opf_Form $form The form to register. * @throws Opf_ItemAlreadyExists_Exception */ public static function addForm(Opf_Form $form) { if (isset(self::$_forms[$form->getName()])) { throw new Opf_Exception('Form ' . $form->getName() . ' already exist.'); } self::$_forms[$form->getName()] = $form; }