Giter Site home page Giter Site logo

sonataimporterbundle's People

Contributors

kunicmarko20 avatar vstanchev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sonataimporterbundle's Issues

SonataImportConfiguration before not exists

1 Why in sonata method before not exists.
2 Is possible to get in

public function map(array $item, array $additionalData)

item is

 => array:2 [▼
    0 => "name"
    1 => "description"

i preffer - use first row as key names and get assoc array key=>value

here is my example file

name description
audi audi desc
BMW desc bmw

is possble to configure it in this way ?

issue installing on symfony 4.1 / Sonata

The service "KunicMarko\SonataImporterBundle\Controller\ImportCRUDController" has a dependency on a non-existent service "KunicMarko\Importer\ImporterFactory.

PHP 7.2 - Symfony 4.1

Best regards

PHP Exception ReflectionException: "Method importAction does not exist" on Sonata 3.4 admin

Q A
Version 0.1.2

Support Question

Hello there, @kunicmarko20.
I have installed version 0.1.2 successfully on my application and now the button shows up on my admin page.
But when I click in this button, i receive a
Uncaught PHP Exception ReflectionException: "Method importAction does not exist" at /vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php line 58 {"exception":"[object] (ReflectionException(code: 0): Method importAction does not exist at /vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php:58)"} []

My admin class looks like:

use Sonata\AdminBundle\Admin\AbstractAdmin;
...
use KunicMarko\SonataImporterBundle\Admin\AdminWithImport;

class ListingAdmin extends AbstractAdmin implements AdminWithImport
{
 ...
}

I have no AdminController defined, so I have used the https://github.com/kunicmarko20/SonataImporterBundle/tree/0.1.2#prepare-controller config
I have already created a ListingCSVImportConfiguration class src/Cocorico/CoreBundle/Importer/ListingCSVImportConfiguration.php but couldn't link it with my Admin class and didn't find a way to do it.

The ListingCSVImportConfiguration content is:


use Cocorico\CoreBundle\Admin\ListingAdmin;
use Cocorico\CoreBundle\Model\Manager\ListingManager;
use Cocorico\CoreBundle\Entity\Listing;
use KunicMarko\SonataImporterBundle\SonataImportConfiguration;


class ListingCSVImportConfiguration implements SonataImportConfiguration
{

    protected $lem;

    public function __construct(ListingManager $lem)
    {
        $this->lem = $lem;
    }

    public static function adminClass(): string
    {
        return ListingAdmin::class;
    }

    public static function format(): string
    {
        return 'csv';
    }

    public function map(array $item, array $additionalData)
    {
        $listing = new Listing();

        $listing->setName($item[0]);

        $this->lem->save($listing);
    }

    public function save(array $items, array $additionalData): void
    {
        $this->lem->save();
    }
}

Configuration - show or not

I propose to add visible configuration - preferred method in admin - isImportEnabled()

i can check user ROLE and then decide show import or not. Now is not easy remove import action because its add after admin configure routes / panel actions.

thanks

Import action breaks non-import admins

The method AdminImportExtension::configureActionButtons does not check if the current $admin implements the AdminWithImport interface and alwasy adds the import action. This breaks admins for which an import does not exist with an exception similar to

An exception has been thrown during the rendering of a template ("unable to find the route admin.company.import").

Proposed resolution is to check if $admin implements the import interface as follows:

public function configureActionButtons(AdminInterface $admin, $list, $action, $object): array
    {
        if (!$admin instanceof AdminWithImport) {
            return $list;
        }

        $list['import']['template'] = $this->templates['action_button'];

        return $list;
    }

Unable to install

Getting the following error when trying to install on Symfony 4.4:

The service "KunicMarko\SonataImporterBundle\Controller\ImportCRUDController" has a dependency on a non-existent service "KunicMarko\Importer\ImporterFactory".

Issue installing on Symfony 3.4 / Sonata

Q A
Version 0.1.1

Support Question

Hello there,
I am trying to install this package on a version of Cocorico and everytime I run my composer install, i receive the following error:

Fatal error: Uncaught Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "getRootNode" of class "Symfony\Component\Config\Definition\Builder\TreeBuilder". in vendor/kunicmarko/sonata-importer-bundle/src/DependencyInjection/Configuration.php on line 19

Symfony\Component\Debug\Exception\UndefinedMethodException: Attempted to call an undefined method named "getRootNode" of class "Symfony\Component\Config\Definition\Builder\TreeBuilder". in vendor/kunicmarko/sonata-importer-bundle/src/DependencyInjection/Configuration.php on line 19

This only happens when I try to use new KunicMarko\SonataImporterBundle\SonataImporterBundle(), on my AppKernel.php.

Could you help me out with this?

Setup help

I have problems with setup.
(Symfony 4.4, Sonata admin 3.55.0)

AutoConfigure ImportConfiguration
To be able to auto-configure your ImportConfiguration they will have to implement KunicMarko\SonataImporterBundle\SonataImportConfiguration and configure format and adminClass methods along with other methods.

I add to admin implements AdminWithImport
I add to controller trait and implement interface

class MyCrudController extends BaseController implements ControllerWithImport
{
    use ImportActionTrait;

but i dont understand what now.
"To be able to auto-configure your ImportConfiguration they will have to implement"

Where i should put "ImportConfiguration" ?

i see import action in panel when i click i have

Call to a member function getImporter() on null
in
$importer = $this->importerFactory->getImporter($type = $import->file->getClientOriginalExtension());

I create My importerConfiguration for admin - how to connect it to admin ?
I register as service but still have error (Call to a member function getImporter() on null)

I see that my AdminContrller dont have ImporterFactory

Thanks for any info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.