/** * This cleanup method is called after loading and getting the current value * in order to avoid crashes when some components of the setting disappeared in the meantime. * * @return integer number of changes made during cleanup : if 0, then cleanup was not necessary */ public function cleanup() { $changes_count = 0; $class_name = $this->getClassName(); foreach ($this->classes as $key => $class) { if ($class->property_path && !Reflection_Property::exists($class_name, join(DOT, $class->property_path))) { unset($this->classes[$key]); $changes_count++; } else { $changes_count += $class->cleanup(); } } return $changes_count; }
/** * Cleanup outdated properties from the list setting * * @return integer number of changes made during cleanup : if 0, then cleanup was not necessary */ public function cleanup() { $changes_count = 0; // properties path foreach ($this->properties_path as $key => $property_path) { if (!Reflection_Property::exists($this->class_name, $property_path)) { unset($this->properties_path[$key]); $changes_count++; } } if ($changes_count) { $this->properties_path = array_values($this->properties_path); } // search foreach (array_keys($this->search) as $property_path) { if (!Reflection_Property::exists($this->class_name, $property_path)) { unset($this->search[$property_path]); $changes_count++; } } // sort if ($this->sort) { foreach ($this->sort->columns as $key => $property_path) { if (!Reflection_Property::exists($this->class_name, $property_path)) { unset($this->sort->columns[$key]); $changes_count++; } } } return $changes_count; }