/** * When called in a subclass of MManagedObject, this method returns the entity description object * that class represents * * This method uses the subclass' name to search the provided MManagedObjectContext for a matching * entity description for the class in which the method is called on. * * @param MManagedObjectContext $context The context in which to perform the search * * @return MEntityDescription The MEntityDescription instance that corresponds to this class */ public static function entityDescription(MManagedObjectContext $context) { return $context->persistentStoreCoordinator()->model()->entityWithName(parent::typeClass()); }
/** * Returns the entity instance for the given name inside the specified context * * This static method searches the specified context for an entity with the given * name and returns it. * * @see MManagedObjectContext * * @static * * @param MString $name The name of the entity you wish to retrieve from the context * @param MManagedObjectContext $context The context to search for the entity * * @return MEntityDescription */ public static function entityWithName(MString $name, MManagedObjectContext $context) { return $context->persistentStoreCoordinator()->model()->entityWithName($name); }