Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions data-sources/datasource.union.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ public static function buildEditor(XMLElement $wrapper, array &$errors = array()
$i = 0;
foreach($datasources as $handle => $datasource) {
$about = $datasource->about();
$source = SectionManager::fetch($datasources[$handle]->getSource());
$source = (new SectionManager)
->select()
->section($datasources[$handle]->getSource())
->execute()
->next();

if(($source instanceof Section) === false) continue;

Expand Down Expand Up @@ -278,7 +282,11 @@ public static function buildEditor(XMLElement $wrapper, array &$errors = array()
if(!isset($datasources[$handle])) continue;

$about = $datasources[$handle]->about();
$source = SectionManager::fetch($datasources[$handle]->getSource());
$source = (new SectionManager)
->select()
->section($datasources[$handle]->getSource())
->execute()
->next();

if(($source instanceof Section) === false) continue;

Expand Down Expand Up @@ -384,9 +392,11 @@ public function grab(array &$param_pool = null) {
str_replace('-','_', $handle), $this->_env, true
);

$this->datasources[$handle]['section'] = SectionManager::fetch(
$this->datasources[$handle]['datasource']->getSource()
);
$this->datasources[$handle]['section'] = (new SectionManager)
->select()
->section($this->datasources[$handle]['datasource']->getSource())
->execute()
->next();

$result->appendChild(
new XMLElement('section', General::sanitize($this->datasources[$handle]['section']->get('name')), array(
Expand Down Expand Up @@ -506,7 +516,12 @@ public function grab_sql(Datasource $datasource) {

include_once(TOOLKIT . '/class.entrymanager.php');

if(!$section = SectionManager::fetch((int)$datasource->getSource())){
if(!$section = (new SectionManager)
->select()
->section((int)$datasource->getSource())
->execute()
->next()
){
$about = $datasource->about();
trigger_error(__('The section associated with the data source %s could not be found.', array('<code>' . $about['name'] . '</code>')), E_USER_ERROR);
}
Expand Down Expand Up @@ -556,9 +571,11 @@ public function grab_sql(Datasource $datasource) {
}
// Handle real field instances
else {
$field = FieldManager::fetch(
FieldManager::fetchFieldIDFromElementName($datasource->dsParamSORT, $datasource->getSource())
);
$field = (new FieldManager)
->select()
->field(FieldManager::fetchFieldIDFromElementName($datasource->dsParamSORT, $datasource->getSource()))
->execute()
->next();

$field->buildSortingSQL($joins, $where, $data['sort'], $datasource->dsParamORDER);

Expand Down Expand Up @@ -841,7 +858,11 @@ public function output(XMLElement &$result, $entries, &$param_pool) {
// Setup any datasources variables ONCE.
if(!isset($ds['datasource']->_param_pool)) {
$ds['datasource']->_param_pool = $param_pool;
$pool = FieldManager::fetch(array_keys($data));
$pool = (new FieldManager)
->select()
->fields(array_keys($data))
->execute()
->rows();
self::$field_pool += $pool;

if (!isset($datasource->dsParamASSOCIATEDENTRYCOUNTS) || $datasource->dsParamASSOCIATEDENTRYCOUNTS == 'yes') {
Expand All @@ -866,7 +887,11 @@ public function output(XMLElement &$result, $entries, &$param_pool) {
foreach($data as $field_id => $values) {
// Check to see if we have a Field object already, if not create one
if(!isset(self::$field_pool[$field_id]) || !self::$field_pool[$field_id] instanceof Field) {
self::$field_pool[$field_id] = FieldManager::fetch($field_id);
self::$field_pool[$field_id] = (new FieldManager)
->select()
->field($field_id)
->execute()
->next();
}

// Process output parameters
Expand Down Expand Up @@ -913,7 +938,11 @@ public function output(XMLElement &$result, $entries, &$param_pool) {
public function processDatasourceFilters(Datasource $datasource, &$where, &$joins, &$group) {
if(!is_array($datasource->dsParamFILTERS) || empty($datasource->dsParamFILTERS)) return;

$pool = FieldManager::fetch(array_filter(array_keys($datasource->dsParamFILTERS), 'is_int'));
$pool = (new FieldManager)
->select()
->fields(array_filter(array_keys($datasource->dsParamFILTERS), 'is_int'))
->execute()
->rows();
self::$field_pool += $pool;

foreach($datasource->dsParamFILTERS as $field_id => $filter){
Expand Down
2 changes: 1 addition & 1 deletion extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function registerProviders() {
return true;
}

public static function providerOf($type = null) {
public function providerOf($type = null) {
self::registerProviders();

if(is_null($type)) return self::$provides;
Expand Down
5 changes: 5 additions & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
</author>
</authors>
<releases>
<release version="2.0.0" date="TBA" min="4.0.0" max="4.x.x" php-min="5.6.x" php-max="7.x.x">
* Update for Symphony 4.x
* PHP7 Compatibility
* Replace deprecated method fetch() by select()
</release>
<release version="1.2" date="2017-03-24" min="2.5">
* [#43](https://github.com/brendo/uniondatasource/issues/43) Fix formatted textarea being escaped (thanks @Aonrud)
* [#42](https://github.com/brendo/uniondatasource/issues/42) Prevent parameters from duplicating in the output (thanks @moretaste)
Expand Down
2 changes: 1 addition & 1 deletion templates/blueprints.datasource.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'system:pagination'
);

public function __construct($env=NULL, $process_params=true){
public function __construct($env = null, $process_params = true){
parent::__construct($env, $process_params);
$this->_dependencies = array(<!-- DS DEPENDENCY LIST -->);
}
Expand Down