lib/Skeleton/I18n/Object/Text.php
public static function get_by_object_label_language($object, $label, \Skeleton\I18n\LanguageInterface $language, $auto_create = true) {
		$class_parents = class_parents($object);
		if ($class_parents === false OR count($class_parents) == 0) {
			$class = get_class($object);
		} else {
			$class = array_pop($class_parents);
		}

		if (self::trait_cache_enabled()) {
			try {
                $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
				$object = self::cache_get($key);
				return $object;
			} catch (\Exception $e) {}
        }

        $db = Database::Get();
		$data = $db->get_row('SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?', [ $class, $object->id, $label, $language->id ]);

		if ($data === null) {
		    if (!$auto_create) {
			    throw new \Exception('Object text does not exists');
			} else {
				$requested = new self();
                $requested->object = $object;
				$requested->language_id = $language->id;
				$requested->label = $label;
				$requested->content = '';
				$requested->save();

				if (self::trait_cache_enabled()) {
                    $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
                    self::cache_set($key, $requested);
                }

                return $requested;
			}
		}

		$object_text = new self();
		$object_text->id = $data['id'];
		$object_text->details = $data;

		if (self::trait_cache_enabled()) {
            $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
            self::cache_set($key, $object_text);
        }

		return $object_text;
	}
public static function get_by_object_label_language($object, $label, \Skeleton\I18n\LanguageInterface $language, $auto_create = true) {
		$class_parents = class_parents($object);
		if ($class_parents === false OR count($class_parents) == 0) {
			$class = get_class($object);
		} else {
			$class = array_pop($class_parents);
		}

		if (self::trait_cache_enabled()) {
			try {
                $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
				$object = self::cache_get($key);
				return $object;
			} catch (\Exception $e) {}
        }

        $db = Database::Get();
		$data = $db->get_row('SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?', [ $class, $object->id, $label, $language->id ]);

		if ($data === null) {
		    if (!$auto_create) {
			    throw new \Exception('Object text does not exists');
			} else {
				$requested = new self();
                $requested->object = $object;
				$requested->language_id = $language->id;
				$requested->label = $label;
				$requested->content = '';
				$requested->save();

				if (self::trait_cache_enabled()) {
                    $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
                    self::cache_set($key, $requested);
                }

                return $requested;
			}
		}

		$object_text = new self();
		$object_text->id = $data['id'];
		$object_text->details = $data;

		if (self::trait_cache_enabled()) {
            $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
            self::cache_set($key, $object_text);
        }

		return $object_text;
	}
public static function get_by_object_label_language ( $ object , $ label , \ Skeleton \ I18n \ LanguageInterface $ language , $ auto_create = true ) { $ class_parents = class_parents ( $ object ) ; if ( $ class_parents === false OR count ( $ class_parents ) == 0 ) { $ class = get_class ( $ object ) ; } else { $ class = array_pop ( $ class_parents ) ; } if ( self :: trait_cache_enabled ( ) ) { try { $ key = $ class . '_' . $ object -> id . '_' . $ label . '_' . $ language -> name_short ; $ object = self :: cache_get ( $ key ) ; return $ object ; } catch ( \ Exception $ e ) { } } $ db = Database :: Get ( ) ; $ data = $ db -> get_row ( 'SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?' , [ $ class , $ object -> id , $ label , $ language -> id ] ) ; if ( $ data === null ) { if ( ! $ auto_create ) { throw new \ Exception ( 'Object text does not exists' ) ; } else { $ requested = new self ( ) ; $ requested -> object = $ object ; $ requested -> language_id = $ language -> id ; $ requested -> label = $ label ; $ requested -> content = '' ; $ requested -> save ( ) ; if ( self :: trait_cache_enabled ( ) ) { $ key = $ class . '_' . $ object -> id . '_' . $ label . '_' . $ language -> name_short ; self :: cache_set ( $ key , $ requested ) ; } return $ requested ; } } $ object_text = new self ( ) ; $ object_text -> id = $ data [ 'id' ] ; $ object_text -> details = $ data ; if ( self :: trait_cache_enabled ( ) ) { $ key = $ class . '_' . $ object -> id . '_' . $ label . '_' . $ language -> name_short ; self :: cache_set ( $ key , $ object_text ) ; } return $ object_text ; }
Get by object, label, language

@access public
@param mixed $object
@param string $label
@param Language $language
Get by object label language