/** * Set state * * @param mixed $state State object or state id or custom state name * * @return void * @todo Refactor? */ public function setState($state) { if ($state instanceof \XLite\Model\State) { // Set by state object if ($state->getStateId()) { if (!$this->state || $this->state->getStateId() != $state->getStateId()) { $this->state = $state; } $this->setCustomState($this->state->getState()); } else { $this->state = null; $this->setCustomState($state->getState()); } } elseif (is_string($state)) { // Set custom state $this->state = null; $this->setCustomState($state); } }
/** * {@inheritDoc} */ public function getStateId() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getStateId', array()); return parent::getStateId(); }
/** * Check - specified state is selected or not * * @param \XLite\Model\State $state Specidied (current) state * * @return boolean */ public function isStateSelected(\XLite\Model\State $state) { return $state->getStateId() == $this->getParam(self::PARAM_STATE)->getStateId(); }