/**
  * Handles the `showLinks()` method for fRecordSet
  *
  * @internal
  *
  * @param fRecordSet   $object       The record set
  * @param string|array $class        The class(es) contained in the record set
  * @param array        &$records     The records
  * @param string       $method_name  The method that was called
  * @param array        $parameters   The parameters passed to the method
  * @return boolean  If the links were shown
  */
 public static function showRecordSetLinks($object, $class, &$records, $method_name, $parameters)
 {
     $template = count($parameters) < 1 ? 'default' : $parameters[0];
     $data = count($parameters) < 2 ? array() : $parameters[1];
     $data = self::extendRecordSetInfo($data, $class);
     return self::showTemplatedLinks($template, $data, $object->getPage(), $object->getLimit(), $object->count(TRUE));
 }
 /**
  * Sets the related records for *-to-many relationships
  *
  * @internal
  *
  * @param  string $class             The class to set the related records for
  * @param  array  &$related_records  The related records existing for the fActiveRecord class
  * @param  string $related_class     The class we are associating with the current record
  * @param  fRecordSet $records       The records are associating
  * @param  string $route             The route to use between the current class and the related class
  * @return void
  */
 public static function setRecordSet($class, &$related_records, $related_class, fRecordSet $records, $route = NULL)
 {
     fActiveRecord::validateClass($related_class);
     fActiveRecord::forceConfigure($related_class);
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     $schema = fORMSchema::retrieve($class);
     $route = fORMSchema::getRouteName($schema, $table, $related_table, $route);
     if (!isset($related_records[$related_table])) {
         $related_records[$related_table] = array();
     }
     if (!isset($related_records[$related_table][$route])) {
         $related_records[$related_table][$route] = array();
     }
     $related_records[$related_table][$route]['record_set'] = $records;
     $related_records[$related_table][$route]['count'] = $records->count();
     $related_records[$related_table][$route]['associate'] = FALSE;
     $related_records[$related_table][$route]['primary_keys'] = NULL;
 }
Beispiel #3
0
 /**
  * Sets the related records for *-to-many relationships
  * 
  * @internal
  * 
  * @param  string $class             The class to set the related records for
  * @param  array  &$related_records  The related records existing for the fActiveRecord class
  * @param  string $related_class     The class we are associating with the current record
  * @param  fRecordSet $records       The records are associating
  * @param  string $route             The route to use between the current class and the related class
  * @return void
  */
 public static function setRecordSet($class, &$related_records, $related_class, fRecordSet $records, $route = NULL)
 {
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     try {
         $route = fORMSchema::getRouteName($table, $related_table, $route, '*-to-many');
     } catch (fProgrammerException $e) {
         $route = fORMSchema::getRouteName($table, $related_table, $route, 'one-to-one');
     }
     if (!isset($related_records[$related_table])) {
         $related_records[$related_table] = array();
     }
     if (!isset($related_records[$related_table][$route])) {
         $related_records[$related_table][$route] = array();
     }
     $related_records[$related_table][$route]['record_set'] = $records;
     $related_records[$related_table][$route]['count'] = $records->count();
     $related_records[$related_table][$route]['associate'] = FALSE;
     $related_records[$related_table][$route]['primary_keys'] = NULL;
 }