/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { $this->aCategory = null; } if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { $this->aFeature = null; } }
/** * Updates the position and/or geometry of a stage in a road by updating * treasurehunt_stages table. Then, check if road is valid. * * @see treasurehunt_set_valid_road() * @param Feature $feature The feature with the id, position, road and geometry of the stage. * @param stdClass $context The context object. */ function treasurehunt_update_geometry_and_position_of_stage(Feature $feature, $context) { global $DB; $stage = new stdClass(); $stage->position = $feature->getProperty('stageposition'); $stage->roadid = $feature->getProperty('roadid'); $geometry = $feature->getGeometry(); $stage->geom = treasurehunt_geometry_to_wkt($geometry); $stage->timemodified = time(); $stage->id = $feature->getId(); $parms = array('id' => $stage->id); $entry = $DB->get_record('treasurehunt_stages', $parms, 'id,position', MUST_EXIST); // It can not be change the position of stage once the road is blocked. if (treasurehunt_check_road_is_blocked($stage->roadid) && $stage->position != $entry->position) { print_error('notchangeorderstage', 'treasurehunt'); } // It can not be save an existing stage without geometry. if (count($geometry->getComponents()) === 0) { print_error('saveemptyridle', 'treasurehunt'); } $DB->update_record('treasurehunt_stages', $stage); // Check if road is valid. treasurehunt_set_valid_road($stage->roadid); // Trigger update stage event. $eventparams = array('context' => $context, 'objectid' => $stage->id); \mod_treasurehunt\event\stage_updated::create($eventparams)->trigger(); }
/** * @return Feature[] */ public static function getAllFeatures() { global $wpdb; $features = array(); $rows = $wpdb->get_results("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $wpdb->prefix . "squirrels_features\n\t\t\tORDER BY\n\t\t\t\ttitle ASC"); foreach ($rows as $row) { $feature = new Feature(); $feature->loadFromRow($row); $features[$feature->getId()] = $feature; } return $features; }
/** * Declares an association between this object and a Feature object. * * @param Feature $v * @return ActivityHasFeature The current object (for fluent API support) * @throws PropelException */ public function setFeature(Feature $v = null) { if ($v === null) { $this->setFeatureId(NULL); } else { $this->setFeatureId($v->getId()); } $this->aFeature = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Feature object, it will not be re-added. if ($v !== null) { $v->addActivityHasFeature($this); } return $this; }
/** * AJAX action for deleting feature. */ public function deleteFeature() { $feature = new Feature($_REQUEST['id']); $feature->delete(); //Since delete doesn't return anything, this will check for success return $feature->getId() == NULL; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Feature $value A Feature object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Feature $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }