private function prepareConstructor()
    {
        $table_descriptor = $this->getStorageDescriptor();

        $fragment = new CNabuPHPConstructorBuilder($this);
        $fragment->addComment(
                "Instantiates the class. If you fill enough parameters to identify an instance "
              . "serialized in the storage, then the instance is deserialized from the storage.");
        if ($table_descriptor->hasPrimaryConstraint()) {
            foreach ($table_descriptor->getPrimaryConstraintFieldNames() as $field_name) {
                if (nb_strEndsWith($field_name, '_id')) {
                    $var_name = substr($field_name, 0, strlen($field_name) - 3);
                } else {
                    $var_name = $field_name;
                }
                $fragment->addParam(
                        $var_name, null, true, false, 'mixed',
                        "An instance of $this->class_name or another object descending from "
                      . "\\nabu\\data\\CNabuDataObject which contains a field named $field_name,"
                      . " or a valid ID.");
                $fragment->addFragment(
                        array(
                            "if (\$$var_name) {",
                            "    \$this->transferMixedValue(\$$var_name, '$field_name');",
                            "}",
                            ''
                        )
                );
            }
        }
        $fragment->addFragment('parent::__construct();');

        if ($this->is_translated) {
            $list_name = preg_replace('/Base$/', 'LanguageList', $this->class_name);
            $list_ns = preg_replace('/\\\\base/', '', $this->class_namespace);
            $fragment->addFragment('$this->__translatedConstruct();');
            $fragment->addFragment("\$this->translations_list = new $list_name();");
            $this->getDocument()->addUse("\\$list_ns\\$list_name");
        }

        $this->addFragment($fragment);
    }
private function prepareConstructor()
    {
        $table_descriptor = $this->getStorageDescriptor();

        $fragment = new CNabuPHPConstructorBuilder($this);
        $fragment->addComment(
                "Instantiates the class. If you fill enough parameters to identify an instance "
              . "serialized in the storage, then the instance is deserialized from the storage.");
        if ($table_descriptor->hasPrimaryConstraint()) {
            foreach ($table_descriptor->getPrimaryConstraintFieldNames() as $field_name) {
                if (nb_strEndsWith($field_name, '_id')) {
                    $var_name = substr($field_name, 0, strlen($field_name) - 3);
                } else {
                    $var_name = $field_name;
                }
                $fragment->addParam(
                        $var_name, null, true, false, 'mixed',
                        "An instance of $this->class_name or another object descending from "
                      . "\\nabu\\data\\CNabuDataObject which contains a field named $field_name,"
                      . " or a valid ID.");
                $fragment->addFragment(
                        array(
                            "if (\$$var_name) {",
                            "    \$this->transferMixedValue(\$$var_name, '$field_name');",
                            "}",
                            ''
                        )
                );
            }
        }
        $fragment->addFragment('parent::__construct();');

        if ($this->is_translated) {
            $list_name = preg_replace('/Base$/', 'LanguageList', $this->class_name);
            $list_ns = preg_replace('/\\\\base/', '', $this->class_namespace);
            $fragment->addFragment('$this->__translatedConstruct();');
            $fragment->addFragment("\$this->translations_list = new $list_name();");
            $this->getDocument()->addUse("\\$list_ns\\$list_name");
        }

        $this->addFragment($fragment);
    }
private function prepareConstructor ( ) { $ table_descriptor = $ this -> getStorageDescriptor ( ) ; $ fragment = new CNabuPHPConstructorBuilder ( $ this ) ; $ fragment -> addComment ( "Instantiates the class. If you fill enough parameters to identify an instance " . "serialized in the storage, then the instance is deserialized from the storage." ) ; if ( $ table_descriptor -> hasPrimaryConstraint ( ) ) { foreach ( $ table_descriptor -> getPrimaryConstraintFieldNames ( ) as $ field_name ) { if ( nb_strEndsWith ( $ field_name , '_id' ) ) { $ var_name = substr ( $ field_name , 0 , strlen ( $ field_name ) - 3 ) ; } else { $ var_name = $ field_name ; } $ fragment -> addParam ( $ var_name , null , true , false , 'mixed' , "An instance of $this->class_name or another object descending from " . "\\nabu\\data\\CNabuDataObject which contains a field named $field_name," . " or a valid ID." ) ; $ fragment -> addFragment ( array ( "if (\$$var_name) {" , "    \$this->transferMixedValue(\$$var_name, '$field_name');" , "}" , '' ) ) ; } } $ fragment -> addFragment ( 'parent::__construct();' ) ; if ( $ this -> is_translated ) { $ list_name = preg_replace ( '/Base$/' , 'LanguageList' , $ this -> class_name ) ; $ list_ns = preg_replace ( '/\\\\base/' , '' , $ this -> class_namespace ) ; $ fragment -> addFragment ( '$this->__translatedConstruct();' ) ; $ fragment -> addFragment ( "\$this->translations_list = new $list_name();" ) ; $ this -> getDocument ( ) -> addUse ( "\\$list_ns\\$list_name" ) ; } $ this -> addFragment ( $ fragment ) ; }
Prepares the constructor of class
Prepares the constructor of class