/** * Retrieve reflection for anonymous function * @param string $file * @throws ApplicationException * @return Reflection */ public function reflection($file) { // cache for reflection data if (!($reflection = Cache::get('reflection:' . $file))) { $reflection = new Reflection($file); $reflection->process(); Cache::set('reflection:' . $file, $reflection); Cache::addTag('reflection:' . $file, 'reflection'); } return $reflection; }
/** * Get user privileges * * @param integer $roleId * @return array */ public function getRolePrivileges($roleId) { $cacheKey = 'privileges:role:' . $roleId; if (!($data = Cache::get($cacheKey))) { $data = Db::fetchColumn("SELECT DISTINCT CONCAT(p.module, ':', p.privilege)\n FROM acl_privileges AS p, acl_roles AS r\n WHERE p.roleId = r.id AND r.id = ?\n ORDER BY CONCAT(p.module, ':', p.privilege)", array((int) $roleId)); Cache::set($cacheKey, $data, Cache::TTL_NO_EXPIRY); Cache::addTag($cacheKey, 'privileges'); } return $data; }
/** * Retrieve reflection for anonymous function * @return Reflection * @throws \Bluz\Common\Exception\ComponentException */ protected function setReflection() { // cache for reflection data if (!($reflection = Cache::get('reflection:' . $this->module . ':' . $this->controller))) { $reflection = new Reflection($this->getFile()); $reflection->process(); Cache::set('reflection:' . $this->module . ':' . $this->controller, $reflection); Cache::addTag('reflection:' . $this->module . ':' . $this->controller, 'reflection'); } $this->reflection = $reflection; }
/** * Return information about tables columns * * @return array */ public function getColumns() { if (empty($this->columns)) { $columns = Cache::get('table:columns:' . $this->table); if (!$columns) { $connect = DbProxy::getOption('connect'); $columns = DbProxy::fetchColumn(' SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?', [$connect['name'], $this->getName()]); Cache::set('table:columns:' . $this->table, $columns); Cache::addTag('table:columns:' . $this->table, 'db'); } $this->columns = $columns; } return $this->columns; }
/** * Get all user roles in system * * @param integer $userId * @return array of identity */ public function getUserRolesIdentity($userId) { $cacheKey = 'roles:user:'******'roles'); Cache::addTag($cacheKey, 'user:' . $userId); } return $data; }