/** * Resolve spec from $this->field * * @param CModelObject $ref_object Ref object * * @return CMbFieldSpec|null */ function resolveSpec(CModelObject $ref_object) { /** @var CMbObject $ref_object */ /** @var string $field */ list($ref_object, $field) = $this->getFieldAndObject($ref_object); $parts = explode("-", $field); $connected_user = CExClassEvent::getConnectedUserSpec(); if (count($parts) == 1) { if ($field == "CONNECTED_USER") { $spec = $connected_user; } else { $spec = $ref_object->_specs[$field]; } } else { $subparts = explode(".", $parts[0]); /** @var CRefSpec $_spec */ if ($subparts[0] == "CONNECTED_USER") { $_spec = $connected_user; } else { $_spec = $ref_object->_specs[$subparts[0]]; } if (count($subparts) > 1) { $class = $subparts[1]; } else { if (!$_spec->class) { return null; } $class = $_spec->class; } $obj = new $class(); if ($parts[1] == "CONNECTED_USER") { $spec = $connected_user; } else { $spec = $obj->_specs[$parts[1]]; } } return $spec; }