/** * Create a new ManyManyRelationList object. This relation will utilise an intermediary dataobject * as a join table, unlike ManyManyList which scaffolds a table automatically. * * @param string $dataClass The class of the DataObjects that this will list. * @param string $joinClass Class name of the joined dataobject record * @param string $localKey The key in the join table that maps to the dataClass' PK. * @param string $foreignKey The key in the join table that maps to joined class' PK. * * @example new ManyManyThroughList('Banner', 'PageBanner', 'BannerID', 'PageID'); */ public function __construct($dataClass, $joinClass, $localKey, $foreignKey) { parent::__construct($dataClass); // Inject manipulator $this->manipulator = ManyManyThroughQueryManipulator::create($joinClass, $localKey, $foreignKey); $this->dataQuery->pushQueryManipulator($this->manipulator); }
/** * Create a new ManyManyList object. * * A ManyManyList object represents a list of {@link DataObject} records * that correspond to a many-many relationship. * * Generation of the appropriate record set is left up to the caller, using * the normal {@link DataList} methods. Addition arguments are used to * support {@@link add()} and {@link remove()} methods. * * @param string $dataClass The class of the DataObjects that this will list. * @param string $joinTable The name of the table whose entries define the content of this many_many relation. * @param string $localKey The key in the join table that maps to the dataClass' PK. * @param string $foreignKey The key in the join table that maps to joined class' PK. * @param array $extraFields A map of field => fieldtype of extra fields on the join table. * * @example new ManyManyList('Group','Group_Members', 'GroupID', 'MemberID'); */ public function __construct($dataClass, $joinTable, $localKey, $foreignKey, $extraFields = array()) { parent::__construct($dataClass); $this->joinTable = $joinTable; $this->localKey = $localKey; $this->foreignKey = $foreignKey; $this->extraFields = $extraFields; $this->linkJoinTable(); }
/** * Create a new HasManyList object. * Generation of the appropriate record set is left up to the caller, using the normal * {@link DataList} methods. Addition arguments are used to support {@@link add()} * and {@link remove()} methods. * * @param string $dataClass The class of the DataObjects that this will list. * @param string $foreignKey The name of the foreign key field to set the ID filter against. */ public function __construct($dataClass, $foreignKey) { parent::__construct($dataClass); $this->foreignKey = $foreignKey; }