| @@ 149-173 (lines=25) @@ | ||
| 146 | * @param integer $id ID of record |
|
| 147 | * @return BackendMenu BackendMenu instance |
|
| 148 | */ |
|
| 149 | public static function findById($id) |
|
| 150 | { |
|
| 151 | if (!isset(static::$identity_map[$id])) { |
|
| 152 | $cacheKey = static::tableName().":$id"; |
|
| 153 | if (false === $model = Yii::$app->cache->get($cacheKey)) { |
|
| 154 | $model = static::find()->where(['id' => $id]); |
|
| 155 | ||
| 156 | if (null !== $model = $model->one()) { |
|
| 157 | Yii::$app->cache->set( |
|
| 158 | $cacheKey, |
|
| 159 | $model, |
|
| 160 | 86400, |
|
| 161 | new TagDependency([ |
|
| 162 | 'tags' => [ |
|
| 163 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(static::className()) |
|
| 164 | ] |
|
| 165 | ]) |
|
| 166 | ); |
|
| 167 | } |
|
| 168 | } |
|
| 169 | static::$identity_map[$id] = $model; |
|
| 170 | } |
|
| 171 | ||
| 172 | return static::$identity_map[$id]; |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Returns all available to logged user BackendMenu items in yii\widgets\Menu acceptable format |
|
| @@ 136-163 (lines=28) @@ | ||
| 133 | * @param int $id |
|
| 134 | * @return null|PropertyStaticValues |
|
| 135 | */ |
|
| 136 | public static function findById($id) |
|
| 137 | { |
|
| 138 | if (!isset(static::$identity_map[$id])) { |
|
| 139 | $cacheKey = "PropertyStaticValue:$id"; |
|
| 140 | ||
| 141 | if (false === $property = Yii::$app->cache->get($cacheKey)) { |
|
| 142 | if (null !== $property = static::find()->where(['id' => $id])->asArray()->one()) { |
|
| 143 | Yii::$app->cache->set( |
|
| 144 | $cacheKey, |
|
| 145 | $property, |
|
| 146 | 0, |
|
| 147 | new TagDependency( |
|
| 148 | [ |
|
| 149 | 'tags' => [ |
|
| 150 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag( |
|
| 151 | static::className(), |
|
| 152 | $id |
|
| 153 | ), |
|
| 154 | ], |
|
| 155 | ] |
|
| 156 | ) |
|
| 157 | ); |
|
| 158 | } |
|
| 159 | } |
|
| 160 | static::$identity_map[$id] = $property; |
|
| 161 | } |
|
| 162 | return static::$identity_map[$id]; |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * Возвращает массив возможных значений свойств по property_id |
|