| @@ 83-106 (lines=24) @@ | ||
| 80 | /** |
|
| 81 | * Возвращает модель по ID с использованием IdentityMap |
|
| 82 | */ |
|
| 83 | public static function findById($id) |
|
| 84 | { |
|
| 85 | if (!isset(static::$identity_map[$id])) { |
|
| 86 | static::$identity_map[$id] = Yii::$app->cache->get('PropertyHandler: ' . $id); |
|
| 87 | if (static::$identity_map[$id] === false) { |
|
| 88 | static::$identity_map[$id] = PropertyHandler::findOne($id); |
|
| 89 | if (static::$identity_map[$id] !== null) { |
|
| 90 | Yii::$app->cache->set( |
|
| 91 | 'PropertyHandler: ' . $id, |
|
| 92 | static::$identity_map[$id], |
|
| 93 | 86400, |
|
| 94 | new TagDependency( |
|
| 95 | [ |
|
| 96 | 'tags' => [ |
|
| 97 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag(static::className(), $id), |
|
| 98 | ], |
|
| 99 | ] |
|
| 100 | ) |
|
| 101 | ); |
|
| 102 | } |
|
| 103 | } |
|
| 104 | } |
|
| 105 | return static::$identity_map[$id]; |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Возвращает список всех объектов |
|
| @@ 103-126 (lines=24) @@ | ||
| 100 | * @param integer $id |
|
| 101 | * @return Currency |
|
| 102 | */ |
|
| 103 | public static function findById($id) |
|
| 104 | { |
|
| 105 | if (!isset(static::$identity_map[$id])) { |
|
| 106 | static::$identity_map[$id] = Yii::$app->cache->get('Currency: ' . $id); |
|
| 107 | if (static::$identity_map[$id] === false) { |
|
| 108 | static::$identity_map[$id] = Currency::findOne($id); |
|
| 109 | if (is_object(static::$identity_map[$id])) { |
|
| 110 | Yii::$app->cache->set( |
|
| 111 | 'Currency: ' . $id, |
|
| 112 | static::$identity_map[$id], |
|
| 113 | 86400, |
|
| 114 | new TagDependency( |
|
| 115 | [ |
|
| 116 | 'tags' => [ |
|
| 117 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag(Currency::className(), $id), |
|
| 118 | ], |
|
| 119 | ] |
|
| 120 | ) |
|
| 121 | ); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | } |
|
| 125 | return static::$identity_map[$id]; |
|
| 126 | } |
|
| 127 | ||
| 128 | ||
| 129 | /** |
|