当前位置: 首页>>代码示例>>PHP>>正文


PHP Datasource::loadFromHandle方法代码示例

本文整理汇总了PHP中Datasource::loadFromHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP Datasource::loadFromHandle方法的具体用法?PHP Datasource::loadFromHandle怎么用?PHP Datasource::loadFromHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Datasource的用法示例。


在下文中一共展示了Datasource::loadFromHandle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render(Register $Parameters, XMLDocument &$Document = NULL, DocumentHeaders &$Headers = NULL)
 {
     $ParameterOutput = new Register();
     if (!is_null($Headers)) {
         $Headers->append('Content-Type', $this->{'content-type'});
     } else {
         header('Content-Type: ' . $this->{'content-type'});
     }
     if (is_null($Document)) {
         $Document = new XMLDocument();
         $Document->appendChild($Document->createElement('data'));
     }
     $root = $Document->documentElement;
     $datasources = $events = array();
     $events_wrapper = $Document->createElement('events');
     $root->appendChild($events_wrapper);
     if (is_array($this->about()->{'events'}) && !empty($this->about()->{'events'})) {
         $events = $this->about()->{'events'};
     }
     if (is_array($this->about()->{'data-sources'}) && !empty($this->about()->{'data-sources'})) {
         $datasources = $this->about()->{'data-sources'};
     }
     ####
     # Delegate: FrontendEventsAppend
     # Description: Append additional Events.
     # Global: Yes
     Extension::notify('FrontendEventsAppend', '/frontend/', array('events' => &$events));
     if (!empty($events)) {
         $postdata = General::getPostData();
         $events_ordered = array();
         foreach ($events as $handle) {
             $events_ordered[] = Event::loadFromHandle($handle);
         }
         uasort($events_ordered, array($this, '__cbSortEventsByPriority'));
         foreach ($events_ordered as $e) {
             if (!$e->canTrigger($postdata)) {
                 continue;
             }
             $fragment = $e->trigger($ParameterOutput, $postdata);
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $events_wrapper->appendChild($node);
             }
         }
     }
     ####
     # Delegate: FrontendDataSourceAppend
     # Description: Append additional DataSources.
     # Global: Yes
     Extension::notify('FrontendDataSourcesAppend', '/frontend/', array('datasources' => &$datasources));
     //	Find dependancies and order accordingly
     $datasource_pool = array();
     $dependency_list = array();
     $datasources_ordered = array();
     $all_dependencies = array();
     foreach ($datasources as $handle) {
         $datasource_pool[$handle] = Datasource::loadFromHandle($handle);
         $dependency_list[$handle] = $datasource_pool[$handle]->parameters()->dependencies;
     }
     $datasources_ordered = $this->__sortByDependencies($dependency_list);
     if (!empty($datasources_ordered)) {
         foreach ($datasources_ordered as $handle) {
             $ds = $datasource_pool[$handle];
             try {
                 $fragment = $ds->render($ParameterOutput);
             } catch (FrontendPageNotFoundException $e) {
                 FrontendPageNotFoundExceptionHandler::render($e);
             }
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $Document->importNode($fragment->documentElement, true);
                 $root->appendChild($node);
             }
         }
     }
     if ($ParameterOutput->length() > 0) {
         foreach ($ParameterOutput as $p) {
             $Parameters->{$p->key} = $p->value;
         }
     }
     ####
     # Delegate: FrontendParamsPostResolve
     # Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
     # Global: Yes
     Extension::notify('FrontendParamsPostResolve', '/frontend/', array('params' => $Parameters));
     $element = $Document->createElement('parameters');
     $root->appendChild($element);
     foreach ($Parameters as $key => $parameter) {
         if (is_array($parameter->value) && count($parameter->value) > 1) {
             $p = $Document->createElement($key);
             $p->setAttribute('value', (string) $parameter);
             foreach ($parameter->value as $v) {
                 $p->appendChild($Document->createElement('item', (string) $v));
             }
             $element->appendChild($p);
         } else {
             $element->appendChild($Document->createElement($key, (string) $parameter));
         }
     }
     $template = $this->template;
     ####
//.........这里部分代码省略.........
开发者ID:plasticine,项目名称:symphony-3,代码行数:101,代码来源:class.view.php

示例2: __prepareForm

 protected function __prepareForm()
 {
     $this->editing = isset($this->_context[1]);
     if (!$this->editing) {
         $this->type = $_REQUEST['type'];
         if (is_null($this->type)) {
             $this->type = Symphony::Configuration()->core()->{'default-datasource-type'};
         }
         // Should the default type or the selected type no longer be valid, choose the first available one instead
         if (!in_array($this->type, array_keys($this->types))) {
             $this->type = current(array_keys($this->types));
         }
         foreach ($this->types as $type) {
             if ($type->class != $this->type) {
                 continue;
             }
             $this->datasource = new $type->class();
             $this->datasource->prepare(isset($_POST['fields']) ? $_POST['fields'] : NULL);
             break;
         }
     } else {
         $this->handle = $this->_context[1];
         // Status message:
         $callback = Administration::instance()->getPageCallback();
         if (isset($callback['flag']) && !is_null($callback['flag'])) {
             $this->status = $callback['flag'];
         }
         $this->datasource = Datasource::loadFromHandle($this->handle);
         $this->type = $this->datasource->getType();
         $this->datasource->prepare(isset($_POST['fields']) ? $_POST['fields'] : NULL);
         if (!$this->datasource->allowEditorToParse()) {
             redirect(ADMIN_URL . '/blueprints/datasources/info/' . $this->handle . '/');
         }
     }
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:35,代码来源:content.blueprintsdatasources.php

示例3: delete

 public function delete($datasource)
 {
     /*
     	TODO:
     	Upon deletion of the event, views need to be updated to remove
     	it's associated with the event
     */
     if (!$datasource instanceof DataSource) {
         $datasource = Datasource::loadFromHandle($datasource);
     }
     $handle = $datasource->handle;
     if (!$datasource->allowEditorToParse()) {
         throw new DataSourceException(__('Datasource cannot be deleted, the Editor does not have permission.'));
     }
     return General::deleteFile(DATASOURCES . "/{$handle}.php");
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:16,代码来源:class.datasource.php

示例4: buildOutput

 public function buildOutput()
 {
     $ParameterOutput = new Register();
     $root = $this->document->documentElement;
     $this->buildContextXML($root);
     $datasources = $events = array();
     $events_wrapper = $this->document->createElement('events');
     $root->appendChild($events_wrapper);
     if (is_array($this->about()->{'events'}) && !empty($this->about()->{'events'})) {
         $events = $this->about()->{'events'};
     }
     if (is_array($this->about()->{'data-sources'}) && !empty($this->about()->{'data-sources'})) {
         $datasources = $this->about()->{'data-sources'};
     }
     ####
     # Delegate: FrontendEventsAppend
     # Description: Append additional Events.
     # Global: Yes
     Extension::notify('FrontendEventsAppend', '/frontend/', array('events' => &$events));
     if (!empty($events)) {
         $postdata = General::getPostData();
         $events_ordered = array();
         foreach ($events as $handle) {
             $events_ordered[] = Event::loadFromHandle($handle);
         }
         uasort($events_ordered, array($this, '__cbSortEventsByPriority'));
         foreach ($events_ordered as $e) {
             if (!$e->canTrigger($postdata)) {
                 continue;
             }
             $fragment = $e->trigger($ParameterOutput, $postdata);
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $this->document->importNode($fragment->documentElement, true);
                 $events_wrapper->appendChild($node);
             }
         }
     }
     ####
     # Delegate: FrontendDataSourceAppend
     # Description: Append additional DataSources.
     # Global: Yes
     Extension::notify('FrontendDataSourcesAppend', '/frontend/', array('datasources' => &$datasources));
     //	Find dependancies and order accordingly
     $datasource_pool = array();
     $dependency_list = array();
     $datasources_ordered = array();
     $all_dependencies = array();
     foreach ($datasources as $handle) {
         $datasource_pool[$handle] = Datasource::loadFromHandle($handle);
         $dependency_list[$handle] = $datasource_pool[$handle]->parameters()->dependencies;
     }
     $datasources_ordered = General::dependenciesSort($dependency_list);
     $data = $this->document->createElement('data');
     if (!empty($datasources_ordered)) {
         foreach ($datasources_ordered as $handle) {
             $ds = $datasource_pool[$handle];
             try {
                 $fragment = $ds->render($ParameterOutput);
             } catch (FrontendPageNotFoundException $e) {
                 FrontendPageNotFoundExceptionHandler::render($e);
             }
             if ($fragment instanceof DOMDocument && !is_null($fragment->documentElement)) {
                 $node = $this->document->importNode($fragment->documentElement, true);
                 $data->appendChild($node);
             }
         }
     }
     $root->appendChild($data);
     /*
     			if($ParameterOutput->length() > 0){
     				foreach($ParameterOutput as $p){
     					$Parameters->{$p->key} = $p->value;
     				}
     			}
     
     			####
     			# Delegate: FrontendParamsPostResolve
     			# Description: Access to the resolved param pool, including additional parameters provided by Data Source outputs
     			# Global: Yes
     			Extension::notify('FrontendParamsPostResolve', '/frontend/', array('params' => $Parameters));
     
     
     			####
     			# Delegate: FrontendTemplatePreRender
     			# Description: Access to the template source, before it is rendered.
     			# Global: Yes
     			Extension::notify(
     				'FrontendTemplatePreRender', '/frontend/', array(
     					'document'	=> $Document,
     					'template'	=> &$template
     				)
     			);
     */
     return $this->transform();
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:95,代码来源:class.frontendview.php


注:本文中的Datasource::loadFromHandle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。