Skip to content

Commit

Permalink
add filtering by delegate + bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmifsud authored and nitriques committed Oct 6, 2016
1 parent 16e1c30 commit c886dca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions extension.meta.xml
Expand Up @@ -13,6 +13,10 @@
</author>
</authors>
<releases>
<release version="1.1.0" date="2016-02-22" min="2.5">
- Added new `AssociationFiltering` delegate allowing extension to filter results
- Fix MySQL 5.7 Distinct, order by error when in strict mode
</release>
<release version="1.0.1" date="2015-07-21" min="2.5">
- Removed association count from index for single select fields
</release>
Expand Down
23 changes: 22 additions & 1 deletion fields/field.association.php
Expand Up @@ -121,8 +121,29 @@ public function findOptions(array $selected_ids = array(), $entry_id = null)
);

if ($limit > 0) {

$where = '';
$joins = '';

/**
* Allow the results to be modified using adjust publish filtering functionality on the core
*
* @delegate AssociationFiltering
* @since Symphony 1.1.0
* @param string $context
* '/publish/'
* @param array $options
* An array which should contain the section id
* and the joins and where clauses by reference both passed by reference
*/
Symphony::ExtensionManager()->notifyMembers('AssociationFiltering', '/publish/', array(
'section-id' => $section->get('id'),
'joins' => &$joins,
'where' => &$where
));

EntryManager::setFetchSorting($section->getSortingField(), $section->getSortingOrder());
$entries = EntryManager::fetch(null, $section->get('id'), $limit, 0, null, null, false, false);
$entries = EntryManager::fetch(null, $section->get('id'), $limit, 0, $where, $joins, false, false);
foreach ($entries as $entry) {
$results[] = (int) $entry['id'];
}
Expand Down

0 comments on commit c886dca

Please sign in to comment.