Prado\Web\Services\TFeedService::run PHP Method

run() public method

This method is invoked by application automatically.
public run ( )
    public function run()
    {
        $id = $this->getRequest()->getServiceParameter();
        if (isset($this->_feeds[$id])) {
            $feedConfig = $this->_feeds[$id];
            $properties = array();
            $feed = null;
            if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
                if (isset($feedConfig['class'])) {
                    $feed = Prado::createComponent($feedConfig['class']);
                    if ($service instanceof IFeedContentProvider) {
                        $properties = isset($feedConfig['properties']) ? $feedConfig['properties'] : array();
                    } else {
                        throw new TConfigurationException('jsonservice_response_type_invalid', $id);
                    }
                } else {
                    throw new TConfigurationException('jsonservice_class_required', $id);
                }
            } else {
                $properties = $feedConfig->getAttributes();
                if (($class = $properties->remove('class')) !== null) {
                    $feed = Prado::createComponent($class);
                    if (!$feed instanceof IFeedContentProvider) {
                        throw new TConfigurationException('feedservice_feedtype_invalid', $id);
                    }
                } else {
                    throw new TConfigurationException('feedservice_class_required', $id);
                }
            }
            // init feed properties
            foreach ($properties as $name => $value) {
                $feed->setSubproperty($name, $value);
            }
            $feed->init($feedConfig);
            $content = $feed->getFeedContent();
            //$this->getResponse()->setContentType('application/rss+xml');
            $this->getResponse()->setContentType($feed->getContentType());
            $this->getResponse()->write($content);
        } else {
            throw new THttpException(404, 'feedservice_feed_unknown', $id);
        }
    }