public function indexAction() { $this->doNotRender(); $origin = $this->getParam('origin'); $destination = ShortUrl::parse($origin); $this->redirect($destination); }
public function deleteAction() { $id = (int) $this->getParam('id'); $record = ShortUrl::getRepository()->find($id); if ($record instanceof ShortUrl) { $record->delete(); } $this->alert('<b>Record deleted.</b>', 'green'); $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); }
public static function api($row) { if ($row instanceof self) { $row = $row->toArray(); } $api = array('id' => (int) $row['id'], 'name' => $row['name'], 'shortcode' => self::getStationShortName($row['name']), 'genre' => $row['genre'], 'category' => $row['category'], 'affiliation' => $row['affiliation'], 'image_url' => \PVL\Url::upload($row['image_url']), 'web_url' => $row['web_url'], 'twitter_url' => $row['twitter_url'], 'irc' => $row['irc'], 'sort_order' => (int) $row['weight']); if (isset($row['streams'])) { $api['streams'] = array(); foreach ((array) $row['streams'] as $stream) { $api['streams'][] = StationStream::api($stream); // Set first stream as default, override if a later stream is explicitly default. if ($stream['is_default'] || !isset($api['default_stream_id'])) { $api['default_stream_id'] = (int) $stream['id']; $api['stream_url'] = $stream['stream_url']; } } } $api['player_url'] = ShortUrl::stationUrl($api['shortcode']); if ($row['requests_enabled']) { $api['request_url'] = \DF\Url::route(array('module' => 'default', 'controller' => 'station', 'action' => 'request', 'id' => $row['id'])); } else { $api['request_url'] = ''; } return $api; }