Skip to content

Instantly share code, notes, and snippets.

@adampiotrowski
Created February 9, 2017 14:31
Show Gist options
  • Select an option

  • Save adampiotrowski/f68dfa5707e427774226e7b00dacecfd to your computer and use it in GitHub Desktop.

Select an option

Save adampiotrowski/f68dfa5707e427774226e7b00dacecfd to your computer and use it in GitHub Desktop.
<?php
namespace RedIsBad\Bundle\AppBundle\Provider;
use WellCommerce\Bundle\CoreBundle\DependencyInjection\AbstractContainerAware;
use WellCommerce\Bundle\ShippingBundle\Provider\ShippingMethodOptionsProviderInterface;
/**
* Class InpostOptionsProvider
*
* @package RedIsBad\Bundle\AppBundle
*/
class InpostOptionsProvider extends AbstractContainerAware implements ShippingMethodOptionsProviderInterface
{
public function getShippingOptions() : array
{
$cacheDir = $this->getKernel()->getCacheDir();
$user = $this->container->getParameter('inpost_user');
$pass = $this->container->getParameter('inpost_pass');
$client = new InpostClient($user, $pass, $cacheDir);
$paczkomaty = $client->inpost_get_machine_list();
$tmp = ['' => '--- wybierz ---'];
foreach ($paczkomaty as $paczkomat) {
$tmp[$paczkomat['name']] = sprintf(
'%s - %s %s %s',
$paczkomat['name'],
$paczkomat['town'],
$paczkomat['street'],
$paczkomat['buildingnumber']
);
}
return $tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment