/** * Constructor. * * @param string $name The name of the relation * @param int $flags Flags for the relation. * @param string $link The full name of the node that is used as * intermediairy node. The intermediairy node is * assumed to have 2 attributes that are named * after the nodes at both ends of the relation. * For example, if node 'project' has a M2M relation * with 'activity', then the intermediairy node * 'project_activity' is assumed to have an attribute * named 'project' and one that is named 'activity'. * You can set your own keys by calling setLocalKey() * and setRemoteKey() * @param string $destination The full name of the node that is the other * end of the relation. * @param string $local_key field for localKey * @param string $remote_key field for remoteKey */ public function __construct($name, $flags = 0, $link, $destination, $local_key = null, $remote_key = null) { $flags = $flags | self::AF_CASCADE_DELETE | self::AF_NO_SORT; $this->m_link = $link; parent::__construct($name, $flags, $destination); if ($local_key != null) { $this->setLocalKey($local_key); } if ($remote_key != null) { $this->setRemoteKey($remote_key); } }
/** * Default Constructor. * * The atkOneToOneRelation supports two configurations: * - Master mode: The current node is considered the master, and the * referential key pointing to the master record is in the * destination node. * - Slave mode: The current node is considered the child, and the * referential key pointing to the master record is in the * current node. * The mode to use is detected automatically based on the value of the * $refKey parameter. * * <b>Example:</b> * <code> * $this->add(new atkOneToOneRelation("child", "mymod.childnode", "parent_id")); * </code> * * @param string $name The unique name of the attribute. In slave mode, * this corresponds to the foreign key field in the * database table. (The name is also used as the section * heading.) * @param int $flags Attribute flags that influence this attributes' behavior. * @param string $destination the destination node (in module.nodename * notation) * @param string $refKey In master mode, this specifies the foreign key * field from the destination node that points to * the master record. In slave mode, this parameter * should be empty. */ public function __construct($name, $flags = 0, $destination, $refKey = '') { $flags = $flags | self::AF_ONETOONE_LAZY; parent::__construct($name, $flags, $destination); $this->m_refKey = $refKey; }
/** * Default constructor. * * <b>Example: </b> Suppose a department has many employees. To edit the * list of employees in a department, this relationship can be built like * this, in the department node: * <code> * $this->add(new atkOneToManyRelation("employees", "mymod.employee", "department_id")); * </code> * * @param string $name The unique name of this relation within a node. * In contrast with most other attributes, the name * does not correspond to a database field. (Because * in one2many relations, the databasefield that * stores the link, is in the destination node and not * in the owner node). * @param int $flags Attribute flags that influence this attributes' behavior. * @param string $destination The node to which the relationship is made * (in module.nodename notation). * @param string|array $refKey For regular oneToMany relationships, $refKey is * name of the referential key in the destination * node. In the case of multi-foreign key * relationships, $refKey can be an array of fields. */ public function __construct($name, $flags = 0, $destination, $refKey = '') { $flags = $flags | self::AF_NO_SORT | self::AF_HIDE_ADD; parent::__construct($name, $flags, $destination); if (is_array($refKey)) { $this->m_refKey = $refKey; } else { if (empty($refKey)) { $this->m_refKey = []; } else { $this->m_refKey[] = $refKey; } } $this->setGridExcludes($this->m_refKey); }
/** * Constructor. * * @param string $name The name of the attribute. This is the name of the field that is the referential key to the destination. * For relations with more than one field in the foreign key, you should pass an array of referential key fields. * The order of the fields must match the order of the primary key attributes in the destination node. * @param int $flags Flags for the relation * * @param string $destination The node we have a relationship with. * */ public function __construct($name, $flags = 0, $destination) { if (Config::getGlobal('manytoone_autocomplete_default', false)) { $flags |= self::AF_RELATION_AUTOCOMPLETE; } if (Config::getGlobal('manytoone_autocomplete_large', true) && Tools::hasFlag($flags, self::AF_LARGE)) { $flags |= self::AF_RELATION_AUTOCOMPLETE; } $this->m_autocomplete_minchars = Config::getGlobal('manytoone_autocomplete_minchars', 2); $this->m_autocomplete_searchmode = Config::getGlobal('manytoone_autocomplete_searchmode', 'contains'); $this->m_autocomplete_search_case_sensitive = Config::getGlobal('manytoone_autocomplete_search_case_sensitive', false); $this->m_autocomplete_size = Config::getGlobal('manytoone_autocomplete_size', 50); $this->m_autocomplete_minrecords = Config::getGlobal('manytoone_autocomplete_minrecords', -1); $this->m_autocomplete_pagination_limit = Config::getGlobal('manytoone_autocomplete_pagination_limit', 25); if (is_array($name)) { $this->m_refKey = $name; // ATK can't handle an array as name, so we initialize the // underlying attribute with the first name of the referential // keys. // Languagefiles, overrides, etc should use this first name to // override the relation. parent::__construct($name[0], $flags, $destination); } else { $this->m_refKey[] = $name; parent::__construct($name, $flags, $destination); } if ($this->hasFlag(self::AF_MANYTOONE_LAZY) && (count($this->m_refKey) > 1 || $this->m_refKey[0] != $this->fieldName())) { Tools::atkerror('self::AF_MANYTOONE_LAZY flag is not supported for multi-column reference key or a reference key that uses another column.'); } }