Example #1
0
 public function getJSColModelElement()
 {
     $colModel = new base_js_ColModelElement();
     $colModel->setName($this->fi->getFieldName())
         ->setIndex($this->fi->getFieldName())
         ->setWidth($this->fi->getDisplayedLength())
         ->setClasses($this->fi->getFieldName())
         ->setEditableTrue();
     return $colModel;
 }
Example #2
0
    private function _saveMNField(Fieldinfo $fi)
    {
        if (empty($this->_fields[$fi->getFieldName()])) {
            return;
        }
        /** @var BaseConnectionObject[] $connObjects */
        $connObjects = $this->_fields[$fi->getFieldName()];
        $objClass = get_class($this);
        $connClass = $fi->getConnectedClass();
        /** @var BaseConnectionObject $connection */
        $connection = new $connClass();
        $otherClass = $connection->getOtherClass($objClass);
        $existingConnObjs = $connection->find($this->getLogicalKey(), $objClass);

        if (empty($connObjects) && empty($existingConnObjs)) {
            return;
        }

        if (empty($connObjects)) {
            $this->_deleteConnObjs($existingConnObjs);
        }

        $savedLKList = [];
        $actualLKList = [];

        foreach ($existingConnObjs as $obj) {
            $savedLKList[$obj->getLKForClass($otherClass)] = $obj;
        }

        foreach ($connObjects as $connObj) {
            $lk = $connObj->getLKForClass($otherClass);
            if (in_array($lk, array_keys($savedLKList))) {
                $actualLKList[] = $lk;
                continue;
            }
            $connObj->setLKForClass($objClass, $this->getLogicalKey());
            $connObj->save();
        }

        $diff = array_diff(array_keys($savedLKList), $actualLKList);
        foreach ($diff as $otherLK) {
            /** @var BaseConnectionObject $connObj */
            $connObj = $savedLKList[$otherLK];
            $connObj->delete();
        }
    }
Example #3
0
 public function setFieldinfo(Fieldinfo $fi)
 {
     $this->cache[$fi->getClass()][$fi->getFieldName()] = $fi;
 }