Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisros authored Oct 7, 2019
2 parents eb37634 + c4bab77 commit 2827c5d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
9 changes: 6 additions & 3 deletions Controller/AdminInterfaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ private function getConfiguration(Config $feed)
'published'=>$feed->get('published'),
'class'=>$feed->get('class'),
'root'=>$feed->get('root'),
'type'=>$feed->get('type')
'type'=>$feed->get('type'),
'service'=>$feed->get('service'),
];
}

Expand Down Expand Up @@ -180,7 +181,8 @@ public function providerAction(Request $request)
'published'=>$request->get('published'),
'class'=>$request->get('class'),
'root'=>$request->get('root'),
'type'=>$request->get('type')
'type'=>$request->get('type'),
'service'=>$request->get('service'),
];

/** @var Config $current */
Expand Down Expand Up @@ -215,7 +217,8 @@ public function addAction(Request $request)
'published'=>$request->get('published'),
'class'=>$request->get('class'),
'root'=>$request->get('root'),
'type'=>$request->get('type')
'type'=>$request->get('type'),
'service'=>$request->get('service'),
];

/** @var Config $current */
Expand Down
8 changes: 6 additions & 2 deletions Controller/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FeedController extends FrontendController
* "/{slug}.{_format}",
* defaults={"_format": "json"},
* requirements={
* "_format": "json|xml|html",
* "_format": "json|xml|html|raw",
* "methods": "GET"
* }
* )
Expand All @@ -47,7 +47,8 @@ public function testAction(Request $request){
throw new NotFoundHttpException('Feed not found.');
}

$feedbuilder = new FeedBuilderService($this->get('event_dispatcher'));
$containerId = $config->get('service');
$feedbuilder = $this->container->get($containerId);
$result = $feedbuilder->run($config, $request->get('ignoreCache', false));

//@TODO Add check for ipaddress
Expand All @@ -61,6 +62,9 @@ public function testAction(Request $request){
case 'html':
return $this->HtmlResponse($result, $config);
break;
case 'raw':
echo $result;
exit;
}

throw new NotFoundHttpException('Sorry feed not found.');
Expand Down
5 changes: 5 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ services:
FeedBuilderBundle\EventListener\ExportExample:
tags:
- { name: kernel.event_listener, event: feedbuilder.after.run, method: fileHandler }

feedBuilderBundle.defaultFeedBuilderService:
class: FeedBuilderBundle\Service\FeedBuilderService
public: true

18 changes: 16 additions & 2 deletions Resources/public/js/pimcore/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ feedbuilder.panelitem = Class.create({
name: "root",
value: this.data.configuration.root,
fieldLabel: t("feedbuilder_form_root")
}

},
this.getServiceField(),
]
},{
xtype: "fieldset",
Expand Down Expand Up @@ -107,6 +107,20 @@ feedbuilder.panelitem = Class.create({
});
return this.form;
},

getServiceField : function() {
if(!this.data.configuration.service){
this.data.configuration.service = 'feedBuilderBundle.defaultFeedBuilderService';
}

return new Ext.form.TextField({
xtype: "textfield",
name: "service",
value: this.data.configuration.service,
fieldLabel: t("feedbuilder_service_id"),
})
},

getUrl: function() {
var url = '/feedbuilder/'+this.data.text;
return new Ext.Panel({
Expand Down
1 change: 1 addition & 0 deletions Resources/translations/admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ feedbuilder_form_type_object: 'Object save'
feedbuilder_form_type_export: 'Cronjob'
feedbuilder_form_type_feed: 'Feed'
feedbuilder_form_root: 'Root element'
feedbuilder_service_id: 'FeedBuilder Service Id'
feedbuilder_title_create_new: 'Create new feed'
feedbuilder_enter_the_name_of_the_new_feed: 'Add the new name of the feed'
feedbuilder_delete_successfully: 'Feed succesfully removed'
Expand Down
22 changes: 13 additions & 9 deletions Service/FeedBuilderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@

class FeedBuilderService
{
private $dispatcher = null;

private $key_attributes = [];

public function __construct(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}

const LOCATION_FILE = 'feedbuilder.php';

const TYPE_OBJECT = 1;
const TYPE_EXPORT = 2;
const TYPE_FEED = 3;

private $dispatcher = null;

private $key_attributes = [];

/**
* FeedBuilderService constructor.
* @param EventDispatcherInterface $dispatchers
*/
public function __construct(
EventDispatcherInterface $dispatcher
) {
$this->dispatcher = $dispatcher;
}

/**
* Returns the config file for the feedbuilder, see the feedbuilder.example.php
Expand Down

0 comments on commit 2827c5d

Please sign in to comment.