/** * Creates a link to EDIT this record, if the user is logged in. * * @return string */ public function editlink() { $perm = 'contenttype:' . $this->contenttype['slug'] . ':edit:' . $this->id; if ($this->app['users']->isAllowed($perm)) { return $this->app->generatePath('editcontent', ['contenttypeslug' => $this->contenttype['slug'], 'id' => $this->id]); } else { return false; } }
/** * Create a link to edit a .yml file, if a filename is detected in the string. Mostly * for use in Flashbag messages, to allow easy editing. * * @param string $str * @param boolean $safe * * @return string Resulting string */ public function ymllink($str, $safe) { // There is absolutely no way anyone could possibly need this in a "safe" context if ($safe) { return null; } $matches = []; if (preg_match('/ ([a-z0-9_-]+\\.yml)/i', $str, $matches)) { $path = $this->app->generatePath('fileedit', ['namespace' => 'config', 'file' => $matches[1]]); $link = sprintf(' <a href="%s">%s</a>', $path, $matches[1]); $str = preg_replace('/ ([a-z0-9_-]+\\.yml)/i', $link, $str); } return $str; }