/** * Creates a collection definition * @param string $name the name of the collection * @param ActiveRecord $model the model * * @return array the definition config */ protected function createCollectionDefinition($name, ActiveRecord $model) { return array('properties' => array('total' => array('location' => 'json', 'type' => 'integer'), 'totalPages' => array('location' => 'json', 'type' => 'integer'), 'params' => array('location' => 'json', 'type' => 'object', 'properties' => array('q' => array('location' => 'json', 'type' => 'string'), '_embed' => array('location' => 'json', 'type' => 'string'))), '_embedded' => array('location' => 'json', 'type' => 'object', 'properties' => array($model->controllerID() => array('location' => 'json', 'type' => 'array', 'items' => array('location' => 'json', 'type' => 'object', 'instanceOf' => get_class($model))))), '_links' => array('location' => 'json', 'type' => 'object'))); }
/** * Generates the cache key for an active record * @param ActiveRecord $input the data to generate the key for * @param array $qualifiers the qualifiers that differentiate the item * * @return string the cache key */ protected function createActiveRecordKey(ActiveRecord $input, $qualifiers = array()) { $prepend = $input->controllerID() . ':'; $append = $input->getDbCriteria()->toArray(); return $this->calculateKey($prepend, array($append, $qualifiers)); }