@param CrudConfigurator $crudConfigurator

@return JsonResponse

@throws \SymfonyId\AdminBundle\Exception\RuntimeException
334368
public function bulkCreate(CrudConfigurator $crudConfigurator)
    {
        /** @var BulkCreateActionHandler $viewHandler */
        $viewHandler = $this->actionHandlers[BulkCreateActionHandler::class];
        $viewHandler->setView($this->view);
        $viewHandler->setRequest($this->request);
        $viewHandler->setCrudConfigurator($crudConfigurator);

        $view = $viewHandler->getView($this->driver);

        return new JsonResponse(array(
            'status' => $view->getParam('status'),
            'message' => $view->getParam('message'),
        ));
    }
660349
public function getSingle($id)
    {
        /** @var \SymfonyId\AdminBundle\Configuration\ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);

        /** @var ModelInterface $model */
        $model = $this->findOr404Error($id);

        return $this->createResponse($model);
    }
1125691
public function execute($httpMethod, $url, array $parameters = [])
    {
        if ($this->config instanceof Config) {
            try {
                $this->response = $this->getClient()->{$httpMethod}($this->config->getAccountNumber() . $url, [
                    'json' => $parameters,
                ]);

                return json_decode((string) $this->response->getBody());

            } catch (ClientException $e) {
                throw new Handler($e);
            }

            return;
        }

        throw new \RuntimeException('The API requires a configuration instance.');
    }
56205
public function getIndexConfigurator()
    {
        static $indexConfigurator;

        if (! $indexConfigurator) {
            if (! isset($this->indexConfigurator) || empty($this->indexConfigurator)) {
                throw new Exception(sprintf(
                    'An index configurator for the %s model is not specified.',
                    __CLASS__
                ));
            }

            $indexConfiguratorClass = $this->indexConfigurator;
            $indexConfigurator = new $indexConfiguratorClass;
        }

        return $indexConfigurator;
    }
11660
protected static function defaultCreateResponse(
        string $index,
        UriInterface $requestUri,
        CrudInterface $crud,
        JsonSchemasInterface $jsonSchemas,
        EncoderInterface $encoder
    ): ResponseInterface {
        $model = $crud->read($index);
        assert($model !== null && !($model instanceof PaginatedDataInterface));

        $responses = static::defaultCreateResponses($requestUri, $encoder);
        $fullUrl   = static::defaultGetResourceUrl($model, $requestUri, $jsonSchemas);
        $response  = $responses->getCreatedResponse($model, $fullUrl);

        return $response;
    }
247233
protected function configureDefinition(EntityDefinition $definition, array $crud)
    {
        $toConfigure = [
            'deleteCascade',
            'listFields',
            'filter',
            'childrenLabelFields',
            'pageSize',
            'initialSortField',
            'initialSortAscending',
            'navBarGroup',
            'optimisticLocking',
            'hardDeletion',
        ];
        foreach ($toConfigure as $field) {
            if (array_key_exists($field, $crud)) {
                $function = 'set'.ucfirst($field);
                $definition->$function($crud[$field]);
            }
        }
    }
1207133
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $controller     = new IndexController();
        $serviceLocator = $this->transformIntoServiceManager($serviceLocator);

        /** @var array|\Zend\Config\Config $configuration */
        $configuration  = $serviceLocator->get('Config');
        $key            = 'net_bazzline_zf_cli_generator';

        if (!isset($configuration[$key])) {
            throw new InvalidArgumentException (
                'expected configuration key "' . $key . '" not found'
            );
        }

        /** @var PipeInterface $cliGenerator */
        $cliGenerator = $serviceLocator->get('NetBazzlineCliGeneratorGenerateCliContent');
        /** @var PipeInterface $configurationGenerator */
        $configurationGenerator = $serviceLocator->get('NetBazzlineCliGeneratorGenerateConfigurationContent');

        $configuration          = $configuration[$key];
        $pathToApplication      = $configuration['application']['path'] .
            DIRECTORY_SEPARATOR .
            $configuration['application']['name'];
        $pathToAutoload         = $configuration['autoload']['path'] .
            DIRECTORY_SEPARATOR .
            $configuration['autoload']['name'];
        $pathToConfiguration    = $configuration['configuration']['target']['path'] .
            DIRECTORY_SEPARATOR .
            $configuration['configuration']['target']['name'];
        $pathToCli              = $configuration['cli']['target']['path'] .
            DIRECTORY_SEPARATOR .
            $configuration['cli']['target']['name'];
        $prefix                 = $configuration['cli']['prefix'];

        $controller->injectGenerateConfigurationProcessPipe($configurationGenerator);
        $controller->injectGenerateCliProcessPipe($cliGenerator);
        $controller->injectPathToApplication($pathToApplication);
        $controller->injectPathToAutoload($pathToAutoload);
        $controller->injectPathToConfiguration($pathToConfiguration);
        $controller->injectPathToCli($pathToCli);
        $controller->injectPrefix($prefix);

        return $controller;
    }
31635
public function redirectBackWithErrors($validator)
    {
        if (request()->wantsJson()) {
            return $this->validUnprocessableEntityJsonResponse($validator->errors());
        }

        return back()->withErrors($validator)->withInput();
    }
1093567
protected function configureCache()
    {
        if (!isset($this['cache'])) {
            $this['cache'] = [
                'type' => 'array'
            ];
        }
        if (!isset($this['cache']['type'])) {
            throw new RuntimeException("cache type not configured correctly");
        }
        switch ($this['cache']['type']) {
            case 'array':
                $cache = new \Symfony\Component\Cache\Adapter\ArrayAdapter();
                break;
            case 'filesystem':
                $directory = $this['cache']['directory'];
                if (!$directory) {
                    throw new RuntimeException("cache directory not configured (please check doc/cache.md)");
                }
                if (!file_exists($directory)) {
                    mkdir($directory, 0777, true);
                }
                $cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter('', 0, $directory);
                break;
            default:
                throw new RuntimeException("Unsupported cache.type:" . $this['cache']['type']);

        }
        $this['cache'] = $cache;
    }
325289
protected function _crud()
    {
        if (!$this->_controller->Crud) {
            return $this->_controller->components()->load('Crud.Crud');
        }

        return $this->_controller->Crud;
    }
440318
public function handle(CrudBuilder $crud)
    {

        if($this->argument('ModelName') == 'User'){

            $this->error('Oops, Can\'t do this on User!');

            return;


        }


        if ( $crud->makeCrudFiles($this->argument()) ) {

            $this->sendSuccessMessage();

            return;

        } else {


            $this->error('Oops, something went wrong!');

            return;

        }



    }
844300
public function fetchCrudService(AutoTablesConfiguration $config)
    {
        if ($config->getServiceId()) {
            $this->logger->info(sprintf('Create CrudService from serviceId [%s]', $config->getServiceId()));
            $crudService = $this->get($config->getServiceId());
            Ensure::isNotNull($crudService, 'No service [%s] found', $crudService);
            Ensure::isTrue($crudService instanceof AutoTablesCrudService, 'Service [%s] has to implement %s', $config->getServiceId(), 'AutoTablesCrudService');
        } else {
            $this->logger->info(sprintf('Create CrudService from repositoryId [%s]', $config->getRepositoryId()));
            Ensure::isNotEmpty($config->getRepositoryId(), 'Neither [serviceId] nor [repositoryId] defined for datatables of type [%s]', $config->getId());
            $repository = $this->doctrine->getRepository($config->getRepositoryId());
            Ensure::isNotNull($repository, 'Repository with id [%s] not found', $config->getRepositoryId());
            $crudService = new RepositoryAutoTablesCrudService($this->doctrine->getManager(), $repository);
        }
        return $crudService;
    }
706340
public function getCollection(Request $request)
    {
        /** @var \SymfonyId\AdminBundle\Configuration\ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);

        $reflectionModel = new \ReflectionClass($crudConfigurator->getCrud()->getModelClass());
        /** @var \SymfonyId\AdminBundle\Annotation\Driver $driver */
        $driver = $this->get('symfonyid.admin.manager.driver_finder')->findDriverForClass($reflectionModel->getName());
        /** @var \SymfonyId\AdminBundle\Crud\CrudOperationHandler $crudOperationHandler */
        $crudOperationHandler = $this->get('symfonyid.admin.crud.crud_operation_handler');

        $requestParam = new RequestParameter($request);

        /*
         * Convert from KnpPaginator to Pagerfanta.
         */
        /** @var \Knp\Component\Pager\Pagination\AbstractPagination $knpPaginator */
        $knpPaginator = $crudOperationHandler->paginateResult($driver, $reflectionModel->getName(), $requestParam->getPage(), $requestParam->getLimit());
        $pagerAdapter = new ArrayAdapter($knpPaginator->getItems());

        $pager = new Pagerfanta($pagerAdapter);
        $pager->setCurrentPage($requestParam->getPage());
        $pager->setMaxPerPage($requestParam->getLimit());

        $embed = strtolower($reflectionModel->getShortName().'s');
        $pagerFactory = new PagerfantaFactory();
        $representation = $pagerFactory->createRepresentation(
            $pager,
            new Route($request->get('_route'), $requestParam->toArray()),
            new CollectionRepresentation($pager->getCurrentPageResults(), $embed, $embed)
        );

        return $this->createResponse($representation);
    }
210633
public function getUpdateForm($id)
    {
        /** @var \SymfonyId\AdminBundle\Configuration\ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_UPDATE);

        /** @var ModelInterface $model */
        $model = $this->findOr404Error($id);
        $form = $crudConfigurator->getForm($model, 'PUT');

        return $this->createResponse($this->getNormalizedForm($form));
    }
239222
public function render(ControlManager $controlManager, JsonBuilder $jsonBuilder)
    {
        foreach ($this->renderers as $renderer) {
            $control = get_class($renderer);

            if (($position = strrpos($control, '\\')) !== false) {
                $control = substr($control, ++$position, -8);
            }

            if ($controlManager->{'has'.$control}()) {
                $lcControl = lcfirst($control);

                $jsonBuilder
                    ->setValue('['.$lcControl.']', true)
                    ->setValue('['.$lcControl.'Options]', $renderer->render($controlManager->{'get'.$control}()), false);
            }
        }
    }
609489
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $frontController = FrontController::getInstance();

        // handle injections
        $frontController->setDispatcher($serviceLocator->get('Dispatcher'));
        $frontController->setRequest($serviceLocator->get('Request'));
        $frontController->setResponse($serviceLocator->get('Response'));
        $frontController->setRouter($serviceLocator->get('Router'));

        // get config
        $appConfig = $serviceLocator->get('Config');
        if (isset($appConfig['front_controller'])) {
            $config = ArrayUtils::merge($this->defaultOptions, $appConfig['front_controller']);
        } else {
            $config = $this->defaultOptions;
        }

        // handle configuration
        $frontController->setModuleControllerDirectoryName($config['module_controller_directory_name']);
        $frontController->setBaseUrl($config['base_url']);
        $frontController->setControllerDirectory($config['controller_directory']);
        $frontController->throwExceptions($config['throw_exceptions']);
        $frontController->returnResponse($config['return_response']);
        $frontController->setDefaultModule($config['default_module']);
        $frontController->setDefaultAction($config['default_action']);
        $frontController->setDefaultControllerName($config['default_controller_name']);
        $frontController->setParams($config['params']);
        foreach ($config['plugins'] as $plugin) {
            if (is_array(($plugin))) {
                $pluginClass = $plugin['class'];
                $stackIndex = $plugin['stack_index'];
            } else {
                $pluginClass = $plugin;
                $stackIndex = null;
            }
            // plugins can be loaded with service locator
            if ($serviceLocator->has($pluginClass)) {
                $plugin = $serviceLocator->get($pluginClass);
            } else {
                $plugin = new $pluginClass();
            }
            $frontController->registerPlugin($plugin, $stackIndex);
        }

        // set action helper plugin manager
        $actionHelperManager = $serviceLocator->get('ActionHelperManager');
        ActionHelperBroker::setPluginLoader($actionHelperManager);
        ActionHelperBroker::addHelper($actionHelperManager->get('viewRenderer'));

        // start layout, if needed
        if (isset($appConfig['layout'])) {
            Layout::startMvc($appConfig['layout']);
        }

        return $frontController;
    }
222729
public function findConfiguration($resource, $throwException = true)
    {
        // By object
        if (is_object($resource)) {
            foreach ($this->configurations as $config) {
                if ($config->isRelevant($resource)) {
                    return $config;
                }
            }
        // By class
        } elseif (class_exists($resource, false)) {
            foreach ($this->configurations as $config) {
                if ($resource == $config->getResourceClass()) {
                    return $config;
                }
            }
        // By configuration identifier
        } elseif (is_string($resource)) {
            // By Alias
            if ($this->has($resource)) {
                return $this->get($resource);
            }
            // By Id
            foreach($this->configurations as $config) {
                if ($resource == $config->getId()) {
                    return $config;
                }
            }
        }

        if ($throwException) {
            throw new NotFoundConfigurationException($resource);
        }

        return null;
    }