/** * @param $id * @param $path * @return RbacDefinition|bool */ protected function createDefinition($id, $path) { if (!isset($this->definitions[$id])) { $rules = []; $cached = $this->getCache()->get(self::CACHE_KEY . ':' . $path); $dependency = Yii::createObject(TagDependency::className(), ['tags' => [self::CACHE_TAG]]); if ($cached) { $rules = $cached; } else { if (is_array($path)) { $rules = $path; } elseif (file_exists($path)) { $rules = (include $path); } } if (is_array($rules) && !empty($rules)) { $rules['module'] = $id; $this->getCache()->set(self::CACHE_KEY . ':' . $path, $rules, $this->cacheDuration, $dependency); $this->definitions[$id] = new RbacDefinition($rules); } } return isset($this->definitions[$id]) ? $this->definitions[$id] : false; }