public function action_entity($entity) { if (Kohana::config('glue')->debug) { $this->request->response = View::factory('glue_template')->set('title', ucfirst($entity) . ' entity')->set('content', glue::entity($entity)->debug()); } else { $this->request->status = 404; } }
public function __construct($entity_name, &$set) { $entity = glue::entity($entity_name); $this->root = new Glue_Command_Load($entity); $set = $this->create_set($entity, $this->root); // Switch active command to current command : $this->active_command = $this->root; }
protected function default_type() { // Guess src and trg cardinality from pk : $src_multiple = false; $trg_multiple = false; foreach ($this->joins as $trg_entity => $arr1) { foreach ($arr1 as $src_entity => $arr2) { // Check trg cardinality : if (!$trg_multiple) { $fields = array_keys($arr2); $pk = glue::entity($trg_entity)->pk(); if (count($pk) !== count($fields) || count(array_diff($fields, $pk)) !== 0) { $trg_multiple = true; } } // Check src cardinality : if (!$src_multiple) { $fields = array_values($arr2); $pk = glue::entity($src_entity)->pk(); if (count($pk) !== count($fields) || count(array_diff($fields, $pk)) !== 0) { $src_multiple = true; } } } } // Compute relationship type : if ($src_multiple) { if ($trg_multiple) { $type = self::MANY_TO_MANY; } else { $type = self::MANY_TO_ONE; } } else { if ($trg_multiple) { $type = self::ONE_TO_MANY; } else { $type = self::ONE_TO_ONE; } } return $type; }
public static function auto_load($class) { if (preg_match("/^Glue_Proxy_(.*)\$/", $class, $matches) > 0) { glue::entity($matches[1])->proxy_load_class(); } }